mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 13:53:15 -07:00
Update vendored beets to 1.6.0
Updates colorama to 0.4.6 Adds confuse version 1.7.0 Updates jellyfish to 0.9.0 Adds mediafile 0.10.1 Updates munkres to 1.1.4 Updates musicbrainzngs to 0.7.1 Updates mutagen to 1.46.0 Updates pyyaml to 6.0 Updates unidecode to 1.3.6
This commit is contained in:
parent
5073ec0c6f
commit
56c6773c6b
385 changed files with 25143 additions and 18080 deletions
|
@ -1,4 +1,3 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# This file is part of beets.
|
||||
# Copyright 2016, Adrian Sampson.
|
||||
#
|
||||
|
@ -13,8 +12,6 @@
|
|||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
from __future__ import division, absolute_import, print_function
|
||||
import six
|
||||
|
||||
"""Gets genres for imported music based on Last.fm tags.
|
||||
|
||||
|
@ -46,7 +43,7 @@ PYLAST_EXCEPTIONS = (
|
|||
)
|
||||
|
||||
REPLACE = {
|
||||
u'\u2010': '-',
|
||||
'\u2010': '-',
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,7 +70,7 @@ def flatten_tree(elem, path, branches):
|
|||
for sub in elem:
|
||||
flatten_tree(sub, path, branches)
|
||||
else:
|
||||
branches.append(path + [six.text_type(elem)])
|
||||
branches.append(path + [str(elem)])
|
||||
|
||||
|
||||
def find_parents(candidate, branches):
|
||||
|
@ -97,7 +94,7 @@ C14N_TREE = os.path.join(os.path.dirname(__file__), 'genres-tree.yaml')
|
|||
|
||||
class LastGenrePlugin(plugins.BeetsPlugin):
|
||||
def __init__(self):
|
||||
super(LastGenrePlugin, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self.config.add({
|
||||
'whitelist': True,
|
||||
|
@ -108,8 +105,9 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
'source': 'album',
|
||||
'force': True,
|
||||
'auto': True,
|
||||
'separator': u', ',
|
||||
'separator': ', ',
|
||||
'prefer_specific': False,
|
||||
'title_case': True,
|
||||
})
|
||||
|
||||
self.setup()
|
||||
|
@ -132,18 +130,27 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
with open(wl_filename, 'rb') as f:
|
||||
for line in f:
|
||||
line = line.decode('utf-8').strip().lower()
|
||||
if line and not line.startswith(u'#'):
|
||||
if line and not line.startswith('#'):
|
||||
self.whitelist.add(line)
|
||||
|
||||
# Read the genres tree for canonicalization if enabled.
|
||||
self.c14n_branches = []
|
||||
c14n_filename = self.config['canonical'].get()
|
||||
if c14n_filename in (True, ''): # Default tree.
|
||||
self.canonicalize = c14n_filename is not False
|
||||
|
||||
# Default tree
|
||||
if c14n_filename in (True, ''):
|
||||
c14n_filename = C14N_TREE
|
||||
elif not self.canonicalize and self.config['prefer_specific'].get():
|
||||
# prefer_specific requires a tree, load default tree
|
||||
c14n_filename = C14N_TREE
|
||||
|
||||
# Read the tree
|
||||
if c14n_filename:
|
||||
self._log.debug('Loading canonicalization tree {0}', c14n_filename)
|
||||
c14n_filename = normpath(c14n_filename)
|
||||
with codecs.open(c14n_filename, 'r', encoding='utf-8') as f:
|
||||
genres_tree = yaml.load(f)
|
||||
genres_tree = yaml.safe_load(f)
|
||||
flatten_tree(genres_tree, [], self.c14n_branches)
|
||||
|
||||
@property
|
||||
|
@ -186,7 +193,7 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
return None
|
||||
|
||||
count = self.config['count'].get(int)
|
||||
if self.c14n_branches:
|
||||
if self.canonicalize:
|
||||
# Extend the list to consider tags parents in the c14n tree
|
||||
tags_all = []
|
||||
for tag in tags:
|
||||
|
@ -214,12 +221,17 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
|
||||
# c14n only adds allowed genres but we may have had forbidden genres in
|
||||
# the original tags list
|
||||
tags = [x.title() for x in tags if self._is_allowed(x)]
|
||||
tags = [self._format_tag(x) for x in tags if self._is_allowed(x)]
|
||||
|
||||
return self.config['separator'].as_str().join(
|
||||
tags[:self.config['count'].get(int)]
|
||||
)
|
||||
|
||||
def _format_tag(self, tag):
|
||||
if self.config["title_case"]:
|
||||
return tag.title()
|
||||
return tag
|
||||
|
||||
def fetch_genre(self, lastfm_obj):
|
||||
"""Return the genre for a pylast entity or None if no suitable genre
|
||||
can be found. Ex. 'Electronic, House, Dance'
|
||||
|
@ -251,8 +263,8 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
if any(not s for s in args):
|
||||
return None
|
||||
|
||||
key = u'{0}.{1}'.format(entity,
|
||||
u'-'.join(six.text_type(a) for a in args))
|
||||
key = '{}.{}'.format(entity,
|
||||
'-'.join(str(a) for a in args))
|
||||
if key in self._genre_cache:
|
||||
return self._genre_cache[key]
|
||||
else:
|
||||
|
@ -270,28 +282,28 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
"""Return the album genre for this Item or Album.
|
||||
"""
|
||||
return self._last_lookup(
|
||||
u'album', LASTFM.get_album, obj.albumartist, obj.album
|
||||
'album', LASTFM.get_album, obj.albumartist, obj.album
|
||||
)
|
||||
|
||||
def fetch_album_artist_genre(self, obj):
|
||||
"""Return the album artist genre for this Item or Album.
|
||||
"""
|
||||
return self._last_lookup(
|
||||
u'artist', LASTFM.get_artist, obj.albumartist
|
||||
'artist', LASTFM.get_artist, obj.albumartist
|
||||
)
|
||||
|
||||
def fetch_artist_genre(self, item):
|
||||
"""Returns the track artist genre for this Item.
|
||||
"""
|
||||
return self._last_lookup(
|
||||
u'artist', LASTFM.get_artist, item.artist
|
||||
'artist', LASTFM.get_artist, item.artist
|
||||
)
|
||||
|
||||
def fetch_track_genre(self, obj):
|
||||
"""Returns the track genre for this Item.
|
||||
"""
|
||||
return self._last_lookup(
|
||||
u'track', LASTFM.get_track, obj.artist, obj.title
|
||||
'track', LASTFM.get_track, obj.artist, obj.title
|
||||
)
|
||||
|
||||
def _get_genre(self, obj):
|
||||
|
@ -361,38 +373,56 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
return None, None
|
||||
|
||||
def commands(self):
|
||||
lastgenre_cmd = ui.Subcommand('lastgenre', help=u'fetch genres')
|
||||
lastgenre_cmd = ui.Subcommand('lastgenre', help='fetch genres')
|
||||
lastgenre_cmd.parser.add_option(
|
||||
u'-f', u'--force', dest='force',
|
||||
action='store_true', default=False,
|
||||
help=u're-download genre when already present'
|
||||
'-f', '--force', dest='force',
|
||||
action='store_true',
|
||||
help='re-download genre when already present'
|
||||
)
|
||||
lastgenre_cmd.parser.add_option(
|
||||
u'-s', u'--source', dest='source', type='string',
|
||||
help=u'genre source: artist, album, or track'
|
||||
'-s', '--source', dest='source', type='string',
|
||||
help='genre source: artist, album, or track'
|
||||
)
|
||||
lastgenre_cmd.parser.add_option(
|
||||
'-A', '--items', action='store_false', dest='album',
|
||||
help='match items instead of albums')
|
||||
lastgenre_cmd.parser.add_option(
|
||||
'-a', '--albums', action='store_true', dest='album',
|
||||
help='match albums instead of items')
|
||||
lastgenre_cmd.parser.set_defaults(album=True)
|
||||
|
||||
def lastgenre_func(lib, opts, args):
|
||||
write = ui.should_write()
|
||||
self.config.set_args(opts)
|
||||
|
||||
for album in lib.albums(ui.decargs(args)):
|
||||
album.genre, src = self._get_genre(album)
|
||||
self._log.info(u'genre for album {0} ({1}): {0.genre}',
|
||||
album, src)
|
||||
album.store()
|
||||
if opts.album:
|
||||
# Fetch genres for whole albums
|
||||
for album in lib.albums(ui.decargs(args)):
|
||||
album.genre, src = self._get_genre(album)
|
||||
self._log.info('genre for album {0} ({1}): {0.genre}',
|
||||
album, src)
|
||||
album.store()
|
||||
|
||||
for item in album.items():
|
||||
# If we're using track-level sources, also look up each
|
||||
# track on the album.
|
||||
if 'track' in self.sources:
|
||||
item.genre, src = self._get_genre(item)
|
||||
item.store()
|
||||
self._log.info(u'genre for track {0} ({1}): {0.genre}',
|
||||
item, src)
|
||||
for item in album.items():
|
||||
# If we're using track-level sources, also look up each
|
||||
# track on the album.
|
||||
if 'track' in self.sources:
|
||||
item.genre, src = self._get_genre(item)
|
||||
item.store()
|
||||
self._log.info(
|
||||
'genre for track {0} ({1}): {0.genre}',
|
||||
item, src)
|
||||
|
||||
if write:
|
||||
item.try_write()
|
||||
if write:
|
||||
item.try_write()
|
||||
else:
|
||||
# Just query singletons, i.e. items that are not part of
|
||||
# an album
|
||||
for item in lib.items(ui.decargs(args)):
|
||||
item.genre, src = self._get_genre(item)
|
||||
self._log.debug('added last.fm item genre ({0}): {1}',
|
||||
src, item.genre)
|
||||
item.store()
|
||||
|
||||
lastgenre_cmd.func = lastgenre_func
|
||||
return [lastgenre_cmd]
|
||||
|
@ -402,21 +432,21 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
if task.is_album:
|
||||
album = task.album
|
||||
album.genre, src = self._get_genre(album)
|
||||
self._log.debug(u'added last.fm album genre ({0}): {1}',
|
||||
self._log.debug('added last.fm album genre ({0}): {1}',
|
||||
src, album.genre)
|
||||
album.store()
|
||||
|
||||
if 'track' in self.sources:
|
||||
for item in album.items():
|
||||
item.genre, src = self._get_genre(item)
|
||||
self._log.debug(u'added last.fm item genre ({0}): {1}',
|
||||
self._log.debug('added last.fm item genre ({0}): {1}',
|
||||
src, item.genre)
|
||||
item.store()
|
||||
|
||||
else:
|
||||
item = task.item
|
||||
item.genre, src = self._get_genre(item)
|
||||
self._log.debug(u'added last.fm item genre ({0}): {1}',
|
||||
self._log.debug('added last.fm item genre ({0}): {1}',
|
||||
src, item.genre)
|
||||
item.store()
|
||||
|
||||
|
@ -438,12 +468,12 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
try:
|
||||
res = obj.get_top_tags()
|
||||
except PYLAST_EXCEPTIONS as exc:
|
||||
self._log.debug(u'last.fm error: {0}', exc)
|
||||
self._log.debug('last.fm error: {0}', exc)
|
||||
return []
|
||||
except Exception as exc:
|
||||
# Isolate bugs in pylast.
|
||||
self._log.debug(u'{}', traceback.format_exc())
|
||||
self._log.error(u'error in pylast library: {0}', exc)
|
||||
self._log.debug('{}', traceback.format_exc())
|
||||
self._log.error('error in pylast library: {0}', exc)
|
||||
return []
|
||||
|
||||
# Filter by weight (optionally).
|
||||
|
|
|
@ -648,35 +648,51 @@
|
|||
- glam rock
|
||||
- hard rock
|
||||
- heavy metal:
|
||||
- alternative metal
|
||||
- alternative metal:
|
||||
- funk metal
|
||||
- black metal:
|
||||
- viking metal
|
||||
- christian metal
|
||||
- death metal:
|
||||
- death/doom
|
||||
- goregrind
|
||||
- melodic death metal
|
||||
- technical death metal
|
||||
- doom metal
|
||||
- doom metal:
|
||||
- epic doom metal
|
||||
- funeral doom
|
||||
- drone metal
|
||||
- epic metal
|
||||
- folk metal:
|
||||
- celtic metal
|
||||
- medieval metal
|
||||
- pagan metal
|
||||
- funk metal
|
||||
- glam metal
|
||||
- gothic metal
|
||||
- industrial metal:
|
||||
- industrial death metal
|
||||
- metalcore:
|
||||
- deathcore
|
||||
- mathcore:
|
||||
- djent
|
||||
- power metal
|
||||
- synthcore
|
||||
- neoclassical metal
|
||||
- post-metal
|
||||
- power metal:
|
||||
- progressive power metal
|
||||
- progressive metal
|
||||
- sludge metal
|
||||
- speed metal
|
||||
- stoner rock
|
||||
- stoner rock:
|
||||
- stoner metal
|
||||
- symphonic metal
|
||||
- thrash metal:
|
||||
- crossover thrash
|
||||
- groove metal
|
||||
- progressive thrash metal
|
||||
- teutonic thrash metal
|
||||
- traditional heavy metal
|
||||
- math rock
|
||||
- new wave:
|
||||
- world fusion
|
||||
|
@ -719,6 +735,7 @@
|
|||
- street punk
|
||||
- thrashcore
|
||||
- horror punk
|
||||
- oi!
|
||||
- pop punk
|
||||
- psychobilly
|
||||
- riot grrrl
|
||||
|
|
|
@ -450,6 +450,8 @@ emo rap
|
|||
emocore
|
||||
emotronic
|
||||
enka
|
||||
epic doom metal
|
||||
epic metal
|
||||
eremwu eu
|
||||
ethereal pop
|
||||
ethereal wave
|
||||
|
@ -1024,6 +1026,7 @@ neo-medieval
|
|||
neo-prog
|
||||
neo-psychedelia
|
||||
neoclassical
|
||||
neoclassical metal
|
||||
neoclassical music
|
||||
neofolk
|
||||
neotraditional country
|
||||
|
@ -1176,8 +1179,10 @@ progressive folk
|
|||
progressive folk music
|
||||
progressive house
|
||||
progressive metal
|
||||
progressive power metal
|
||||
progressive rock
|
||||
progressive trance
|
||||
progressive thrash metal
|
||||
protopunk
|
||||
psych folk
|
||||
psychedelic music
|
||||
|
@ -1396,6 +1401,7 @@ symphonic metal
|
|||
symphonic poem
|
||||
symphonic rock
|
||||
symphony
|
||||
synthcore
|
||||
synthpop
|
||||
synthpunk
|
||||
t'ong guitar
|
||||
|
@ -1428,6 +1434,7 @@ tejano
|
|||
tejano music
|
||||
tekno
|
||||
tembang sunda
|
||||
teutonic thrash metal
|
||||
texas blues
|
||||
thai pop
|
||||
thillana
|
||||
|
@ -1444,6 +1451,7 @@ toeshey
|
|||
togaku
|
||||
trad jazz
|
||||
traditional bluegrass
|
||||
traditional heavy metal
|
||||
traditional pop music
|
||||
trallalero
|
||||
trance
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue