Wrap most of the download function in a try catch
This commit is contained in:
parent
c57009b77f
commit
7e9c25ef53
@ -75,6 +75,7 @@ class Library:
|
|||||||
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():
|
for song, songcontent in albumcontent.items():
|
||||||
|
try:
|
||||||
zeroes = int(math.log10(len(albumcontent)) + 1)
|
zeroes = int(math.log10(len(albumcontent)) + 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'
|
||||||
@ -111,6 +112,8 @@ class Library:
|
|||||||
resultfile.tag.title = song
|
resultfile.tag.title = song
|
||||||
resultfile.tag.track_num = songcontent['track']
|
resultfile.tag.track_num = songcontent['track']
|
||||||
resultfile.tag.save()
|
resultfile.tag.save()
|
||||||
|
except (KeyboardInterrupt, EOFError):
|
||||||
|
logging.debug('Interrupt received, exiting')
|
||||||
|
|
||||||
class BadWitch:
|
class BadWitch:
|
||||||
# Our program
|
# Our program
|
||||||
|
Reference in New Issue
Block a user