Added command line options to query explicit for albums and / or tracks.
@@ -380,11 +380,20 @@ class LastGenrePlugin(plugins.BeetsPlugin):
u'-s', u'--source', dest='source', type='string',
help=u'genre source: artist, album, or track'
)
+ lastgenre_cmd.parser.add_option(
+ u'-A', u'--tracks', action='store_true', default=False,
+ help=u'match tracks instead of albums'
+ )
+ lastgenre_cmd.parser.add_option(
+ u'-a', u'--albums', action='store_true', default=True,
+ help=u'match albums instead of tracks'
+ )
def lastgenre_func(lib, opts, args):
write = ui.should_write()
self.config.set_args(opts)
+ if opts.albums:
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}',
@@ -403,11 +412,13 @@ class LastGenrePlugin(plugins.BeetsPlugin):
if write:
item.try_write()
+ if opts.tracks:
for item in lib.items(ui.decargs(args)):
item.genre, src = self._get_genre(item)
self._log.debug(u'added last.fm item genre ({0}): {1}', src,
item.genre)
item.store()
+
lastgenre_cmd.func = lastgenre_func
return [lastgenre_cmd]
