From 0b8827c1b89bb2daed19916c025b6c10079cc4f7 Mon Sep 17 00:00:00 2001 From: quackerd Date: Mon, 5 Jun 2023 18:55:55 -0400 Subject: [PATCH] +overwrite option --- musick.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/musick.py b/musick.py index d981cbc..b607621 100644 --- a/musick.py +++ b/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: ") + print(f" Cover: ") cover_missing.append(f) else: print(" Cover: ") @@ -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)