mirror of
https://github.com/beetbox/beets.git
synced 2026-01-17 05:34:23 +01:00
rename interactive_autotag to timid
This commit is contained in:
parent
2ca26d3d20
commit
704a76ba2c
3 changed files with 26 additions and 25 deletions
|
|
@ -441,7 +441,7 @@ def validate_candidate(items, tuple_dict, info):
|
|||
|
||||
tuple_dict[info['album_id']] = dist, ordered, info
|
||||
|
||||
def tag_album(items, config, search_artist=None, search_album=None):
|
||||
def tag_album(items, timid=False, search_artist=None, search_album=None):
|
||||
"""Bundles together the functionality used to infer tags for a
|
||||
set of items comprised by an album. Returns everything relevant:
|
||||
- The current artist.
|
||||
|
|
@ -469,12 +469,12 @@ def tag_album(items, config, search_artist=None, search_album=None):
|
|||
id_info = match_by_id(items)
|
||||
if id_info:
|
||||
validate_candidate(items, out_tuples, id_info)
|
||||
if out_tuples:
|
||||
if out_tuples and not timid:
|
||||
# If we have a very good MBID match, return immediately.
|
||||
# Otherwise, this match will compete against metadata-based
|
||||
# matches.
|
||||
rec = recommendation(out_tuples.values())
|
||||
if rec == RECOMMEND_STRONG and not config.interactive_autotag:
|
||||
if rec == RECOMMEND_STRONG:
|
||||
log.debug('ID match.')
|
||||
return cur_artist, cur_album, out_tuples.values(), rec
|
||||
|
||||
|
|
@ -515,7 +515,7 @@ def tag_album(items, config, search_artist=None, search_album=None):
|
|||
rec = recommendation(out_tuples)
|
||||
return cur_artist, cur_album, out_tuples, rec
|
||||
|
||||
def tag_item(item, search_artist=None, search_title=None):
|
||||
def tag_item(item, timid=False, search_artist=None, search_title=None):
|
||||
"""Attempts to find metadata for a single track. Returns a
|
||||
`(candidates, recommendation)` pair where `candidates` is a list
|
||||
of `(distance, track_info)` pairs. `search_artist` and
|
||||
|
|
@ -533,7 +533,7 @@ def tag_item(item, search_artist=None, search_title=None):
|
|||
candidates.append((dist, track_info))
|
||||
# If this is a good match, then don't keep searching.
|
||||
rec = recommendation(candidates)
|
||||
if rec == RECOMMEND_STRONG:
|
||||
if rec == RECOMMEND_STRONG and not timid:
|
||||
log.debug('Track ID match.')
|
||||
return candidates, rec
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class ImportConfig(object):
|
|||
_fields = ['lib', 'paths', 'resume', 'logfile', 'color', 'quiet',
|
||||
'quiet_fallback', 'copy', 'write', 'art', 'delete',
|
||||
'choose_match_func', 'should_resume_func', 'threaded',
|
||||
'autot', 'singletons', 'interactive_autotag', 'choose_item_func']
|
||||
'autot', 'singletons', 'timid', 'choose_item_func']
|
||||
def __init__(self, **kwargs):
|
||||
for slot in self._fields:
|
||||
setattr(self, slot, kwargs[slot])
|
||||
|
|
@ -330,7 +330,7 @@ def initial_lookup(config):
|
|||
|
||||
log.debug('Looking up: %s' % task.path)
|
||||
try:
|
||||
task.set_match(*autotag.tag_album(task.items, config))
|
||||
task.set_match(*autotag.tag_album(task.items, config.timid))
|
||||
except autotag.AutotagError:
|
||||
task.set_null_match()
|
||||
|
||||
|
|
@ -490,7 +490,7 @@ def item_lookup(config):
|
|||
task = None
|
||||
while True:
|
||||
task = yield task
|
||||
task.set_item_match(*autotag.tag_item(task.item))
|
||||
task.set_item_match(*autotag.tag_item(task.item, config.timid))
|
||||
|
||||
def item_query(config):
|
||||
"""A coroutine that queries the user for input on single-item
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ DEFAULT_IMPORT_COPY = True
|
|||
DEFAULT_IMPORT_WRITE = True
|
||||
DEFAULT_IMPORT_DELETE = False
|
||||
DEFAULT_IMPORT_AUTOT = True
|
||||
DEFAULT_IMPORT_INT_AUTOT = False
|
||||
DEFAULT_IMPORT_TIMID = False
|
||||
DEFAULT_IMPORT_ART = True
|
||||
DEFAULT_IMPORT_QUIET = False
|
||||
DEFAULT_IMPORT_QUIET_FALLBACK = 'skip'
|
||||
|
|
@ -163,7 +163,7 @@ def _quiet_fall_back(config):
|
|||
assert(False)
|
||||
return config.quiet_fallback
|
||||
|
||||
def choose_candidate(candidates, singleton, rec, color, interactive_autotag,
|
||||
def choose_candidate(candidates, singleton, rec, color, timid,
|
||||
cur_artist=None, cur_album=None, item=None):
|
||||
"""Given a sorted list of candidates, ask the user for a selection
|
||||
of which candidate to use. Applies to both full albums and
|
||||
|
|
@ -264,8 +264,8 @@ def choose_candidate(candidates, singleton, rec, color, interactive_autotag,
|
|||
else:
|
||||
show_change(cur_artist, cur_album, items, info, dist, color)
|
||||
|
||||
# Exact match => tag automatically if no interactive tagging is requested.
|
||||
if rec == autotag.RECOMMEND_STRONG and not interactive_autotag :
|
||||
# Exact match => tag automatically if we're not in timid mode.
|
||||
if rec == autotag.RECOMMEND_STRONG and not timid:
|
||||
if singleton:
|
||||
return info
|
||||
else:
|
||||
|
|
@ -331,8 +331,8 @@ def choose_match(task, config):
|
|||
while True:
|
||||
# Ask for a choice from the user.
|
||||
choice = choose_candidate(candidates, False, rec, config.color,
|
||||
config.interactive_autotag,
|
||||
task.cur_artist, task.cur_album)
|
||||
config.timid, task.cur_artist,
|
||||
task.cur_album)
|
||||
|
||||
# Choose which tags to use.
|
||||
if choice in (importer.action.SKIP, importer.action.ASIS,
|
||||
|
|
@ -344,8 +344,8 @@ def choose_match(task, config):
|
|||
search_artist, search_album = manual_search(False)
|
||||
try:
|
||||
_, _, candidates, rec = \
|
||||
autotag.tag_album(task.items, config,
|
||||
search_artist=search_artist, search_album=search_album)
|
||||
autotag.tag_album(task.items, config.timid, search_artist,
|
||||
search_album)
|
||||
except autotag.AutotagError:
|
||||
candidates, rec = None, None
|
||||
else:
|
||||
|
|
@ -374,7 +374,7 @@ def choose_item(task, config):
|
|||
while True:
|
||||
# Ask for a choice.
|
||||
choice = choose_candidate(candidates, True, rec, config.color,
|
||||
config.interactive_autotag, item=task.item)
|
||||
config.timid, item=task.item)
|
||||
|
||||
if choice in (importer.action.SKIP, importer.action.ASIS):
|
||||
return choice
|
||||
|
|
@ -394,7 +394,7 @@ def choose_item(task, config):
|
|||
|
||||
def import_files(lib, paths, copy, write, autot, logpath, art, threaded,
|
||||
color, delete, quiet, resume, quiet_fallback, singletons,
|
||||
interactive_autotag):
|
||||
timid):
|
||||
"""Import the files in the given list of paths, tagging each leaf
|
||||
directory as an album. If copy, then the files are copied into
|
||||
the library folder. If write, then new metadata is written to the
|
||||
|
|
@ -444,7 +444,7 @@ def import_files(lib, paths, copy, write, autot, logpath, art, threaded,
|
|||
choose_match_func = choose_match,
|
||||
should_resume_func = should_resume,
|
||||
singletons = singletons,
|
||||
interactive_autotag = interactive_autotag,
|
||||
timid = timid,
|
||||
choose_item_func = choose_item,
|
||||
)
|
||||
|
||||
|
|
@ -484,10 +484,8 @@ import_cmd.parser.add_option('-l', '--log', dest='logpath',
|
|||
help='file to log untaggable albums for later review')
|
||||
import_cmd.parser.add_option('-s', '--singletons', action='store_true',
|
||||
help='import individual tracks instead of full albums')
|
||||
import_cmd.parser.add_option('-i', '--interactive-autotag', dest='interactive_autotag',
|
||||
action='store_true', help='always ask user before tagging something - even if similarity is strong')
|
||||
import_cmd.parser.add_option('-I', '--nointeractive-autotag', dest='interactive_autotag',
|
||||
action='store_false', help='don\'t ask user before tagging something with high similarity (default)')
|
||||
import_cmd.parser.add_option('-t', '--timid', dest='timid',
|
||||
action='store_true', help='always confirm all actions')
|
||||
def import_func(lib, config, opts, args):
|
||||
copy = opts.copy if opts.copy is not None else \
|
||||
ui.config_val(config, 'beets', 'import_copy',
|
||||
|
|
@ -508,7 +506,9 @@ def import_func(lib, config, opts, args):
|
|||
quiet_fallback_str = ui.config_val(config, 'beets', 'import_quiet_fallback',
|
||||
DEFAULT_IMPORT_QUIET_FALLBACK)
|
||||
singletons = opts.singletons
|
||||
interactive_autotag = opts.interactive_autotag if opts.interactive_autotag is not None else DEFAULT_IMPORT_INT_AUTOT
|
||||
timid = opts.timid if opts.timid is not None else \
|
||||
ui.config_val(config, 'beets', 'import_timid',
|
||||
DEFAULT_IMPORT_TIMID, bool)
|
||||
|
||||
# Resume has three options: yes, no, and "ask" (None).
|
||||
resume = opts.resume if opts.resume is not None else \
|
||||
|
|
@ -526,7 +526,8 @@ def import_func(lib, config, opts, args):
|
|||
else:
|
||||
quiet_fallback = importer.action.SKIP
|
||||
import_files(lib, args, copy, write, autot, opts.logpath, art, threaded,
|
||||
color, delete, quiet, resume, quiet_fallback, singletons, interactive_autotag)
|
||||
color, delete, quiet, resume, quiet_fallback, singletons,
|
||||
timid)
|
||||
import_cmd.func = import_func
|
||||
default_commands.append(import_cmd)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue