From 5eaa942eabe16c86abfec67d21a95c3c86efb356 Mon Sep 17 00:00:00 2001 From: Lynnesbian Date: Fri, 16 Oct 2020 18:35:49 +1000 Subject: [PATCH] a lot of TODOs because there's a lot to do here --- bcao.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bcao.py b/bcao.py index 4a1604e..2e33b1b 100755 --- a/bcao.py +++ b/bcao.py @@ -5,6 +5,7 @@ # input: a .zip from bandcamp # output: it organises it, adds cover art, puts it in the right place... +# TODO: this is written like a hacky bash script and i hate it import subprocess, argparse, sys, os, re, base64 def log(message: str, importance: int = 0): @@ -22,14 +23,17 @@ try: from mutagen.flac import Picture from mutagen.aac import AAC except ImportError: + # TODO: requirements.txt die("Please install python3-mutagen (pip install mutagen)") try: + # TODO: see if there's a decent zip library for python subprocess.check_output(["unzip", "--help"]) except: die("Please install unzip (apt install unzip)") try: + # TODO: don't use which ffs subprocess.check_output(["which", "convert"]) subprocess.check_output(["which", "identify"]) except: @@ -48,7 +52,7 @@ if not os.path.exists(args.zip): log("Extracting...") zipname = os.path.splitext(os.path.basename(args.zip))[0] -tmp = "/tmp/bcao/{0}".format(zipname) +tmp = "/tmp/bcao/{0}".format(zipname) # TODO: use OS specific temp dirs subprocess.check_output(["rm", "-rf", tmp]) subprocess.check_output(['mkdir', '-p', tmp]) subprocess.check_output(["unzip", args.zip, "-d", tmp]) @@ -59,6 +63,7 @@ for root, dirs, filez in os.walk(tmp): for file in filez: # for every file files.append(root + os.sep + file) +# TODO: redo everything from here to the cover art resizing cover = "" artists = [] album = "" @@ -118,6 +123,7 @@ with open(cover, "rb") as cvr: imginfo = subprocess.check_output(["identify", "-ping", "-format", r"%w,%h,%m,%[bit-depth]", cover]).decode("utf-8").split(",") +# TODO: surely you don't have to do this?? does mutagen not have a higher level way of setting an image? picture = Picture() picture.data = data picture.type = 3 @@ -162,9 +168,12 @@ subprocess.check_output(["mkdir", "-p", mPath]) for root, dirs, filez in os.walk(tmp): for file in filez: # for every file + # TODO: i'm 99% sure python has a built in move command + # TODO: os.path.join subprocess.check_output(["mv", root + os.sep + file, mPath + os.sep + file]) log("Deleting {}...".format(tmp)) +# TODO: i'm 100% sure python has a built in remove command subprocess.check_output(["rm", "-rf", tmp]) log("Done!")