From b609047d6463cac69345d50d693be945ba87b27e Mon Sep 17 00:00:00 2001 From: J0J0 T Date: Wed, 2 Mar 2022 16:29:07 +0100 Subject: [PATCH] discogs: Add extract_release_id_regex sanity check Check whether any input worth pattern checking was passed. --- beetsplug/discogs.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/beetsplug/discogs.py b/beetsplug/discogs.py index 820a0acbd..30aa6d28d 100644 --- a/beetsplug/discogs.py +++ b/beetsplug/discogs.py @@ -194,16 +194,17 @@ class DiscogsPlugin(BeetsPlugin): # patterns. # Regex has been tested here https://regex101.com/r/wyLdB4/2 - for pattern in [ - r'^\[?r?(?P\d+)\]?$', - r'discogs\.com/release/(?P\d+)-', - r'discogs\.com/[^/]+/release/(?P\d+)', - ]: - match = re.search(pattern, album_id) - if match: - return int(match.group('id')) - - return None + if album_id: + for pattern in [ + r'^\[?r?(?P\d+)\]?$', + r'discogs\.com/release/(?P\d+)-', + r'discogs\.com/[^/]+/release/(?P\d+)', + ]: + match = re.search(pattern, album_id) + if match: + return int(match.group('id')) + else: + return None def album_for_id(self, album_id): """Fetches an album by its Discogs ID and returns an AlbumInfo object