beets: 1.4.9 -> unstable-2020-12-22

The maintainer has stopped cutting releases[1]. Since the last release,
1.4.9, includes a dependency that is filled with hate speech[2] it's all
the more reason to package the unstable version and eliminate that
requirement.

Moreover a number of fixes, improvements, and features have landed
since.

[1]: https://github.com/beetbox/beets/issues/3625
[2]: https://github.com/NixOS/nixpkgs/pull/90504

Co-authored-by: Doron Behar <doron.behar@gmail.com>
This commit is contained in:
Bernardo Meurer 2021-01-02 15:47:09 -08:00 committed by Doron Behar
parent 52a4a170b9
commit 0faf72a557
14 changed files with 233 additions and 207 deletions

View File

@ -0,0 +1,21 @@
diff --git i/beetsplug/badfiles.py w/beetsplug/badfiles.py
index 36b45de3..5208b696 100644
--- i/beetsplug/badfiles.py
+++ w/beetsplug/badfiles.py
@@ -71,14 +71,14 @@ class BadFiles(BeetsPlugin):
return status, errors, [line for line in output.split("\n") if line]
def check_mp3val(self, path):
- status, errors, output = self.run_command(["mp3val", path])
+ status, errors, output = self.run_command(["@mp3val@/bin/mp3val", path])
if status == 0:
output = [line for line in output if line.startswith("WARNING:")]
errors = len(output)
return status, errors, output
def check_flac(self, path):
- return self.run_command(["flac", "-wst", path])
+ return self.run_command(["@flac@/bin/flac", "-wst", path])
def check_custom(self, command):
def checker(path):

View File

