mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 09:02:15 -06:00
mtp/vidchk: support stuff like rag-prep
This commit is contained in:
parent
49470c05fa
commit
993213e2c0
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
import subprocess as sp
|
import subprocess as sp
|
||||||
|
|
||||||
|
@ -43,10 +44,14 @@ harmless = re.compile(
|
||||||
|
|
||||||
|
|
||||||
def wfilter(lines):
|
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:
|
if rc:
|
||||||
err = (so + se).decode("utf-8", "replace").split("\n", 1)
|
err = (so + se).decode("utf-8", "replace").split("\n", 1)
|
||||||
err = wfilter(err) or err
|
err = wfilter(err) or err
|
||||||
|
@ -67,6 +72,11 @@ def main():
|
||||||
zs = zb.decode("utf-8", "replace")
|
zs = zb.decode("utf-8", "replace")
|
||||||
md = json.loads(zs)
|
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:
|
try:
|
||||||
w, h = [int(x) for x in md["res"].split("x")]
|
w, h = [int(x) for x in md["res"].split("x")]
|
||||||
if not w + h:
|
if not w + h:
|
||||||
|
@ -90,7 +100,7 @@ def main():
|
||||||
with open(fsenc(f"{fp}.ff.json"), "wb") as f:
|
with open(fsenc(f"{fp}.ff.json"), "wb") as f:
|
||||||
f.write(so)
|
f.write(so)
|
||||||
|
|
||||||
err = errchk(so, se, p.returncode)
|
err = errchk(so, se, p.returncode, f"{fp}.vidchk")
|
||||||
if err:
|
if err:
|
||||||
return err
|
return err
|
||||||
|
|
||||||
|
@ -114,7 +124,7 @@ def main():
|
||||||
|
|
||||||
p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
p = sp.Popen(cmd, stdout=sp.PIPE, stderr=sp.PIPE)
|
||||||
so, se = p.communicate()
|
so, se = p.communicate()
|
||||||
return errchk(so, se, p.returncode)
|
return errchk(so, se, p.returncode, f"{fp}.vidchk")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
|
@ -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
|
md_only = [], // `${id} ${fn}` where ID was only found in metadata
|
||||||
mofs = 0,
|
mofs = 0,
|
||||||
mnchk = 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++) {
|
for (var a = 0; a < good_files.length; a++) {
|
||||||
var [fobj, name] = good_files[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) {
|
function process_id_list(txt) {
|
||||||
var wanted_ids = new Set(txt.trim().split('\n')),
|
var wanted_ids = new Set(txt.trim().split('\n')),
|
||||||
name_id = {},
|
name_id = {},
|
||||||
now = Date.now(),
|
|
||||||
wanted_names = new Set(), // basenames with a wanted ID
|
wanted_names = new Set(), // basenames with a wanted ID
|
||||||
wanted_files = new Set(); // filedrops
|
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)) {
|
if (wanted_names.has(name)) {
|
||||||
wanted_files.add(good_files[a]);
|
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();
|
good_files[a][1] = subdir + '/' + good_files[a][1].split(/\//g).pop();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue