Skip to content

Commit

Permalink
- Improved doc and changelog
Browse files Browse the repository at this point in the history
- Cleaner implementation of mutual excursion of the command line
arguments.
  • Loading branch information
rain0r committed Apr 21, 2019
1 parent ddd7b4b commit b7d3ef6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
14 changes: 5 additions & 9 deletions beetsplug/lastgenre/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,22 +382,18 @@ def commands(self):
help=u'genre source: artist, album, or track'
)
lastgenre_cmd.parser.add_option(
u'-A', u'--items', action='store_true',
u'-A', u'--items', action='store_false', dest='album',
help=u'match items instead of albums')
lastgenre_cmd.parser.add_option(
u'-a', u'--albums', action='store_true',
u'-a', u'--albums', action='store_true', dest='album',
help=u'match albums instead of items')
lastgenre_cmd.parser.set_defaults(query_type='albums')
lastgenre_cmd.parser.set_defaults(album=True)

def lastgenre_func(lib, opts, args):
write = ui.should_write()
self.config.set_args(opts)

if opts.albums and opts.items:
self._log.error(u'options -a and -A are mutually exclusive')
return

if opts.albums:
if opts.album:
# Fetch genres for whole albums
for album in lib.albums(ui.decargs(args)):
album.genre, src = self._get_genre(album)
Expand All @@ -417,7 +413,7 @@ def lastgenre_func(lib, opts, args):

if write:
item.try_write()
elif opts.items:
else:
# Just query singletons, i.e. items that are not part of
# an album
for item in lib.items(ui.decargs(args)):
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Changelog

New features:

* LastGenre can now be used to fetch genres for singletons.
* :doc:`/plugins/lastgenre`: Added option ``-A`` to match individual tracks and singletons.
* The disambiguation string for identifying albums in the importer now shows
the catalog number.
Thanks to :user:`8h2a`.
Expand Down
3 changes: 3 additions & 0 deletions docs/plugins/lastgenre.rst
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,8 @@ In addition to running automatically on import, the plugin can also be run manua
from the command line. Use the command ``beet lastgenre [QUERY]`` to fetch
genres for albums or items matching a certain query.

By default, ``beet lastgenre`` matches albums. If you would like to match
individual tracks or singletons, use the ``-A`` switch: ``beet lastgenre -A [QUERY]``.

To disable automatic genre fetching on import, set the ``auto`` config option
to false.

0 comments on commit b7d3ef6

Please sign in to comment.