From c48fa0a8309982017dc3069d43cbee55876c4a4b Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Wed, 11 Jan 2023 11:37:53 +0100 Subject: [PATCH] Fix Discogs ID extractor to support short format - Often discogs release links used to be written as discogs.com/release/ - Extend one of the existing regex patterns to support that by making the trailing dash (-) optional. - Save a new test regex on regex101.com and update the link to it. --- beets/util/id_extractors.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/beets/util/id_extractors.py b/beets/util/id_extractors.py index 08f30c2b2..b1020e78c 100644 --- a/beets/util/id_extractors.py +++ b/beets/util/id_extractors.py @@ -47,14 +47,15 @@ def extract_discogs_id_regex(album_id): # - plain integer, optionally wrapped in brackets and prefixed by an # 'r', as this is how discogs displays the release ID on its webpage. # - legacy url format: discogs.com//release/ + # - legacy url short format: discogs.com/release/ # - current url format: discogs.com/release/- # See #291, #4080 and #4085 for the discussions leading up to these # patterns. - # Regex has been tested here https://regex101.com/r/wyLdB4/2 + # Regex has been tested here https://regex101.com/r/TOu7kw/1 for pattern in [ r'^\[?r?(?P\d+)\]?$', - r'discogs\.com/release/(?P\d+)-', + r'discogs\.com/release/(?P\d+)-?', r'discogs\.com/[^/]+/release/(?P\d+)', ]: match = re.search(pattern, album_id)