diff --git a/badwitch.py b/badwitch.py index 3ac4e81..c7f9ac6 100755 --- a/badwitch.py +++ b/badwitch.py @@ -90,11 +90,14 @@ class Library: destpath = (Path.home() / 'Music' / albumartist / album) Path(destpath).mkdir(parents=True, exist_ok=True) # Actually download and tag songs - for song, songcontent in albumcontent.items(): - if song == 'meta': - continue - try: - zeroes = int(math.log10(len(albumcontent)) + 1) + try: + for song, songcontent in albumcontent.items(): + if song == 'meta': + continue + if metadata == {}: + zeroes = int(math.log10(len(albumcontent)) + 1) + else: + zeroes = int(math.log10(len(albumcontent) - 1) + 1) filename = str(songcontent['track']).zfill(zeroes) + ' - ' + song destfile = str(destpath / filename) + '.%(ext)s' logging.debug('Saving to: ' + destfile) @@ -140,8 +143,8 @@ class Library: resultfile.tag.composer = metadata['composer'] # Save resultfile.tag.save() - except (KeyboardInterrupt, EOFError): - logging.debug('Interrupt received, exiting') + except (KeyboardInterrupt, EOFError): + logging.debug('Interrupt received, exiting') class AlbumWidget(QFrame): def __init__(self, album, albumcontent):