Skip to content

Commit

Permalink
Ignore non-track entries
Browse files Browse the repository at this point in the history
  • Loading branch information
infojunkie committed Oct 13, 2023
1 parent b44e271 commit 48cbd79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
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 = "0.1.2"
version = "0.1.3"
description = "A rudimentary audio tagger based on Discogs metadata."
authors = ["infojunkie <[email protected]>"]
readme = "README.md"
Expand Down
7 changes: 4 additions & 3 deletions src/discogs_tag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ''
Expand Down

0 comments on commit 48cbd79

Please sign in to comment.