mirror of
https://github.com/beetbox/beets.git
synced 2026-02-05 15:03:21 +01:00
All suitable plugins use CommonOptionsParser features
This commit is contained in:
parent
38ca99498d
commit
650305c9a1
9 changed files with 19 additions and 53 deletions
|
|
@ -139,8 +139,6 @@ class ConvertPlugin(BeetsPlugin):
|
|||
cmd = ui.Subcommand('convert', help='convert to external location')
|
||||
cmd.parser.add_option('-p', '--pretend', action='store_true',
|
||||
help='show actions but do nothing')
|
||||
cmd.parser.add_option('-a', '--album', action='store_true',
|
||||
help='choose albums instead of tracks')
|
||||
cmd.parser.add_option('-t', '--threads', action='store', type='int',
|
||||
help='change the number of threads, \
|
||||
defaults to maximum available processors')
|
||||
|
|
@ -149,10 +147,10 @@ class ConvertPlugin(BeetsPlugin):
|
|||
and move the old files')
|
||||
cmd.parser.add_option('-d', '--dest', action='store',
|
||||
help='set the destination directory')
|
||||
cmd.parser.add_option('-f', '--format', action='store', dest='format',
|
||||
help='set the destination directory')
|
||||
cmd.parser.add_option('-y', '--yes', action='store_true', dest='yes',
|
||||
help='do not ask for confirmation')
|
||||
cmd.parser.add_album_option()
|
||||
cmd.parser.add_format_option(target='item')
|
||||
cmd.func = self.convert_func
|
||||
return [cmd]
|
||||
|
||||
|
|
|
|||
|
|
@ -125,17 +125,6 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
self._command = Subcommand('duplicates',
|
||||
help=__doc__,
|
||||
aliases=['dup'])
|
||||
|
||||
self._command.parser.add_option('-f', '--format', dest='format',
|
||||
action='store', type='string',
|
||||
help='print with custom format',
|
||||
metavar='FMT', default='')
|
||||
|
||||
self._command.parser.add_option('-a', '--album', dest='album',
|
||||
action='store_true',
|
||||
help='show duplicate albums instead of'
|
||||
' tracks')
|
||||
|
||||
self._command.parser.add_option('-c', '--count', dest='count',
|
||||
action='store_true',
|
||||
help='show duplicate counts')
|
||||
|
|
@ -168,15 +157,11 @@ class DuplicatesPlugin(BeetsPlugin):
|
|||
action='store', metavar='DEST',
|
||||
help='copy items to dest')
|
||||
|
||||
self._command.parser.add_option('-p', '--path', dest='path',
|
||||
action='store_true',
|
||||
help='print paths for matched items or'
|
||||
' albums')
|
||||
|
||||
self._command.parser.add_option('-t', '--tag', dest='tag',
|
||||
action='store',
|
||||
help='tag matched items with \'k=v\''
|
||||
' attribute')
|
||||
self._command.parser.add_all_common_options()
|
||||
|
||||
def commands(self):
|
||||
|
||||
|
|
|
|||
|
|
@ -486,10 +486,7 @@ class EchonestMetadataPlugin(plugins.BeetsPlugin):
|
|||
'-t', '--threshold', dest='threshold', action='store',
|
||||
type='float', default=0.15, help='Set difference threshold'
|
||||
)
|
||||
sim_cmd.parser.add_option(
|
||||
'-f', '--format', action='store', default='${difference}: ${path}',
|
||||
help='print with custom format'
|
||||
)
|
||||
sim_cmd.parser.add_format_option()
|
||||
|
||||
def sim_func(lib, opts, args):
|
||||
self.config.set_args(opts)
|
||||
|
|
|
|||
|
|
@ -52,8 +52,7 @@ class MBSyncPlugin(BeetsPlugin):
|
|||
cmd.parser.add_option('-W', '--nowrite', action='store_false',
|
||||
default=config['import']['write'], dest='write',
|
||||
help="don't write updated metadata to files")
|
||||
cmd.parser.add_option('-f', '--format', action='store', default='',
|
||||
help='print with custom format')
|
||||
cmd.parser.add_format_option()
|
||||
cmd.func = self.func
|
||||
return [cmd]
|
||||
|
||||
|
|
@ -64,17 +63,16 @@ class MBSyncPlugin(BeetsPlugin):
|
|||
pretend = opts.pretend
|
||||
write = opts.write
|
||||
query = ui.decargs(args)
|
||||
fmt = opts.format
|
||||
|
||||
self.singletons(lib, query, move, pretend, write, fmt)
|
||||
self.albums(lib, query, move, pretend, write, fmt)
|
||||
self.singletons(lib, query, move, pretend, write)
|
||||
self.albums(lib, query, move, pretend, write)
|
||||
|
||||
def singletons(self, lib, query, move, pretend, write, fmt):
|
||||
def singletons(self, lib, query, move, pretend, write):
|
||||
"""Retrieve and apply info from the autotagger for items matched by
|
||||
query.
|
||||
"""
|
||||
for item in lib.items(query + ['singleton:true']):
|
||||
item_formatted = format(item, fmt)
|
||||
item_formatted = format(item)
|
||||
if not item.mb_trackid:
|
||||
self._log.info(u'Skipping singleton with no mb_trackid: {0}',
|
||||
item_formatted)
|
||||
|
|
@ -93,13 +91,13 @@ class MBSyncPlugin(BeetsPlugin):
|
|||
autotag.apply_item_metadata(item, track_info)
|
||||
apply_item_changes(lib, item, move, pretend, write)
|
||||
|
||||
def albums(self, lib, query, move, pretend, write, fmt):
|
||||
def albums(self, lib, query, move, pretend, write):
|
||||
"""Retrieve and apply info from the autotagger for albums matched by
|
||||
query and their items.
|
||||
"""
|
||||
# Process matching albums.
|
||||
for a in lib.albums(query):
|
||||
album_formatted = format(a, fmt)
|
||||
album_formatted = format(a)
|
||||
if not a.mb_albumid:
|
||||
self._log.info(u'Skipping album with no mb_albumid: {0}',
|
||||
album_formatted)
|
||||
|
|
|
|||
|
|
@ -94,19 +94,13 @@ class MissingPlugin(BeetsPlugin):
|
|||
self._command = Subcommand('missing',
|
||||
help=__doc__,
|
||||
aliases=['miss'])
|
||||
|
||||
self._command.parser.add_option('-f', '--format', dest='format',
|
||||
action='store', type='string',
|
||||
help='print with custom FORMAT',
|
||||
metavar='FORMAT', default='')
|
||||
|
||||
self._command.parser.add_option('-c', '--count', dest='count',
|
||||
action='store_true',
|
||||
help='count missing tracks per album')
|
||||
|
||||
self._command.parser.add_option('-t', '--total', dest='total',
|
||||
action='store_true',
|
||||
help='count total of missing tracks')
|
||||
self._command.add_format_option()
|
||||
|
||||
def commands(self):
|
||||
def _miss(lib, opts, args):
|
||||
|
|
|
|||
|
|
@ -42,11 +42,7 @@ class PlayPlugin(BeetsPlugin):
|
|||
'play',
|
||||
help='send music to a player as a playlist'
|
||||
)
|
||||
play_command.parser.add_option(
|
||||
'-a', '--album',
|
||||
action='store_true', default=False,
|
||||
help='query and load albums rather than tracks'
|
||||
)
|
||||
play_command.parser.add_album_option()
|
||||
play_command.func = self.play_music
|
||||
return [play_command]
|
||||
|
||||
|
|
|
|||
|
|
@ -67,16 +67,11 @@ def random_item(lib, opts, args):
|
|||
|
||||
random_cmd = Subcommand('random',
|
||||
help='chose a random track or album')
|
||||
random_cmd.parser.add_option('-a', '--album', action='store_true',
|
||||
help='choose an album instead of track')
|
||||
random_cmd.parser.add_option('-p', '--path', action='store_true',
|
||||
help='print the path of the matched item')
|
||||
random_cmd.parser.add_option('-f', '--format', action='store',
|
||||
help='print with custom format', default='')
|
||||
random_cmd.parser.add_option('-n', '--number', action='store', type="int",
|
||||
help='number of objects to choose', default=1)
|
||||
random_cmd.parser.add_option('-e', '--equal-chance', action='store_true',
|
||||
help='each artist has the same chance')
|
||||
random_cmd.parser.add_all_common_options()
|
||||
random_cmd.func = random_item
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -760,7 +760,6 @@ class ReplayGainPlugin(BeetsPlugin):
|
|||
self.handle_track(item, write)
|
||||
|
||||
cmd = ui.Subcommand('replaygain', help='analyze for ReplayGain')
|
||||
cmd.parser.add_option('-a', '--album', action='store_true',
|
||||
help='analyze albums instead of tracks')
|
||||
cmd.parser.add_album_option()
|
||||
cmd.func = func
|
||||
return [cmd]
|
||||
|
|
|
|||
|
|
@ -99,6 +99,10 @@ class MbsyncCliTest(unittest.TestCase, TestHelper):
|
|||
e = "mbsync: Skipping album with no mb_albumid: 'album info'"
|
||||
self.assertEqual(e, logs[0])
|
||||
|
||||
# restore the config
|
||||
config['format_item'] = '$artist - $album - $title'
|
||||
config['format_album'] = '$albumartist - $album'
|
||||
|
||||
# Test singleton with no mb_trackid.
|
||||
# The default singleton format includes $artist and $album
|
||||
# so we need to stub them here
|
||||
|
|
|
|||
Loading…
Reference in a new issue