From 45dc99f1a9dd9ff8cf65bcd04135832ccd97a7ac Mon Sep 17 00:00:00 2001 From: Tai Lee Date: Mon, 3 Jun 2013 00:25:31 +1000 Subject: [PATCH] Group preferred media patterns, in case they contain "|" to keep them separate from the number of media. --- beets/autotag/match.py | 2 +- docs/reference/config.rst | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/beets/autotag/match.py b/beets/autotag/match.py index 2f226cef4..a44784c07 100644 --- a/beets/autotag/match.py +++ b/beets/autotag/match.py @@ -415,7 +415,7 @@ def distance(items, album_info, mapping): dist.add_string('media', likelies['media'], album_info.media) # Preferred media. - preferred_media = [re.compile(r'(\d+x)?%s' % pattern, re.I) for pattern + preferred_media = [re.compile(r'(\d+x)?(%s)' % pattern, re.I) for pattern in config['match']['preferred']['media'].get()] if album_info.media and preferred_media: dist.add_priority('media', album_info.media, preferred_media) diff --git a/docs/reference/config.rst b/docs/reference/config.rst index ec194afde..c9f36c5e1 100644 --- a/docs/reference/config.rst +++ b/docs/reference/config.rst @@ -437,9 +437,13 @@ preferred In addition to comparing the tagged metadata with the match metadata for similarity, you can also specify an ordered list of preferred countries and -media types. A distance penalty will be applied if the country or media type -from the match metadata doesn't match. The order is important, the first item -will be most preferred. +media types. + +A distance penalty will be applied if the country or media type from the match +metadata doesn't match. The order is important, the first item will be most +preferred. Each item may be a regular expression, and will be matched case +insensitively. The number of media will be stripped when matching preferred +media (e.g. "2x" in "2xCD"). You can also tell the autotagger to prefer matches that have a release year closest to the original year for an album. @@ -448,8 +452,8 @@ Here's an example:: match: preferred: - countries: ['US', 'GB', 'UK'] - media: ['CD', 'Digital Media'] + countries: ['US', 'GB|UK'] + media: ['CD', 'Digital Media|File'] original_year: yes By default, none of these options are enabled.