Apply improvements suggested in GitHub PullRequest #3065:
- be idiomatic
- 0 is falsy
- check enum equality, not identity
- mutate list by constructing a new one
- improve documentation
- fix a typo
- do not mention deprecation of a config option
Configure the replaygain analysis by passing arguments to the Backends. This
avoids the difference between ReplayGain and EBU r128 backends; every Backend
can now fulfil both tasks. Additionally it eases Backend development as the
difference between the two tag formats is now completely handled in the main
Plugin, not in the Backends.
Use the POSIX character class instead of `\s` to match all whitespace in a
regular expression describing the language of valid inputs, in order to avoid a
test failure for the invalid escape sequence `\s` in Python strings.
This commit mostly addresses feedback:
- remove some unused parenthesis
- fix a typo
- expand some docstrings
- document that ffmpeg is usually easy to install
Add replaygain backend using ffmpeg's ebur128 filter.
The album gain is calculated as the mean of all BS.1770 gating block powers.
Besides differences in gating block offset, this should be equivalent to a
BS.1770 analysis of a proper concatenation of all tracks.
Just calculating the mean of all track gains (as implemented by the bs1770gain
backend) yields incorrect results as that would:
- completely ignore track lengths
- just using length in seconds won't work either (e.g. BS.1770 ignores
passages below a threshold)
- take the mean of track loudness, not power
When using the ffmpeg replaygain backend to create R128_*_GAIN tags, the
targetlevel will be set to -23 LUFS. GitHub PullRequest #3065 will make this
configurable.
It will also skip peak calculation, as there is no R128_*_PEAK tag.
It is checked if the libavfilter library supports replaygain calculation. Before
version 6.67.100 that did require the `--enable-libebur128` compile-time-option,
after that the ebur128 library is included in libavfilter itself. Thus we
require either a recent enough libavfilter version or the `--enable-libebur128`
option.
Previously using EBU R128 forced the use of the bs1770gain backend.
This change adds a whitelist of backends supporting R128. When the configured
backend is in that list it will also be used for R128 calculations. Otherwise
bs1770gain is still used as a default.
This should not change the overall behaviour of the program at all, but allow
for further R128-supporting backends to be added.
Return a namedtuple CommandOutput(stdout, stderr) instead of just stdout from
util.command_ouput, allowing separate access to stdout and stderr.
This change is required by the ffmpeg replaygain backend (GitHub
PullRequest #3056) as ffmpeg's ebur128 filter outputs only to stderr.
Since commit 95e569a, mediafile takes care of the float -> Q7.8 conversion in
R128 GAIN tags by itself.
From `store_album_r128_gain` this conversion was already missing, remove it from
`store_track_r128_gain`, too.
fixes#3311
I'm not sure where these are used, but the website supports https and
the API url already uses https, so this should be a safe call and not
require a util.SNI_SUPPORTED check.
*All* URLs were checked manually, but only once per domain!
I mostly concerned myself with URLs in documentation rather than source
code because the latter may or may not have impactful changes, while the
former should be straight forward.
Changes in addition to simply adding an s:
- changed pip and pypi references as their location has changed
- MPoD (iOS app) url redirects to Regelian, so I replaced those
- updated homebrew references
Notable observations:
- beets.io does have HTTPS set up properly (via gh-pages)
- beatport.py uses the old HTTP url for beatport
- as does lyrics.py for lyrics.wikia.com
- https://tomahawk-player.org/ expired long ago, but the http page
redirects to https regardless
- none of the sourceforge subdomains have https (in 2019!)
The real MPD ignores `noidle` when the client is not idle. It doesn't
even send a successful response, just ignores the command. Although
I don't understand why a client would fail to keep track of its own
state, it seems that this is necessary to get ncmpcpp working.
The playlistid command is supposed to list the whole playlist if no
argument is provided, but we were accidentally trying to look up an
impossible negative id in that case causing an error to always be
returned.
As detailed here:
https://github.com/beetbox/beets/issues/2406#issuecomment-274423601
In a *function-style* definition, we didn't properly *un-define* the
values for a given item after each function invocation. So when a field
wasn't defined, it would get the value for the previously-formatted
object instead. It now properly throws a NameError.
This uses GStreamer APIs to extract a list of audio decoders and the
relevant MIME types and file extensions. Some clients like ncmpcpp use
this command to fetch a list of supported file extensions.
Some clients list the albums belonging to an artist by issuing the
command `list album <ARTIST NAME>`. This change inserts the tag `artist`
before the artist name so that this succeeds. Fixes#3007
A new `ControlConnection` is created each time a client connects over
a new control socket. This is used to forward events from the player,
and also for debugging utilities that are not part of the real MPD
protocol.
This new feature reuses as much infrastructure from the normal protocol
handling as possible (e.g. `Command` for parsing messages). While the
normal connection delegates to server `cmd_*` methods which are string
generators, the control connections delegate to `ctrl_*` methods defined
on the connection itself that are full coroutines.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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".
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.
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.
Although crossfade is not implemented in bpd, we can store the setting
and repeat is back to clients. Also log a warning that the operation is
not implemented.
The real MPD doesn't show the crossfade in status if it's zero since
that means no crossfade, so now we don't either.
Previously the `the` plugin would log a debug message when the text _didn't_ get changed by the plugin, whereas I think what was intended was the opposite. With this change the logged messages show the actual transformations made by the plugin.
Probably fixes#3165. There were several things going wrong here:
1. For some reason, this was using the *filesystem* encoding, which is
what you use to decode filenames. But this was general command
output, not filenames.
2. Errors in decoding threw exceptions, even though all we do with this
output is show it to the user.
3. The prints were using `displayable_path`, even though the lines are
*already* Unicode strings.
Hopefully this cleans up that mess.
Today I had some network problems regarding dbpedia.org, which made
beets crash because a requests.exceptions.ConnectionError was raised
("[Errno 113] No route to host"). This commits adds some error handling
around network requests to prevent further crashes in the future.
Adds M3U playlist support as a query to beets and thus partially
resolves issue #123. The implementation is heavily based on #2380 by
Robin McCorkell.
It supports referencing playlists by absolute path:
$ beet ls playlist:/path/to/someplaylist.m3u
It also supports referencing playlists by name. The playlist is then
seached in the playlist_dir and the ".m3u" extension is appended to the
name:
$ beet ls playlist:anotherplaylist
The configuration for the plugin looks like this:
playlist:
relative_to: library
playlist_dir: /path/to/playlists
The relative_to option specifies how relative paths in playlists are
handled. By default, paths are relative to the "library" directory. It
also possible to make them relative to the "playlist" or set the option
or set it to a fixed path.