Skip to content

Commit

Permalink
Fix Discogs ID extractor to support short format
Browse files Browse the repository at this point in the history
- Often discogs release links used to be written as discogs.com/release/<id>
- 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.
  • Loading branch information
JOJ0 committed Jan 11, 2023
1 parent 3fad32a commit 5d85ab1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions beets/util/id_extractors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<name of release>/release/<id>
# - legacy url short format: discogs.com/release/<id>
# - current url format: discogs.com/release/<id>-<name of 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<id>\d+)\]?$',
r'discogs\.com/release/(?P<id>\d+)-',
r'discogs\.com/release/(?P<id>\d+)-?',
r'discogs\.com/[^/]+/release/(?P<id>\d+)',
]:
match = re.search(pattern, album_id)
Expand Down

0 comments on commit 5d85ab1

Please sign in to comment.