This commit is contained in:
ed 2021-03-21 17:15:47 +01:00
parent 49e4fb7e12
commit 7f8d7d6006
6 changed files with 33 additions and 8 deletions

View file

@ -1,8 +1,8 @@
# coding: utf-8 # coding: utf-8
VERSION = (0, 9, 8) VERSION = (0, 9, 9)
CODENAME = "the strongest music server" CODENAME = "the strongest music server"
BUILD_DT = (2021, 3, 15) BUILD_DT = (2021, 3, 21)
S_VERSION = ".".join(map(str, VERSION)) S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)

View file

@ -350,7 +350,7 @@ class AuthSrv(object):
a = a.split("=")[0] a = a.split("=")[0]
local_mtp[a] = True local_mtp[a] = True
local = True local = True
for b in self.args.mtp: for b in self.args.mtp or []:
b = b.split("=")[0] b = b.split("=")[0]
if a == b: if a == b:
local = False local = False
@ -376,7 +376,7 @@ class AuthSrv(object):
self.log(m.format(vol.vpath, mtp), 1) self.log(m.format(vol.vpath, mtp), 1)
errors = True errors = True
for mtp in self.args.mtp: for mtp in self.args.mtp or []:
mtp = mtp.split("=")[0] mtp = mtp.split("=")[0]
if mtp not in all_mte: if mtp not in all_mte:
m = 'metadata tag "{}" is defined by "-mtm" or "-mtp", but is not used by "-mte" (or by any "cmte" volume-flag)' m = 'metadata tag "{}" is defined by "-mtm" or "-mtp", but is not used by "-mte" (or by any "cmte" volume-flag)'

View file

@ -140,7 +140,7 @@ class U2idx(object):
q += " where " + (" and ".join(where)) q += " where " + (" and ".join(where))
self.log("q2: {} {}".format(q, repr(v))) # self.log("q2: {} {}".format(q, repr(v)))
ret = [] ret = []
lim = 1000 lim = 1000
@ -182,6 +182,12 @@ class U2idx(object):
done_flag.append(True) done_flag.append(True)
self.active_id = None self.active_id = None
# undupe hits from multiple metadata keys
if len(ret) > 1:
ret = [ret[0]] + [
y for x, y in zip(ret[:-1], ret[1:]) if x["rp"] != y["rp"]
]
return ret, list(taglist.keys()) return ret, list(taglist.keys())
def terminator(self, identifier, done_flag): def terminator(self, identifier, done_flag):

View file

@ -29,6 +29,7 @@ from .util import (
s3enc, s3enc,
s3dec, s3dec,
statdir, statdir,
s2hms,
) )
from .mtag import MTag from .mtag import MTag
from .authsrv import AuthSrv from .authsrv import AuthSrv
@ -499,12 +500,17 @@ class Up2k(object):
return ret return ret
def _run_all_mtp(self): def _run_all_mtp(self):
t0 = time.time()
self.mtp_force = {} self.mtp_force = {}
self.mtp_parsers = {} self.mtp_parsers = {}
for ptop, flags in self.flags.items(): for ptop, flags in self.flags.items():
if "mtp" in flags: if "mtp" in flags:
self._run_one_mtp(ptop) self._run_one_mtp(ptop)
td = time.time() - t0
msg = "mtp finished in {:.2f} sec ({})"
self.log(msg.format(td, s2hms(td, True)))
def _run_one_mtp(self, ptop): def _run_one_mtp(self, ptop):
db_path = os.path.join(ptop, ".hist", "up2k.db") db_path = os.path.join(ptop, ".hist", "up2k.db")
sz0 = os.path.getsize(db_path) // 1024 sz0 = os.path.getsize(db_path) // 1024
@ -651,9 +657,6 @@ class Up2k(object):
wcur.close() wcur.close()
cur.close() cur.close()
if n_done:
self.log("mtp finished")
def _start_mpool(self): def _start_mpool(self):
if WINDOWS and False: if WINDOWS and False:
nah = open(os.devnull, "wb") nah = open(os.devnull, "wb")

View file

@ -550,6 +550,16 @@ def get_spd(nbyte, t0, t=None):
return "{} \033[0m{}/s\033[0m".format(s1, s2) return "{} \033[0m{}/s\033[0m".format(s1, s2)
def s2hms(s, optional_h=False):
s = int(s)
h, s = divmod(s, 3600)
m, s = divmod(s, 60)
if not h and optional_h:
return "{}:{:02}".format(m, s)
return "{}:{:02}:{:02}".format(h, m, s)
def undot(path): def undot(path):
ret = [] ret = []
for node in path.split("/"): for node in path.split("/"):

View file

@ -67,6 +67,12 @@ wget -S --header='Accept-Encoding: gzip' -U 'MSIE 6.0; SV1' http://127.0.0.1:392
shab64() { sp=$1; f="$2"; v=0; sz=$(stat -c%s "$f"); while true; do w=$((v+sp*1024*1024)); printf $(tail -c +$((v+1)) "$f" | head -c $((w-v)) | sha512sum | cut -c-64 | sed -r 's/ .*//;s/(..)/\\x\1/g') | base64 -w0 | cut -c-43 | tr '+/' '-_'; v=$w; [ $v -lt $sz ] || break; done; } shab64() { sp=$1; f="$2"; v=0; sz=$(stat -c%s "$f"); while true; do w=$((v+sp*1024*1024)); printf $(tail -c +$((v+1)) "$f" | head -c $((w-v)) | sha512sum | cut -c-64 | sed -r 's/ .*//;s/(..)/\\x\1/g') | base64 -w0 | cut -c-43 | tr '+/' '-_'; v=$w; [ $v -lt $sz ] || break; done; }
##
## poll url for performance issues
command -v gdate && date() { gdate "$@"; }; while true; do t=$(date +%s.%N); (time wget http://127.0.0.1:3923/?ls -qO- | jq -C '.files[]|{sz:.sz,ta:.tags.artist,tb:.tags.".bpm"}|del(.[]|select(.==null))' | awk -F\" '/"/{t[$2]++} END {for (k in t){v=t[k];p=sprintf("%" (v+1) "s",v);gsub(/ /,"#",p);printf "\033[36m%s\033[33m%s ",k,p}}') 2>&1 | awk -v ts=$t 'NR==1{t1=$0} NR==2{sub(/.*0m/,"");sub(/s$/,"");t2=$0;c=2; if(t2>0.3){c=3} if(t2>0.8){c=1} } END{sub(/[0-9]{6}$/,"",ts);printf "%s \033[3%dm%s %s\033[0m\n",ts,c,t2,t1}'; sleep 0.1 || break; done
## ##
## sqlite3 stuff ## sqlite3 stuff