Commit graph

8756 commits

Author SHA1 Message Date
Carl Suster
e70b2134e4 bpd: update documentation 2019-04-08 11:40:24 +10:00
Carl Suster
275301750a Changelog for #3205 2019-04-08 11:40:24 +10:00
Carl Suster
6fbf3853f2 bpd: bump protocol version to 0.14.0 2019-04-08 11:40:24 +10:00
Carl Suster
d05ca2c2b0 bpd: add tests for idle command 2019-04-08 11:40:24 +10:00
Carl Suster
699de94f4f bpd: send all relevant idle events 2019-04-08 11:40:24 +10:00
Carl Suster
7105c800aa bpd: implement the idle command
Getting this command puts the connection into a special mode where it
awaits MPD events (like the player changing state or the playlist
changing due to other clients interacting with the server.

The MPD specification states that events should queue while a client is
connected, and when it issues the `idle` command any matching events
should be sent immediately if there are any, or as soon as they happen
otherwise.
2019-04-08 11:40:24 +10:00
Carl Suster
ee0c31ba6a bpd: track and log client session details
Keep track of a list of currently-connected clients.

Use `socket.getpeername()` to get an identifier for each connection and
include this in each log message. This function is documented as not
being available on all systems, but it's unclear which systems this
involves.

Also log a message on client connect and disconnect events. If the
disconnection reason is because the client sent a blank line, match MPD
by returning a protocol error then hanging up. Escape curly braces.
2019-04-08 11:28:56 +10:00
Carl Suster
5b0a02eb31 bpd: don't send volume if zero in status 2019-04-08 10:52:15 +10:00
Carl Suster
f8a2c22e8d bpd: fix typo in comment 2019-04-08 10:52:15 +10:00
Carl Suster
bb1613694b
Merge pull request #3209 from arcresu/prune_dirs-except
Catch OSError in prune_dirs helper
2019-04-08 09:47:38 +10:00
Adrian Sampson
362722c87c
Merge pull request #3206 from arcresu/random-util
random: move functionality into beets.random
2019-04-07 11:59:39 -04:00
Carl Suster
9147fabb97 random: beets.util.random -> beets.random 2019-04-07 18:46:11 +10:00
Carl Suster
df5579d4a8
Merge pull request #3210 from gdtwst/mpdstats_quickfix
mpdstats: Re-add fixes from #2707
2019-04-07 18:00:18 +10:00
Carl Suster
27599410e8 Changelog for #3209 2019-04-07 16:39:28 +10:00
Jack Wilson
dc897c0bb9 Catch OSError in prune_dirs
Since `fnmatch_all` can raise `OSError`s, and we were already silently
giving up in `prune_dirs` on some of these exception, just do more of
the same.
2019-04-07 16:31:21 +10:00
gdtwst
c41197cc5c Re-add fixes from #2707 2019-04-07 10:07:38 +07:00
Adrian Sampson
ebed21f319 Merge pull request #3207 from arcresu/mpd-currentsong
mpdstats: use currentsong instead of playlist
2019-04-06 13:51:18 -04:00
Adrian Sampson
2748527407 Changelog for #3054 2019-04-06 13:49:50 -04:00
Adrian Sampson
63b7ede4f7 Merge pull request #3054 from discopatrick/2704-lastgenre-force
WIP: Remove `default` arg for `lastgenre --force` flag
2019-04-06 13:49:07 -04:00
Adrian Sampson
d17ac8699f
Merge pull request #3199 from thomas-mc-work/patch-1
Provide an example for the languages list
2019-04-06 12:41:35 -04:00
Thomas McWork
0e93b0f58d
follow comment explanation 2019-04-06 09:29:15 +02:00
Carl Suster
f35eda717b Changelog for #3207 2019-04-06 15:36:52 +11:00
Carl Suster
4158bdb95e mpdstats: update tests for currentsong 2019-04-06 15:31:03 +11:00
Rainer Unseld
ce5981b885 mpdstats: use currentsong instead of playlist
Improved the method to get the path of the current song. Before, the complete playlist was fetched from the server. Now, the command "currentsong" is used for this purpose. This improves performance when a huge playlist is active.
2019-04-06 15:23:34 +11:00
Carl Suster
9056467fdc random: allow custom random generator 2019-04-06 12:12:52 +11:00
Carl Suster
438009ba94 random: add test for equal_chance_permutation 2019-04-06 12:10:27 +11:00
Carl Suster
f35944f49c random: move implementation to beets.util.random 2019-04-06 11:06:19 +11:00
Adrian Sampson
a1e26bd8d8
Merge pull request #3200 from arcresu/bpd2
bpd: extend coverage of MPD protocol
2019-04-02 10:09:51 -04:00
Carl Suster
95dd513b25 bpd: add flake8 exception for test command 2019-04-02 14:25:56 +11:00
Carl Suster
140d25df52 Changelog for #3200 2019-04-02 13:50:16 +11:00
Carl Suster
20e2f8beec bpd: output an info-level message when ready 2019-04-02 13:38:43 +11:00
Carl Suster
d074dac771 bpd: add comments to the error handling code 2019-04-02 13:37:40 +11:00
Carl Suster
28db7d3d33 bpd: provide precision time in status 2019-04-02 11:15:00 +11:00
Carl Suster
4be2e1b5e6 Remove beets.util.inspect wrapper 2019-04-02 10:22:47 +11:00
Carl Suster
36c85a8aeb Fix beets.util.inspect for Python 3
Under the original compatibility shim we weren't correctly inclusing
`self` in the argument list for bound methods.
2019-04-02 10:11:43 +11:00
Carl Suster
9622e7433b bpd: return real audio data 2019-04-02 09:44:34 +11:00
Carl Suster
e839e4ea19 bpd: improve exception handling
Check function signature instead of using TypeError to crudely guess
that the wrong number of arguments were provided.

Prevent bpd from crashing when trying to log a traceback. The
`traceback.format_exc` function takes an optional argument which is
supposed to be an integer restricting the length of the backtrace to
show. Instead we were passing the exception object to this function and
causing a new exception to be raised.
2019-04-02 09:39:07 +11:00
Thomas McWork
4cbe116e42
use most simple syntax 2019-04-01 09:13:36 +02:00
Carl Suster
146c5f5e13 bpd: fix repeat, consume and single in reverse
These flags are all relevant to the 'previous' command as well as the
'next' command.
2019-04-01 18:05:10 +11:00
Carl Suster
12e49b3c88 bpd: skipping backwards through zero keeps playing
Previously issuing the 'previous' command when at position 0 on the
playlist would cause bpd to stop playing. MPD instead just restarts the
currently playing song instead, so we now match this behaviour.
2019-04-01 17:51:21 +11:00
Carl Suster
a4fe6875a1 bpd: fix bug in bounds check of current song index
The songs are indexed starting from zero for the play command, however
the bound check was off by one. An index matching the length of the
playlist would crash the server instead of responding with an error
message over the protocol.
2019-04-01 17:41:25 +11:00
Carl Suster
0c3a63ef9f bpd: fix repeat mode behaviour
The repeat flag indicates that the entire playlist should be repeated.
If both the repeat and single flags are set then this triggers the old
behaviour of looping over a single track.
2019-04-01 17:39:35 +11:00
Carl Suster
b245c0e755 bpd: test fields returned by status command 2019-04-01 16:42:39 +11:00
Carl Suster
bae9c40600 bpd: support the single command
This command instructs bpd to stop playing when the current song
finishes. In the MPD 0.20 protocol this flag gains a value 'oneshot' but
for now we just support its older version with a boolean value.
2019-04-01 16:30:02 +11:00
Carl Suster
71e7621642 bpd: no-op support for persistent playlists
The real MPD offers persistent playlist manipulation, storing the
playlists in a directory set in the config file. If that directory is
not available then the feature is disabled and the relevant commands all
respond with errors. Based on this, the initial support in bpd just
returns errors matching the MPD server in the disabled mode.

For playlistadd, extend the _bpd_add helper to work with playlists other
than the queue in order to support testing the real implementations of
these commands in the future.
2019-04-01 16:30:02 +11:00
Carl Suster
859e16d1e3 bpd: support consume command 2019-04-01 16:30:02 +11:00
Carl Suster
e5851866d7 bpd: add replay_gain_* commands
There's a special status command for checking the replay gain mode,
which can be set to one of a short list of possible values. For now at
least we can ignore this feature, but track the setting anyway.
2019-04-01 14:49:27 +11:00
Carl Suster
67a0b38d20 bpd: add dummy command for volume
MPD supports a deprecated command 'volume' which was used to change the
volume by a relative amount unlike its replacement 'setvol' which uses
an absolute amount. As far as I can tell 'volume' always responds with a system
error message "No mixer".
2019-04-01 14:49:27 +11:00
Carl Suster
1511e313f7 bpd: add mixramp commands
These are a more sophisticated version of crossfade so we're free to
ignore them, at least for now. We now track the values of the two
settings, and show them in the status output. Like MPD, we suppress the
mixrampdb value if it's set to nan, which is how it signals that the
feature should be turned off.
2019-04-01 14:49:27 +11:00
Carl Suster
0f53ae9a87 bpd: error instead of crashing on extra argument
If an MPC client is expecting a command to take an argument that bpd
isn't expecting (e.g. because of a difference in protocol versions) then
bpd currently crashes completely. Instead, do what the real MPD does and
return an error message over the protocol.
2019-04-01 14:49:27 +11:00