Account for metadata when adding zeroes, break to kill entire download operation
This commit is contained in:
parent
cf9722516f
commit
42d4edabb7
17
badwitch.py
17
badwitch.py
@ -90,11 +90,14 @@ class Library:
|
|||||||
destpath = (Path.home() / 'Music' / albumartist / album)
|
destpath = (Path.home() / 'Music' / albumartist / album)
|
||||||
Path(destpath).mkdir(parents=True, exist_ok=True)
|
Path(destpath).mkdir(parents=True, exist_ok=True)
|
||||||
# Actually download and tag songs
|
# Actually download and tag songs
|
||||||
for song, songcontent in albumcontent.items():
|
try:
|
||||||
if song == 'meta':
|
for song, songcontent in albumcontent.items():
|
||||||
continue
|
if song == 'meta':
|
||||||
try:
|
continue
|
||||||
zeroes = int(math.log10(len(albumcontent)) + 1)
|
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
|
filename = str(songcontent['track']).zfill(zeroes) + ' - ' + song
|
||||||
destfile = str(destpath / filename) + '.%(ext)s'
|
destfile = str(destpath / filename) + '.%(ext)s'
|
||||||
logging.debug('Saving to: ' + destfile)
|
logging.debug('Saving to: ' + destfile)
|
||||||
@ -140,8 +143,8 @@ class Library:
|
|||||||
resultfile.tag.composer = metadata['composer']
|
resultfile.tag.composer = metadata['composer']
|
||||||
# Save
|
# Save
|
||||||
resultfile.tag.save()
|
resultfile.tag.save()
|
||||||
except (KeyboardInterrupt, EOFError):
|
except (KeyboardInterrupt, EOFError):
|
||||||
logging.debug('Interrupt received, exiting')
|
logging.debug('Interrupt received, exiting')
|
||||||
|
|
||||||
class AlbumWidget(QFrame):
|
class AlbumWidget(QFrame):
|
||||||
def __init__(self, album, albumcontent):
|
def __init__(self, album, albumcontent):
|
||||||
|
Loading…
Reference in New Issue
Block a user