clean up code
This commit is contained in:
19
scraper.py
19
scraper.py
@@ -2,13 +2,10 @@
|
||||
# ex: set filetype=python
|
||||
|
||||
import argparse
|
||||
import mutagen.id3
|
||||
import os
|
||||
import soundfile as sf
|
||||
import urllib.parse
|
||||
import xml.etree.cElementTree as xml
|
||||
from mutagen.easyid3 import EasyID3
|
||||
from mutagen.id3 import ID3, TIT2, TIT3, TALB, TRCK, TYER
|
||||
from mutagen.mp3 import MP3
|
||||
from shutil import copyfile
|
||||
|
||||
@@ -58,7 +55,8 @@ def tag_file(track: Track, file_name: str, cnt, max):
|
||||
Adds ID3 tags to a file.
|
||||
"""
|
||||
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
|
||||
|
||||
print('Tagging file {0} [{1}/{2}]'.format(file_name, cnt, max))
|
||||
@@ -97,11 +95,15 @@ def main():
|
||||
Setup our main program
|
||||
"""
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument('-t', '--target', type=str, help='The target path to store the scraped \
|
||||
files into', default='~/itunesscrape')
|
||||
parser.add_argument('-l', '--logfile', type=str, help='The path to the logfile to use.',
|
||||
parser.add_argument('-t', '--target', type=str,
|
||||
help='The target path to store the scraped \
|
||||
files into',
|
||||
default='~/itunesscrape')
|
||||
parser.add_argument('-l', '--logfile', type=str,
|
||||
help='The path to the logfile to use.',
|
||||
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()
|
||||
|
||||
print('Parsing library file...')
|
||||
@@ -121,5 +123,6 @@ def main():
|
||||
|
||||
print('Done. Copied {0} of {1} files.'.format(count, maxcount))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user