mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 11:02:43 +01:00
Merge pull request #88 from pdf/lastgenre_source_selection
Allow selection of source for genre information (ie - artist vs album)
This commit is contained in:
commit
a21e3ca344
2 changed files with 26 additions and 3 deletions
|
|
@ -167,9 +167,13 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
# The "write to files" option corresponds to the
|
||||
# import_write config value.
|
||||
write = config['import']['write'].get(bool)
|
||||
source = self.config['source'].get()
|
||||
for album in lib.albums(ui.decargs(args)):
|
||||
tags = []
|
||||
lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
|
||||
if source is 'artist':
|
||||
lastfm_obj = LASTFM.get_artist(album.albumartist)
|
||||
else:
|
||||
lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
|
||||
if album.genre:
|
||||
tags.append(album.genre)
|
||||
|
||||
|
|
@ -191,15 +195,22 @@ class LastGenrePlugin(plugins.BeetsPlugin):
|
|||
return [lastgenre_cmd]
|
||||
|
||||
def imported(self, session, task):
|
||||
source = self.config['source'].get()
|
||||
tags = []
|
||||
if task.is_album:
|
||||
album = session.lib.get_album(task.album_id)
|
||||
lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
|
||||
if source is 'artist':
|
||||
lastfm_obj = LASTFM.get_artist(album.albumartist)
|
||||
else:
|
||||
lastfm_obj = LASTFM.get_album(album.albumartist, album.album)
|
||||
if album.genre:
|
||||
tags.append(album.genre)
|
||||
else:
|
||||
item = task.item
|
||||
lastfm_obj = LASTFM.get_track(item.artist, item.title)
|
||||
if source is 'artist':
|
||||
lastfm_obj = LASTFM.get_artist(item.artist)
|
||||
else:
|
||||
lastfm_obj = LASTFM.get_track(item.artist, item.title)
|
||||
if item.genre:
|
||||
tags.append(item.genre)
|
||||
|
||||
|
|
|
|||
|
|
@ -64,6 +64,18 @@ to use your own tree.
|
|||
.. _YAML: http://www.yaml.org/
|
||||
.. _pyyaml: http://pyyaml.org/
|
||||
|
||||
Genre Source
|
||||
------------
|
||||
|
||||
When looking up genres for albums, you may specify whether you want to retrieve
|
||||
the genre from the album, or from the artist by setting the ``source``
|
||||
configuration value::
|
||||
|
||||
lastgenre:
|
||||
source: artist
|
||||
|
||||
Currently the only available option is 'artist', any other value for ``source``
|
||||
will default to retrieving genres from the album.
|
||||
|
||||
Running Manually
|
||||
----------------
|
||||
|
|
|
|||
Loading…
Reference in a new issue