+overwrite option
This commit is contained in:
parent
696011bcbd
commit
0b8827c1b8
12
musick.py
12
musick.py
@ -16,6 +16,7 @@ errors = []
|
||||
input_dir = None
|
||||
output_dir = None
|
||||
cover_dir = None
|
||||
overwrite_cover = False
|
||||
cover_arts = []
|
||||
|
||||
UNKNOWN_ARTIST_NAME = "Unknown Artist"
|
||||
@ -138,14 +139,14 @@ def process_file(f: str, odir: str):
|
||||
mobj.set_album(album)
|
||||
mobj.set_title(title)
|
||||
|
||||
if (mobj.get_cover() == None):
|
||||
if (mobj.get_cover() == None or overwrite_cover):
|
||||
cover_idx = find_best_cover(artist, album, title)
|
||||
if (cover_idx >= 0):
|
||||
mobj.set_cover(cover_arts[cover_idx][3])
|
||||
print(f" Cover: \"{cover_arts[cover_idx][5]}\"")
|
||||
print(f" Cover: <{'None' if mobj.get_cover() == None else 'Exists'}> -> \"{cover_arts[cover_idx][5]}\"")
|
||||
total_cover_written += 1
|
||||
else:
|
||||
print(" Cover: <Missing>")
|
||||
print(f" Cover: <Missing>")
|
||||
cover_missing.append(f)
|
||||
else:
|
||||
print(" Cover: <Exists>")
|
||||
@ -183,9 +184,10 @@ def main():
|
||||
global input_dir
|
||||
global output_dir
|
||||
global cover_dir
|
||||
global overwrite_cover
|
||||
|
||||
try:
|
||||
opts , _ = getopt.getopt(sys.argv[1:], "hi:o:c:")
|
||||
opts , _ = getopt.getopt(sys.argv[1:], "hi:o:c:f")
|
||||
except getopt.GetoptError as err:
|
||||
print(str(err))
|
||||
usage()
|
||||
@ -201,6 +203,8 @@ def main():
|
||||
output_dir = a
|
||||
elif o == "-c":
|
||||
cover_dir = a
|
||||
elif o == "-f":
|
||||
overwrite_cover = True
|
||||
else:
|
||||
print("Unrecognized option: " + o)
|
||||
sys.exit(1)
|
||||
|
Loading…
Reference in New Issue
Block a user