clean up code

This commit is contained in:
2022-05-10 22:26:57 +02:00
parent 1a7552c7c0
commit 9e51bfebac

View File

@@ -2,13 +2,10 @@
# ex: set filetype=python # ex: set filetype=python
import argparse import argparse
import mutagen.id3
import os import os
import soundfile as sf
import urllib.parse import urllib.parse
import xml.etree.cElementTree as xml import xml.etree.cElementTree as xml
from mutagen.easyid3 import EasyID3 from mutagen.easyid3 import EasyID3
from mutagen.id3 import ID3, TIT2, TIT3, TALB, TRCK, TYER
from mutagen.mp3 import MP3 from mutagen.mp3 import MP3
from shutil import copyfile from shutil import copyfile
@@ -58,7 +55,8 @@ def tag_file(track: Track, file_name: str, cnt, max):
Adds ID3 tags to a file. Adds ID3 tags to a file.
""" """
if not file_name.endswith('.mp3'): if not file_name.endswith('.mp3'):
print('Skipping file {0}. It\'s not an mp3 file. [{1}/{2}]'.format(file_name, cnt, max)) print('Skipping file {0}. It\'s not an mp3 file. [{1}/{2}]'
.format(file_name, cnt, max))
return return
print('Tagging file {0} [{1}/{2}]'.format(file_name, cnt, max)) print('Tagging file {0} [{1}/{2}]'.format(file_name, cnt, max))
@@ -97,11 +95,15 @@ def main():
Setup our main program Setup our main program
""" """
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('-t', '--target', type=str, help='The target path to store the scraped \ parser.add_argument('-t', '--target', type=str,
files into', default='~/itunesscrape') help='The target path to store the scraped \
parser.add_argument('-l', '--logfile', type=str, help='The path to the logfile to use.', files into',
default='~/itunesscrape')
parser.add_argument('-l', '--logfile', type=str,
help='The path to the logfile to use.',
default='~/itunesscrape.log') default='~/itunesscrape.log')
parser.add_argument('libraryFile', help='The iTunes library file in XML format.') parser.add_argument('libraryFile',
help='The iTunes library file in XML format.')
args = parser.parse_args() args = parser.parse_args()
print('Parsing library file...') print('Parsing library file...')
@@ -121,5 +123,6 @@ def main():
print('Done. Copied {0} of {1} files.'.format(count, maxcount)) print('Done. Copied {0} of {1} files.'.format(count, maxcount))
if __name__ == "__main__": if __name__ == "__main__":
main() main()