reformat code

This commit is contained in:
2022-05-07 19:54:56 +02:00
parent a0ed245b3a
commit 3d181b1842

View File

@@ -33,6 +33,7 @@ def parseXml(xml_file):
tracks.append(Track(t)) tracks.append(Track(t))
return tracks return tracks
def copy_file(track: Track, targetFolder) -> str: def copy_file(track: Track, targetFolder) -> str:
""" """
Copies a track from its source to the destination folder Copies a track from its source to the destination folder
@@ -43,10 +44,11 @@ def copy_file(track: Track, targetFolder) -> str:
print('Copying file {0}', path) print('Copying file {0}', path)
copyfile(path, dst) copyfile(path, dst)
else: else:
print('File {0} not found.') print('File {0} not found.', path)
return None return None
return dst return dst
def tag_file(track: Track, file_name: str): def tag_file(track: Track, file_name: str):
""" """
Adds ID3 tags to a file. Adds ID3 tags to a file.
@@ -57,21 +59,32 @@ def tag_file(track: Track, file_name: str):
print('Tagging file {0}'.format(file_name)) print('Tagging file {0}'.format(file_name))
mp3file = MP3(file_name, ID3=EasyID3) mp3file = MP3(file_name, ID3=EasyID3)
if hasattr(track,'Album'): mp3file['album'] = track.Album if hasattr(track, 'Album'):
if hasattr(track,'BPM'): mp3file['bpm'] = track.BPM mp3file['album'] = track.Album
if hasattr(track,'Compilation'): mp3file['compilation'] = 'true' if hasattr(track, 'BPM'):
if hasattr(track,'Composer'): mp3file['composer'] = track.Composer mp3file['bpm'] = track.BPM
if hasattr(track,'TotalTime'): mp3file['length'] = track.TotalTime if hasattr(track, 'Compilation'):
if hasattr(track,'Name'): mp3file['title'] = track.Name mp3file['compilation'] = 'true'
if hasattr(track,'Artist'): mp3file['artist'] = track.Artist if hasattr(track, 'Composer'):
if hasattr(track,'AlbumArtist'): mp3file['albumartist'] = track.AlbumArtist mp3file['composer'] = track.Composer
if hasattr(track,'DiscNumber'): mp3file['discnumber'] = track.DiscNumber if hasattr(track, 'TotalTime'):
mp3file['length'] = track.TotalTime
if hasattr(track, 'Name'):
mp3file['title'] = track.Name
if hasattr(track, 'Artist'):
mp3file['artist'] = track.Artist
if hasattr(track, 'AlbumArtist'):
mp3file['albumartist'] = track.AlbumArtist
if hasattr(track, 'DiscNumber'):
mp3file['discnumber'] = track.DiscNumber
if hasattr(track, 'TrackNumber'): if hasattr(track, 'TrackNumber'):
if hasattr(track, 'TrackCount'): if hasattr(track, 'TrackCount'):
mp3file['tracknumber'] = '{0}/{1}'.format(track.TrackNumber, track.TrackCount) mp3file['tracknumber'] = '{0}/{1}'.format(track.TrackNumber,
track.TrackCount)
else: else:
mp3file['tracknumber'] = track.TrackNumber mp3file['tracknumber'] = track.TrackNumber
if hasattr(track,'Genre'): mp3file['genre'] = track.Genre if hasattr(track, 'Genre'):
mp3file['genre'] = track.Genre
mp3file.save() mp3file.save()