diff --git a/pyproject.toml b/pyproject.toml index e960bbd..02e3594 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] readme = "README.md" diff --git a/src/discogs_tag/cli.py b/src/discogs_tag/cli.py index ce19e12..3d85848 100644 --- a/src/discogs_tag/cli.py +++ b/src/discogs_tag/cli.py @@ -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) diff --git a/tests/test_discogs_tag.py b/tests/test_discogs_tag.py index 494d702..64ab51f 100644 --- a/tests/test_discogs_tag.py +++ b/tests/test_discogs_tag.py @@ -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