@ -0,0 +1,43 @@
diff --git i/beets/ui/commands.py w/beets/ui/commands.py
index 4d010f4b..0b023585 100755
--- i/beets/ui/commands.py
+++ w/beets/ui/commands.py
@@ -1741,20 +1741,6 @@ default_commands.append(config_cmd)
def print_completion(*args):
for line in completion_script(default_commands + plugins.commands()):
print_(line, end=u'')
- if not any(map(os.path.isfile, BASH_COMPLETION_PATHS)):
- log.warning(u'Warning: Unable to find the bash-completion package. '
- u'Command line completion might not work.')
-
-BASH_COMPLETION_PATHS = map(syspath, [
- u'/etc/bash_completion',
- u'/usr/share/bash-completion/bash_completion',
- u'/usr/local/share/bash-completion/bash_completion',
- # SmartOS
- u'/opt/local/share/bash-completion/bash_completion',
- # Homebrew (before bash-completion2)
- u'/usr/local/etc/bash_completion',
-])
-
def completion_script(commands):
"""Yield the full completion shell script as strings.
diff --git i/test/test_ui.py w/test/test_ui.py
index 5cfed1fd..9d3dc458 100644
--- i/test/test_ui.py
+++ w/test/test_ui.py
@@ -1230,12 +1230,7 @@ class CompletionTest(_common.TestCase, TestHelper):
stdout=subprocess.PIPE, env=env)
# Load bash_completion library.
- for path in commands.BASH_COMPLETION_PATHS:
- if os.path.exists(util.syspath(path)):
- bash_completion = path
- break
- else:
- self.skipTest(u'bash-completion script not found')
+ self.skipTest(u'bash-completion script not found')
try:
with open(util.syspath(bash_completion), 'rb') as f:
tester.stdin.writelines(f)

View File

@ -1,55 +0,0 @@
From 771ce704ebeac4cd9bd74b3ddde9fb01f3dc7eb4 Mon Sep 17 00:00:00 2001
From: wisp3rwind <17089248+wisp3rwind@users.noreply.github.com>
Date: Tue, 9 Jun 2020 19:34:31 +0200
Subject: [PATCH] compatibility with breaking changes to the ast module
new in 3.10, also backported to 3.8 and 3.9: https://github.com/python/cpython/pull/20649
In fact, our generation of some Literals has been invalid since Python
3.4, fix that too.
---
beets/util/functemplate.py | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/beets/util/functemplate.py b/beets/util/functemplate.py
index af22b790..266534a9 100644
--- a/beets/util/functemplate.py
+++ b/beets/util/functemplate.py
@@ -73,15 +73,26 @@ def ex_literal(val):
"""An int, float, long, bool, string, or None literal with the given
value.
"""
- if val is None:
- return ast.Name('None', ast.Load())
- elif isinstance(val, six.integer_types):
- return ast.Num(val)
- elif isinstance(val, bool):
- return ast.Name(bytes(val), ast.Load())
- elif isinstance(val, six.string_types):
- return ast.Str(val)
- raise TypeError(u'no literal for {0}'.format(type(val)))
+ if sys.version_info[:2] < (3, 4):
+ if val is None:
+ return ast.Name('None', ast.Load())
+ elif isinstance(val, six.integer_types):
+ return ast.Num(val)
+ elif isinstance(val, bool):
+ return ast.Name(bytes(val), ast.Load())
+ elif isinstance(val, six.string_types):
+ return ast.Str(val)
+ raise TypeError(u'no literal for {0}'.format(type(val)))
+ elif sys.version_info[:2] < (3, 6):
+ if val in [None, True, False]:
+ return ast.NameConstant(val)
+ elif isinstance(val, six.integer_types):
+ return ast.Num(val)
+ elif isinstance(val, six.string_types):
+ return ast.Str(val)
+ raise TypeError(u'no literal for {0}'.format(type(val)))
+ else:
+ return ast.Constant(val)
def ex_varassign(name, expr):
--
2.27.0

View File

@ -0,0 +1,43 @@
diff --git i/beetsplug/convert.py w/beetsplug/convert.py
index 70363f6e..2962aa4f 100644
--- i/beetsplug/convert.py
+++ w/beetsplug/convert.py
@@ -81,7 +81,7 @@ def get_format(fmt=None):
command = config['convert']['command'].as_str()
elif 'opts' in keys:
# Undocumented option for backwards compatibility with < 1.3.1.
- command = u'ffmpeg -i $source -y {0} $dest'.format(
+ command = u'@ffmpeg@/bin/ffmpeg -i $source -y {0} $dest'.format(
config['convert']['opts'].as_str()
)
if 'extension' in keys:
@@ -121,22 +121,22 @@ class ConvertPlugin(BeetsPlugin):
u'id3v23': u'inherit',
u'formats': {
u'aac': {
- u'command': u'ffmpeg -i $source -y -vn -acodec aac '
+ u'command': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec aac '
u'-aq 1 $dest',
u'extension': u'm4a',
},
u'alac': {
- u'command': u'ffmpeg -i $source -y -vn -acodec alac $dest',
+ u'command': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec alac $dest',
u'extension': u'm4a',
},
- u'flac': u'ffmpeg -i $source -y -vn -acodec flac $dest',
- u'mp3': u'ffmpeg -i $source -y -vn -aq 2 $dest',
+ u'flac': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec flac $dest',
+ u'mp3': u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -aq 2 $dest',
u'opus':
- u'ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest',
+ u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec libopus -ab 96k $dest',
u'ogg':
- u'ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest',
+ u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec libvorbis -aq 3 $dest',
u'wma':
- u'ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest',
+ u'@ffmpeg@/bin/ffmpeg -i $source -y -vn -acodec wmav2 -vn $dest',
},
u'max_bitrate': 500,
u'auto': False,

View File

@ -1,4 +1,4 @@
{ stdenv, fetchFromGitHub, writeScript, glibcLocales, diffPlugins
{ stdenv, lib, fetchFromGitHub, writeScript, glibcLocales, diffPlugins, substituteAll
, pythonPackages, imagemagick, gobject-introspection, gst_all_1
, runtimeShell
, fetchpatch
@ -6,11 +6,14 @@
# Attributes needed for tests of the external plugins
, callPackage, beets
, enableAbsubmit ? stdenv.lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
, enableAbsubmit ? lib.elem stdenv.hostPlatform.system essentia-extractor.meta.platforms, essentia-extractor ? null
, enableAcousticbrainz ? true
, enableAcoustid ? true
, enableBadfiles ? true, flac ? null, mp3val ? null
, enableConvert ? true, ffmpeg_3 ? null
, enableBeatport ? true
, enableBpsync ? true
, enableConvert ? true, ffmpeg ? null
, enableDeezer ? true
, enableDiscogs ? true
, enableEmbyupdate ? true
, enableFetchart ? true
@ -21,8 +24,9 @@
, enableLoadext ? true
, enableMpd ? true
, enablePlaylist ? true
, enableReplaygain ? true, bs1770gain ? null
, enableReplaygain ? true
, enableSonosUpdate ? true
, enableSubsonicplaylist ? true
, enableSubsonicupdate ? true
, enableThumbnails ? true
, enableWeb ? true
@ -39,28 +43,33 @@
assert enableAbsubmit -> essentia-extractor != null;
assert enableAcoustid -> pythonPackages.pyacoustid != null;
assert enableBadfiles -> flac != null && mp3val != null;
assert enableBeatport -> pythonPackages.requests_oauthlib != null;
assert enableBpsync -> enableBeatport;
assert enableCheck -> flac != null && mp3val != null && liboggz != null;
assert enableConvert -> ffmpeg_3 != null;
assert enableConvert -> ffmpeg != null;
assert enableDiscogs -> pythonPackages.discogs_client != null;
assert enableFetchart -> pythonPackages.responses != null;
assert enableGmusic -> pythonPackages.gmusicapi != null;
assert enableKeyfinder -> keyfinder-cli != null;
assert enableLastfm -> pythonPackages.pylast != null;
assert enableMpd -> pythonPackages.mpd2 != null;
assert enableReplaygain -> bs1770gain != null;
assert enableReplaygain -> ffmpeg != null;
assert enableSonosUpdate -> pythonPackages.soco != null;
assert enableThumbnails -> pythonPackages.pyxdg != null;
assert enableWeb -> pythonPackages.flask != null;
with stdenv.lib;
with lib;
let
optionalPlugins = {
absubmit = enableAbsubmit;
acousticbrainz = enableAcousticbrainz;
badfiles = enableBadfiles;
beatport = enableBeatport;
bpsync = enableBpsync;
chroma = enableAcoustid;
convert = enableConvert;
deezer = enableDeezer;
discogs = enableDiscogs;
embyupdate = enableEmbyupdate;
fetchart = enableFetchart;
@ -75,18 +84,19 @@ let
playlist = enablePlaylist;
replaygain = enableReplaygain;
sonosupdate = enableSonosUpdate;
subsonicplaylist = enableSubsonicplaylist;
subsonicupdate = enableSubsonicupdate;
thumbnails = enableThumbnails;
web = enableWeb;
};
pluginsWithoutDeps = [
"beatport" "bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
"export" "filefilter" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
"bench" "bpd" "bpm" "bucket" "cue" "duplicates" "edit" "embedart"
"export" "filefilter" "fish" "freedesktop" "fromfilename" "ftintitle" "fuzzy"
"hook" "ihate" "importadded" "importfeeds" "info" "inline" "ipfs" "lyrics"
"mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "permissions" "play"
"mbcollection" "mbsubmit" "mbsync" "metasync" "missing" "parentwork" "permissions" "play"
"plexupdate" "random" "rewrite" "scrub" "smartplaylist" "spotify" "the"
"types" "zero"
"types" "unimported" "zero"
];
enabledOptionalPlugins = attrNames (filterAttrs (_: id) optionalPlugins);
@ -102,28 +112,33 @@ let
enableAlternatives = false;
enableCopyArtifacts = false;
enableExtraFiles = false;
}).overrideAttrs (stdenv.lib.const {
}).overrideAttrs (const {
doInstallCheck = false;
});
pluginArgs = externalTestArgs // { inherit pythonPackages; };
plugins = {
alternatives = callPackage ./alternatives-plugin.nix pluginArgs;
check = callPackage ./check-plugin.nix pluginArgs;
copyartifacts = callPackage ./copyartifacts-plugin.nix pluginArgs;
extrafiles = callPackage ./extrafiles-plugin.nix pluginArgs;
alternatives = callPackage ./plugins/alternatives.nix pluginArgs;
check = callPackage ./plugins/check.nix pluginArgs;
copyartifacts = callPackage ./plugins/copyartifacts.nix pluginArgs;
extrafiles = callPackage ./plugins/extrafiles.nix pluginArgs;
};
in pythonPackages.buildPythonApplication rec {
pname = "beets";
version = "1.4.9";
# While there is a stable version, 1.4.9, it is more than 1000 commits behind
# master and lacks many bug fixes and improvements[1]. Also important,
# unstable does not require bs1770gain[2].
# [1]: https://discourse.beets.io/t/forming-a-beets-core-team/639
# [2]: https://github.com/NixOS/nixpkgs/pull/90504
version = "unstable-2020-12-22";
src = fetchFromGitHub {
owner = "beetbox";
repo = "beets";
rev = "v${version}";
sha256 = "1qxdqbzvz97zgykzdwn78g2xyxmg0q2jdb12dnjnrwvhmjv67vi8";
rev = "53dcb24d10788897f20c341774b474808ec2c0b6";
sha256 = "sha256-P++NA13T2TRHW3Se10np8BSe/WRBYAKRte5xKoHKW50=";
};
propagatedBuildInputs = [
@ -137,19 +152,25 @@ in pythonPackages.buildPythonApplication rec {
pythonPackages.unidecode
pythonPackages.gst-python
pythonPackages.pygobject3
pythonPackages.reflink
pythonPackages.confuse
pythonPackages.mediafile
gobject-introspection
] ++ optional enableAbsubmit essentia-extractor
++ optional enableAcoustid pythonPackages.pyacoustid
++ optional enableBeatport pythonPackages.requests_oauthlib
++ optional (enableFetchart
|| enableDeezer
|| enableEmbyupdate
|| enableKodiupdate
|| enableLoadext
|| enablePlaylist
|| enableSubsonicplaylist
|| enableSubsonicupdate
|| enableAcousticbrainz)
pythonPackages.requests
++ optional enableCheck plugins.check
++ optional enableConvert ffmpeg_3
++ optional enableConvert ffmpeg
++ optional enableDiscogs pythonPackages.discogs_client
++ optional enableGmusic pythonPackages.gmusicapi
++ optional enableKeyfinder keyfinder-cli
@ -187,41 +208,35 @@ in pythonPackages.buildPythonApplication rec {
];
patches = [
./replaygain-default-bs1770gain.patch
# Bash completion fix for Nix
./bash-completion-always-print.patch
# From some reason upstream assumes the program 'keyfinder-cli' is located
# in the path as `KeyFinder`
./keyfinder-default-bin.patch
./mutagen-1.43.patch
(fetchpatch {
# Fixes failing testcases around the werkzeug component; can dropped after 1.4.9
url = "https://github.com/beetbox/beets/commit/d43d54e21cde97f57f19486925ab56b419254cc8.patch";
sha256 = "13n2gzmcgfi0m2ycl2r1hpczgksplnkc3y6b66vg57rx5y8nnv5c";
]
# We need to force ffmpeg as the default, since we do not package
# bs1770gain, and set the absolute path there, to avoid impurities.
++ lib.optional enableReplaygain (substituteAll {
src = ./replaygain-default-ffmpeg.patch;
ffmpeg = getBin ffmpeg;
})
# Put absolute Nix paths in place
++ lib.optional enableConvert (substituteAll {
src = ./convert-plugin-ffmpeg-path.patch;
ffmpeg = getBin ffmpeg;
})
++ lib.optional enableBadfiles (substituteAll {
src = ./badfiles-plugin-nix-paths.patch;
inherit mp3val flac;
})
;
# Fixes 548 tests due to breaking changes to the ast module
# https://github.com/beetbox/beets/pull/3621
# Can be dropped after 1.4.9
./compatibility-with-breaking-changes-to-the-ast-module.patch
];
# Disable failing tests
postPatch = ''
sed -i -e '/assertIn.*item.*path/d' test/test_info.py
echo echo completion tests passed > test/rsrc/test_completion.sh
sed -i -e '/^BASH_COMPLETION_PATHS *=/,/^])$/ {
/^])$/i u"${completion}"
}' beets/ui/commands.py
'' + optionalString enableBadfiles ''
sed -i -e '/self\.run_command(\[/ {
s,"flac","${flac.bin}/bin/flac",
s,"mp3val","${mp3val}/bin/mp3val",
}' beetsplug/badfiles.py
'' + optionalString enableConvert ''
sed -i -e 's,\(util\.command_output(\)\([^)]\+\)),\1[b"${ffmpeg_3.bin}/bin/ffmpeg" if args[0] == b"ffmpeg" else args[0]] + \2[1:]),' beetsplug/convert.py
'' + optionalString enableReplaygain ''
sed -i -re '
s!^( *cmd *= *b?['\'''"])(bs1770gain['\'''"])!\1${bs1770gain}/bin/\2!
' beetsplug/replaygain.py
sed -i -e 's/if has_program.*bs1770gain.*:/if True:/' \
test/test_replaygain.py
sed -i -e 's/len(mf.images)/0/' test/test_zero.py
'';
postInstall = ''

View File

@ -1,8 +1,8 @@
diff --git a/beetsplug/keyfinder.py b/beetsplug/keyfinder.py
index 34a4abc..59e8539 100644
index 702003f0..08689cd8 100644
--- a/beetsplug/keyfinder.py
+++ b/beetsplug/keyfinder.py
@@ -30,7 +30,7 @@ class KeyFinderPlugin(BeetsPlugin):
@@ -31,7 +31,7 @@ class KeyFinderPlugin(BeetsPlugin):
def __init__(self):
super(KeyFinderPlugin, self).__init__()
self.config.add({
@ -11,18 +11,8 @@ index 34a4abc..59e8539 100644
u'auto': True,
u'overwrite': False,
})
@@ -59,8 +59,7 @@ class KeyFinderPlugin(BeetsPlugin):
continue
try:
- output = util.command_output([bin, '-f',
- util.syspath(item.path)])
+ output = util.command_output([bin, util.syspath(item.path)])
except (subprocess.CalledProcessError, OSError) as exc:
self._log.error(u'execution failed: {0}', exc)
continue
diff --git a/test/test_keyfinder.py b/test/test_keyfinder.py
index 57e2bcd..c1ee916 100644
index c8735e47..d7d670a4 100644
--- a/test/test_keyfinder.py
+++ b/test/test_keyfinder.py
@@ -44,7 +44,7 @@ class KeyFinderTest(unittest.TestCase, TestHelper):
@ -33,4 +23,4 @@ index 57e2bcd..c1ee916 100644
+ ['keyfinder-cli', util.syspath(item.path)])
def test_add_key_on_import(self, command_output):
command_output.return_value = 'dbm'
command_output.return_value = util.CommandOutput(b"dbm", b"")

View File

@ -1,40 +0,0 @@
Backport
https://github.com/beetbox/mediafile/commit/b3343c4ee08d1251ae5e2344401a2f5892b4e868
https://github.com/beetbox/mediafile/commit/d2fc3b59f77c515b02dfe7ad936f89264375d2b4
to Beets 1.4.9.
diff --git i/setup.py w/setup.py
index 79278f8b..b8d60687 100755
--- i/setup.py
+++ w/setup.py
@@ -87,7 +87,7 @@ setup(
install_requires=[
'six>=1.9',
- 'mutagen>=1.33',
+ 'mutagen>=1.43',
'unidecode',
'musicbrainzngs>=0.4',
'pyyaml',
diff --git i/test/test_mediafile.py w/test/test_mediafile.py
index 36a2c53a..0ddde44e 100644
--- i/test/test_mediafile.py
+++ w/test/test_mediafile.py
@@ -888,7 +888,7 @@ class WavpackTest(ReadWriteTestBase, unittest.TestCase):
'bitrate': 109312,
'format': u'WavPack',
'samplerate': 44100,
- 'bitdepth': 0,
+ 'bitdepth': 16,
'channels': 1,
}
@@ -912,7 +912,7 @@ class AIFFTest(ReadWriteTestBase, unittest.TestCase):
'bitrate': 705600,
'format': u'AIFF',
'samplerate': 44100,
- 'bitdepth': 0,
+ 'bitdepth': 16,
'channels': 1,
}

View File

@ -1,17 +0,0 @@
diff --git a/beetsplug/replaygain.py b/beetsplug/replaygain.py
index 40b3a3a..9b54a5a 100644
--- a/beetsplug/replaygain.py
+++ b/beetsplug/replaygain.py
@@ -627,11 +627,10 @@ class ReplayGainPlugin(BeetsPlugin):
super(ReplayGainPlugin, self).__init__()
self.import_stages = [self.imported]
- # default backend is 'command' for backward-compatibility.
self.config.add({
'overwrite': False,
'auto': True,
- 'backend': u'command',
+ 'backend': u'bs1770gain',
'targetlevel': 89,
})

View File

@ -0,0 +1,26 @@
diff --git i/beetsplug/replaygain.py w/beetsplug/replaygain.py
index 9d6fa23c..c5800039 100644
--- i/beetsplug/replaygain.py
+++ w/beetsplug/replaygain.py
@@ -391,7 +391,7 @@ class FfmpegBackend(Backend):
def __init__(self, config, log):
super(FfmpegBackend, self).__init__(config, log)
- self._ffmpeg_path = "ffmpeg"
+ self._ffmpeg_path = "@ffmpeg@/bin/ffmpeg"
# check that ffmpeg is installed
try:
@@ -1228,11 +1228,10 @@ class ReplayGainPlugin(BeetsPlugin):
def __init__(self):
super(ReplayGainPlugin, self).__init__()
- # default backend is 'command' for backward-compatibility.
self.config.add({
'overwrite': False,
'auto': True,
- 'backend': u'command',
+ 'backend': u'ffmpeg',
'threads': cpu_count(),
'parallel_on_import': False,
'per_disc': False,