diff --git a/pyproject.toml b/pyproject.toml index a24c402..5047342 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "discogs-tag" -version = "0.1.2" +version = "0.1.3" description = "A rudimentary 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 60fa6cf..31a8483 100644 --- a/src/discogs_tag/cli.py +++ b/src/discogs_tag/cli.py @@ -15,9 +15,10 @@ def tag(release, dir = './', dry = False): with urllib.request.urlopen(request) as response: data = json.load(response) files = sorted(glob(os.path.join(dir, '*.flac')) + glob(os.path.join(dir, '*.mp3'))) - if (len(files) != len(data['tracklist'])): - raise Exception(f'Expecting {len(data["tracklist"])} files but found {len(files)}. Aborting.') - for n, track in enumerate(data['tracklist']): + tracks = list(filter(lambda t: t['type_'] == 'track', data['tracklist'])) + if (len(files) != len(tracks)): + raise Exception(f'Expecting {len(tracks)} files but found {len(files)}. Aborting.') + for n, track in enumerate(tracks): audio = mutagen.File(files[n], easy=True) audio['title'] = track['title'] audio['artist'] = ', '.join([artist_name(artist) for artist in track['artists']]) if 'artists' in track else ''