Skip to content

Commit

Permalink
v0.9.9
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Mar 21, 2021
1 parent 49e4fb7 commit 7f8d7d6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions copyparty/__version__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# coding: utf-8

VERSION = (0, 9, 8)
VERSION = (0, 9, 9)
CODENAME = "the strongest music server"
BUILD_DT = (2021, 3, 15)
BUILD_DT = (2021, 3, 21)

S_VERSION = ".".join(map(str, VERSION))
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
Expand Down
4 changes: 2 additions & 2 deletions copyparty/authsrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ def reload(self):
a = a.split("=")[0]
local_mtp[a] = True
local = True
for b in self.args.mtp:
for b in self.args.mtp or []:
b = b.split("=")[0]
if a == b:
local = False
Expand All @@ -376,7 +376,7 @@ def reload(self):
self.log(m.format(vol.vpath, mtp), 1)
errors = True

for mtp in self.args.mtp:
for mtp in self.args.mtp or []:
mtp = mtp.split("=")[0]
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)'
Expand Down
8 changes: 7 additions & 1 deletion copyparty/u2idx.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def run_query(self, vols, uq, uv, targs):

q += " where " + (" and ".join(where))

self.log("q2: {} {}".format(q, repr(v)))
# self.log("q2: {} {}".format(q, repr(v)))

ret = []
lim = 1000
Expand Down Expand Up @@ -182,6 +182,12 @@ def run_query(self, vols, uq, uv, targs):
done_flag.append(True)
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())

def terminator(self, identifier, done_flag):
Expand Down
9 changes: 6 additions & 3 deletions copyparty/up2k.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
s3enc,
s3dec,
statdir,
s2hms,
)
from .mtag import MTag
from .authsrv import AuthSrv
Expand Down Expand Up @@ -499,12 +500,17 @@ def _flush_mpool(self, wcur):
return ret

def _run_all_mtp(self):
t0 = time.time()
self.mtp_force = {}
self.mtp_parsers = {}
for ptop, flags in self.flags.items():
if "mtp" in flags:
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):
db_path = os.path.join(ptop, ".hist", "up2k.db")
sz0 = os.path.getsize(db_path) // 1024
Expand Down Expand Up @@ -651,9 +657,6 @@ def _run_one_mtp(self, ptop):
wcur.close()
cur.close()

if n_done:
self.log("mtp finished")

def _start_mpool(self):
if WINDOWS and False:
nah = open(os.devnull, "wb")
Expand Down
10 changes: 10 additions & 0 deletions copyparty/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,16 @@ def get_spd(nbyte, t0, t=None):
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):
ret = []
for node in path.split("/"):
Expand Down
6 changes: 6 additions & 0 deletions docs/notes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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; }


##
## 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

Expand Down

0 comments on commit 7f8d7d6

Please sign in to comment.