Skip to content

Commit

Permalink
Support Discogs URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Jul 13, 2024
1 parent f6b47d4 commit d914dbc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "discogs-tag"
version = "1.0.0"
version = "1.0.1"
description = "An audio tagger based on Discogs metadata."
authors = ["infojunkie <[email protected]>"]
readme = "README.md"
Expand Down
3 changes: 3 additions & 0 deletions src/discogs_tag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def get_release(release):
headers = {
'User-Agent': f'{__NAME__} {__VERSION__}'
}
match = re.match(r"https://www\.discogs\.com/release/(\d*)", release)
if match:
release = f'https://api.discogs.com/releases/{match.group(1)}'
try:
request = urllib.request.Request(release, headers=headers)
return urllib.request.urlopen(request)
Expand Down
1 change: 1 addition & 0 deletions tests/test_discogs_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,3 +240,4 @@ def test_get_release():
assert json.load(get_release('file:tests/16215626.json'))['id'] == 16215626
assert json.load(get_release('16215626'))['id'] == 16215626
assert json.load(get_release('https://api.discogs.com/releases/16215626'))['id'] == 16215626
assert json.load(get_release('https://www.discogs.com/release/16215626-Pink-Floyd-Wish-You-Were-Here'))['id'] == 16215626

0 comments on commit d914dbc

Please sign in to comment.