a lot of TODOs because there's a lot to do here
This commit is contained in:
parent
09d1e58c78
commit
5eaa942eab
1 changed files with 10 additions and 1 deletions
11
bcao.py
11
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!")
|
||||
|
|
Loading…
Reference in a new issue