GithubHelp home page GithubHelp logo

thekakkun / beets-mpd-utils Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 64 KB

Beets plugins for interfacing with MPD

License: MIT License

Python 100.00%
beets beets-plugin mpd music music-player-daemon

beets-mpd-utils's Introduction

beets-mpd-utils

Some beets plugins to interface with Music Player Daemon.

  • MPD Tracker: Track song plays/skips on MPD.
  • MPD DJ: Auto-add songs/albums to your MPD queue.

Installation

Install the plugin.

pip install beets-mpd-utils

Enable the plugin by adding it the plugins option in your beets config.

plugins: mpd_tracker, mpd_dj

Provided Plugins

MPD Tracker

The mpd_tracker plugin tracks song plays and skips on MPD and records them in the following flexible attributes:

  • Song
    • play_count: The number of times the song has been played.
    • last_played: When the play_count was last updated.
    • skip_count: The number of times the song has beed skipped.
  • Album
    • last_played: Only written once every song in the album has been played. Defined as the oldest last_played value for the songs in the album.

Usage

Once enabled, start the tracker by typing:

beet tracker

Configuration

To configure, make a mpd_tracker section in your beets config file. Songs will be considered played/skipped if either of the time/percentage thresholds are met.

The available options are:

  • play_time: The amount of seconds played after which the song will be considered "played". Default: 240.
  • play_percent: The percentage of the song that needs to be played before being considered "played". Expects a value between 0 and 1, default: 0.5.
  • skip_time: The amount of seconds played before which the song will be considered "skipped". Default: 20.
  • skip_percent: The percentage of the song that needs to be played before which the song will be considered "skipped". Expects a value between 0 and 1, default: 0.0.

MPD DJ

The mpd_dj plugin randomly adds items to the MPD queue. Note that activating this plugin will turn off random mode in MPD, as it needs to know what songs are upcoming in the queue.

Usage

Once enabled, start the tracker by typing:

beet dj

By default, the plugin will work to maintain 20 upcoming songs, selected randomly from the library. These defaults can be changed using command-line options.

  • --number=ITEMS, -n ITEMS: The plugin will maintain the specified number of items in the upcoming queue.
  • --album, -a: The plugin will queue albums instead of songs.

In addition, you can enter a query to specify what will be added to the queue.

# maintain 5 albums in the queue, pulling randomly from albums released in 2022
beet dj -n 5 --album year:2022

beets-mpd-utils's People

Contributors

thekakkun avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

beets-mpd-utils's Issues

Rating in tracker plugin?

Hi,

Would you be open to adding a rating key to the tracker plugin, like the mpdstats plugin does? mpdstats bases the rating off of play_count and skip_count. That's a useful attribute to have, imo.

I would use mpdstats, but I much prefer how your plugin allows for configuring play_count and skip_count.

Just an idea!

Crashing

Hi, thanks for sharing this. It's a very useful extension.

I am having trouble getting it to work :/

I followed the install instructions, i.e, beets is on version 1.6.1, python on 3.11.5, running on archlinux.

Traceback (most recent call last):
  File "/home/clu/.python/bin/beet", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/clu/.python/lib/python3.11/site-packages/beets/ui/__init__.py", line 1782, in main
    _raw_main(args)
  File "/home/clu/.python/lib/python3.11/site-packages/beets/ui/__init__.py", line 1769, in _raw_main
    subcommand.func(lib, suboptions, subargs)
  File "/home/clu/.python/lib/python3.11/site-packages/beetsplug/mpd_tracker.py", line 56, in _func
    asyncio.run(self.run(lib))
  File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/clu/.python/lib/python3.11/site-packages/beetsplug/mpd_tracker.py", line 77, in run
    self.set_skipped(lib, song)
  File "/home/clu/.python/lib/python3.11/site-packages/beetsplug/mpd_tracker.py", line 121, in set_skipped
    item["skip_count"] = item.get("skip_count", 0) + 1
                         ^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get'
Exception ignored in: <function StreamWriter.__del__ at 0x7fd184cc1620>
Traceback (most recent call last):
  File "/usr/lib/python3.11/asyncio/streams.py", line 396, in __del__
  File "/usr/lib/python3.11/asyncio/streams.py", line 344, in close
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 860, in close
  File "/usr/lib/python3.11/asyncio/base_events.py", line 761, in call_soon
  File "/usr/lib/python3.11/asyncio/base_events.py", line 519, in _check_closed
RuntimeError: Event loop is closed

If you have any ideas I am all ears! Thanks for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.