diff --git a/bin/mtag/vidchk.py b/bin/mtag/vidchk.py index f2f618c7..f1a22f4b 100755 --- a/bin/mtag/vidchk.py +++ b/bin/mtag/vidchk.py @@ -2,6 +2,7 @@ import json import re +import os import sys import subprocess as sp @@ -43,10 +44,14 @@ harmless = re.compile( def wfilter(lines): - return [x for x in lines if not harmless.search(x)] + return [x for x in lines if x.strip() and not harmless.search(x)] -def errchk(so, se, rc): +def errchk(so, se, rc, dbg): + if dbg: + with open(dbg, "wb") as f: + f.write(b"so:\n" + so + b"\nse:\n" + se + b"\n") + if rc: err = (so + se).decode("utf-8", "replace").split("\n", 1) err = wfilter(err) or err @@ -67,6 +72,11 @@ def main(): zs = zb.decode("utf-8", "replace") md = json.loads(zs) + fdir = os.path.dirname(os.path.realpath(fp)) + flag = os.path.join(fdir, ".processed") + if os.path.exists(flag): + return "already processed" + try: w, h = [int(x) for x in md["res"].split("x")] if not w + h: @@ -90,7 +100,7 @@ def main(): with open(fsenc(f"{fp}.ff.json"), "wb") as f: f.write(so) - err = errchk(so, se, p.returncode) + err = errchk(so, se, p.returncode, f"{fp}.vidchk") if err: return err @@ -114,7 +124,7 @@ def main(): p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE) so, se = p.communicate() - return errchk(so, se, p.returncode) + return errchk(so, se, p.returncode, f"{fp}.vidchk") if __name__ == "__main__": diff --git a/contrib/plugins/up2k-hook-ytid.js b/contrib/plugins/up2k-hook-ytid.js index 1e3e5dc4..d5abdc00 100644 --- a/contrib/plugins/up2k-hook-ytid.js +++ b/contrib/plugins/up2k-hook-ytid.js @@ -44,7 +44,11 @@ async function a_up2k_namefilter(good_files, nil_files, bad_files, hooks) { md_only = [], // `${id} ${fn}` where ID was only found in metadata mofs = 0, mnchk = 0, - mfile = ''; + mfile = '', + myid = localStorage.getItem('ytid_t0'); + + if (!myid) + localStorage.setItem('ytid_t0', myid = Date.now()); for (var a = 0; a < good_files.length; a++) { var [fobj, name] = good_files[a], @@ -177,7 +181,6 @@ async function a_up2k_namefilter(good_files, nil_files, bad_files, hooks) { function process_id_list(txt) { var wanted_ids = new Set(txt.trim().split('\n')), name_id = {}, - now = Date.now(), wanted_names = new Set(), // basenames with a wanted ID wanted_files = new Set(); // filedrops @@ -207,7 +210,7 @@ async function a_up2k_namefilter(good_files, nil_files, bad_files, hooks) { if (wanted_names.has(name)) { wanted_files.add(good_files[a]); - var subdir = `${name_id[name]}-${now}`; + var subdir = `${name_id[name]}-${myid}`; good_files[a][1] = subdir + '/' + good_files[a][1].split(/\//g).pop(); break; }