mirror of
https://github.com/9001/copyparty.git
synced 2025-11-03 13:33:13 +00:00
Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7650c9326 | ||
|
|
d94c6d4e72 | ||
|
|
3cc8760733 | ||
|
|
a2f6973495 | ||
|
|
f8648fa651 | ||
|
|
177aa038df | ||
|
|
e0a14ec881 | ||
|
|
9366512f2f | ||
|
|
ea38b8041a | ||
|
|
f1870daf0d | ||
|
|
9722441aad | ||
|
|
9d014087f4 | ||
|
|
83b4038b85 | ||
|
|
1e0a448feb |
@@ -60,7 +60,7 @@ def main():
|
||||
try:
|
||||
det(tf)
|
||||
except:
|
||||
pass
|
||||
pass # mute
|
||||
finally:
|
||||
os.unlink(tf)
|
||||
|
||||
|
||||
123
bin/mtag/audio-key-slicing.py
Executable file
123
bin/mtag/audio-key-slicing.py
Executable file
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import subprocess as sp
|
||||
|
||||
import keyfinder
|
||||
|
||||
from copyparty.util import fsenc
|
||||
|
||||
"""
|
||||
dep: github/mixxxdj/libkeyfinder
|
||||
dep: pypi/keyfinder
|
||||
dep: ffmpeg
|
||||
|
||||
note: this is a janky edition of the regular audio-key.py,
|
||||
slicing the files at 20sec intervals and keeping 5sec from each,
|
||||
surprisingly accurate but still garbage (446 ok, 69 bad, 13% miss)
|
||||
|
||||
it is fast tho
|
||||
"""
|
||||
|
||||
|
||||
def get_duration():
|
||||
# TODO provide ffprobe tags to mtp as json
|
||||
|
||||
# fmt: off
|
||||
dur = sp.check_output([
|
||||
"ffprobe",
|
||||
"-hide_banner",
|
||||
"-v", "fatal",
|
||||
"-show_streams",
|
||||
"-show_format",
|
||||
fsenc(sys.argv[1])
|
||||
])
|
||||
# fmt: on
|
||||
|
||||
dur = dur.decode("ascii", "replace").split("\n")
|
||||
dur = [x.split("=")[1] for x in dur if x.startswith("duration=")]
|
||||
dur = [float(x) for x in dur if re.match(r"^[0-9\.,]+$", x)]
|
||||
return list(sorted(dur))[-1] if dur else None
|
||||
|
||||
|
||||
def get_segs(dur):
|
||||
# keep first 5s of each 20s,
|
||||
# keep entire last segment
|
||||
ofs = 0
|
||||
segs = []
|
||||
while True:
|
||||
seg = [ofs, 5]
|
||||
segs.append(seg)
|
||||
if dur - ofs < 20:
|
||||
seg[-1] = int(dur - seg[0])
|
||||
break
|
||||
|
||||
ofs += 20
|
||||
|
||||
return segs
|
||||
|
||||
|
||||
def slice(tf):
|
||||
dur = get_duration()
|
||||
dur = min(dur, 600) # max 10min
|
||||
segs = get_segs(dur)
|
||||
|
||||
# fmt: off
|
||||
cmd = [
|
||||
"ffmpeg",
|
||||
"-nostdin",
|
||||
"-hide_banner",
|
||||
"-v", "fatal",
|
||||
"-y"
|
||||
]
|
||||
|
||||
for seg in segs:
|
||||
cmd.extend([
|
||||
"-ss", str(seg[0]),
|
||||
"-i", fsenc(sys.argv[1])
|
||||
])
|
||||
|
||||
filt = ""
|
||||
for n, seg in enumerate(segs):
|
||||
filt += "[{}:a:0]atrim=duration={}[a{}]; ".format(n, seg[1], n)
|
||||
|
||||
prev = "a0"
|
||||
for n in range(1, len(segs)):
|
||||
nxt = "b{}".format(n)
|
||||
filt += "[{}][a{}]acrossfade=d=0.5[{}]; ".format(prev, n, nxt)
|
||||
prev = nxt
|
||||
|
||||
cmd.extend([
|
||||
"-filter_complex", filt[:-2],
|
||||
"-map", "[{}]".format(nxt),
|
||||
"-sample_fmt", "s16",
|
||||
tf
|
||||
])
|
||||
# fmt: on
|
||||
|
||||
# print(cmd)
|
||||
sp.check_call(cmd)
|
||||
|
||||
|
||||
def det(tf):
|
||||
slice(tf)
|
||||
print(keyfinder.key(tf).camelot())
|
||||
|
||||
|
||||
def main():
|
||||
with tempfile.NamedTemporaryFile(suffix=".flac", delete=False) as f:
|
||||
f.write(b"h")
|
||||
tf = f.name
|
||||
|
||||
try:
|
||||
det(tf)
|
||||
finally:
|
||||
os.unlink(tf)
|
||||
pass
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,18 +1,54 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import subprocess as sp
|
||||
import keyfinder
|
||||
|
||||
from copyparty.util import fsenc
|
||||
|
||||
"""
|
||||
dep: github/mixxxdj/libkeyfinder
|
||||
dep: pypi/keyfinder
|
||||
dep: ffmpeg
|
||||
|
||||
note: cannot fsenc
|
||||
"""
|
||||
|
||||
|
||||
try:
|
||||
print(keyfinder.key(sys.argv[1]).camelot())
|
||||
except:
|
||||
pass
|
||||
# tried trimming the first/last 5th, bad idea,
|
||||
# misdetects 9a law field (Sphere Caliber) as 10b,
|
||||
# obvious when mixing 9a ghostly parapara ship
|
||||
|
||||
|
||||
def det(tf):
|
||||
# fmt: off
|
||||
sp.check_call([
|
||||
"ffmpeg",
|
||||
"-nostdin",
|
||||
"-hide_banner",
|
||||
"-v", "fatal",
|
||||
"-y", "-i", fsenc(sys.argv[1]),
|
||||
"-t", "300",
|
||||
"-sample_fmt", "s16",
|
||||
tf
|
||||
])
|
||||
# fmt: on
|
||||
|
||||
print(keyfinder.key(tf).camelot())
|
||||
|
||||
|
||||
def main():
|
||||
with tempfile.NamedTemporaryFile(suffix=".flac", delete=False) as f:
|
||||
f.write(b"h")
|
||||
tf = f.name
|
||||
|
||||
try:
|
||||
det(tf)
|
||||
except:
|
||||
pass # mute
|
||||
finally:
|
||||
os.unlink(tf)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# coding: utf-8
|
||||
|
||||
VERSION = (0, 11, 24)
|
||||
VERSION = (0, 11, 25)
|
||||
CODENAME = "the grid"
|
||||
BUILD_DT = (2021, 6, 22)
|
||||
BUILD_DT = (2021, 6, 25)
|
||||
|
||||
S_VERSION = ".".join(map(str, VERSION))
|
||||
S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT)
|
||||
|
||||
@@ -693,6 +693,9 @@ class AuthSrv(object):
|
||||
self.user = user
|
||||
self.iuser = {v: k for k, v in user.items()}
|
||||
|
||||
pwds = [re.escape(x) for x in self.iuser.keys()]
|
||||
self.re_pwd = re.compile("=(" + "|".join(pwds) + ")([]&; ]|$)")
|
||||
|
||||
# import pprint
|
||||
# pprint.pprint({"usr": user, "rd": mread, "wr": mwrite, "mnt": mount})
|
||||
|
||||
|
||||
@@ -54,8 +54,16 @@ class HttpCli(object):
|
||||
self.out_headers = {"Access-Control-Allow-Origin": "*"}
|
||||
|
||||
def log(self, msg, c=0):
|
||||
ptn = self.asrv.re_pwd
|
||||
if ptn.search(msg):
|
||||
msg = ptn.sub(self.unpwd, msg)
|
||||
|
||||
self.log_func(self.log_src, msg, c)
|
||||
|
||||
def unpwd(self, m):
|
||||
a, b = m.groups()
|
||||
return "=\033[7m {} \033[27m{}".format(self.asrv.iuser[a], b)
|
||||
|
||||
def _check_nonfatal(self, ex):
|
||||
return ex.code < 400 or ex.code in [404, 429]
|
||||
|
||||
@@ -630,7 +638,7 @@ class HttpCli(object):
|
||||
penalty = 0.7
|
||||
t_idle = t0 - idx.p_end
|
||||
if idx.p_dur > 0.7 and t_idle < penalty:
|
||||
m = "rate-limit ({:.1f} sec), cost {:.2f}, idle {:.2f}"
|
||||
m = "rate-limit {:.1f} sec, cost {:.2f}, idle {:.2f}"
|
||||
raise Pebkac(429, m.format(penalty, idx.p_dur, t_idle))
|
||||
|
||||
if "srch" in body:
|
||||
|
||||
@@ -1030,7 +1030,13 @@ def guess_mime(url, fallback="application/octet-stream"):
|
||||
except:
|
||||
return fallback
|
||||
|
||||
return MIMES.get(ext) or mimetypes.guess_type(url)[0] or fallback
|
||||
ret = MIMES.get(ext) or mimetypes.guess_type(url)[0] or fallback
|
||||
|
||||
if ";" not in ret:
|
||||
if ret.startswith("text/") or ret.endswith("/javascript"):
|
||||
ret += "; charset=UTF-8"
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
def runcmd(*argv):
|
||||
|
||||
@@ -243,7 +243,7 @@ var mpl = (function () {
|
||||
"pb_mode": sread('pb_mode') || 'loop-folder',
|
||||
"preload": bcfg_get('au_preload', true),
|
||||
"clip": bcfg_get('au_npclip', false),
|
||||
"os_ctl": bcfg_get('au_os_ctl', false) && have_mctl,
|
||||
"os_ctl": bcfg_get('au_os_ctl', true) && have_mctl,
|
||||
"osd_cv": bcfg_get('au_osd_cv', true),
|
||||
};
|
||||
|
||||
@@ -290,6 +290,13 @@ var mpl = (function () {
|
||||
draw_pb_mode();
|
||||
}
|
||||
|
||||
r.pp = function () {
|
||||
if (!r.os_ctl)
|
||||
return;
|
||||
|
||||
navigator.mediaSession.playbackState = mp.au && !mp.au.paused ? "playing" : "paused";
|
||||
};
|
||||
|
||||
r.announce = function () {
|
||||
if (!r.os_ctl)
|
||||
return;
|
||||
@@ -330,13 +337,21 @@ var mpl = (function () {
|
||||
}
|
||||
|
||||
navigator.mediaSession.metadata = new MediaMetadata(tags);
|
||||
navigator.mediaSession.playbackState = mp.au.paused ? "paused" : "playing";
|
||||
navigator.mediaSession.setActionHandler('play', playpause);
|
||||
navigator.mediaSession.setActionHandler('pause', playpause);
|
||||
navigator.mediaSession.setActionHandler('seekbackward', function () { seek_au_rel(-10); });
|
||||
navigator.mediaSession.setActionHandler('seekforward', function () { seek_au_rel(10); });
|
||||
navigator.mediaSession.setActionHandler('previoustrack', prev_song);
|
||||
navigator.mediaSession.setActionHandler('nexttrack', next_song);
|
||||
r.pp();
|
||||
};
|
||||
|
||||
r.stop = function () {
|
||||
if (!r.os_ctl || !navigator.mediaSession.metadata)
|
||||
return;
|
||||
|
||||
navigator.mediaSession.metadata = null;
|
||||
navigator.mediaSession.playbackState = "paused";
|
||||
};
|
||||
|
||||
return r;
|
||||
@@ -345,14 +360,15 @@ var mpl = (function () {
|
||||
|
||||
// extract songs + add play column
|
||||
function MPlayer() {
|
||||
this.id = Date.now();
|
||||
this.au = null;
|
||||
this.au_native = null;
|
||||
this.au_native2 = null;
|
||||
this.au_ogvjs = null;
|
||||
this.au_ogvjs2 = null;
|
||||
this.tracks = {};
|
||||
this.order = [];
|
||||
var r = this;
|
||||
r.id = Date.now();
|
||||
r.au = null;
|
||||
r.au_native = null;
|
||||
r.au_native2 = null;
|
||||
r.au_ogvjs = null;
|
||||
r.au_ogvjs2 = null;
|
||||
r.tracks = {};
|
||||
r.order = [];
|
||||
|
||||
var re_audio = /\.(opus|ogg|m4a|aac|mp3|wav|flac)$/i,
|
||||
trs = QSA('#files tbody tr');
|
||||
@@ -367,32 +383,33 @@ function MPlayer() {
|
||||
|
||||
if (m) {
|
||||
var tid = link.getAttribute('id');
|
||||
this.order.push(tid);
|
||||
this.tracks[tid] = url;
|
||||
r.order.push(tid);
|
||||
r.tracks[tid] = url;
|
||||
tds[0].innerHTML = '<a id="a' + tid + '" href="#a' + tid + '" class="play">play</a></td>';
|
||||
ebi('a' + tid).onclick = ev_play;
|
||||
}
|
||||
}
|
||||
|
||||
this.vol = sread('vol');
|
||||
if (this.vol !== null)
|
||||
this.vol = parseFloat(this.vol);
|
||||
r.vol = sread('vol');
|
||||
if (r.vol !== null)
|
||||
r.vol = parseFloat(r.vol);
|
||||
else
|
||||
this.vol = 0.5;
|
||||
r.vol = 0.5;
|
||||
|
||||
this.expvol = function () {
|
||||
return 0.5 * this.vol + 0.5 * this.vol * this.vol;
|
||||
r.expvol = function (v) {
|
||||
return 0.5 * v + 0.5 * v * v;
|
||||
};
|
||||
|
||||
this.setvol = function (vol) {
|
||||
this.vol = Math.max(Math.min(vol, 1), 0);
|
||||
r.setvol = function (vol) {
|
||||
r.vol = Math.max(Math.min(vol, 1), 0);
|
||||
swrite('vol', vol);
|
||||
r.stopfade(true);
|
||||
|
||||
if (this.au)
|
||||
this.au.volume = this.expvol();
|
||||
if (r.au)
|
||||
r.au.volume = r.expvol(r.vol);
|
||||
};
|
||||
|
||||
this.read_order = function () {
|
||||
r.read_order = function () {
|
||||
var order = [],
|
||||
links = QSA('#files>tbody>tr>td:nth-child(1)>a');
|
||||
|
||||
@@ -403,24 +420,71 @@ function MPlayer() {
|
||||
|
||||
order.push(tid.slice(1));
|
||||
}
|
||||
this.order = order;
|
||||
r.order = order;
|
||||
};
|
||||
|
||||
this.preload = function (url) {
|
||||
r.fdir = 0;
|
||||
r.fvol = -1;
|
||||
r.ftid = -1;
|
||||
r.ftimer = null;
|
||||
r.fade_in = function () {
|
||||
r.fvol = 0;
|
||||
r.fdir = 0.025;
|
||||
if (r.au) {
|
||||
r.ftid = r.au.tid;
|
||||
r.au.play();
|
||||
mpl.pp();
|
||||
fader();
|
||||
}
|
||||
};
|
||||
r.fade_out = function () {
|
||||
r.fvol = r.vol;
|
||||
r.fdir = -0.05;
|
||||
r.ftid = r.au.tid;
|
||||
fader();
|
||||
};
|
||||
r.stopfade = function (hard) {
|
||||
clearTimeout(r.ftimer);
|
||||
if (hard)
|
||||
r.ftid = -1;
|
||||
}
|
||||
function fader() {
|
||||
r.stopfade();
|
||||
if (!r.au || r.au.tid !== r.ftid)
|
||||
return;
|
||||
|
||||
var done = true;
|
||||
r.fvol += r.fdir;
|
||||
if (r.fvol < 0) {
|
||||
r.fvol = 0;
|
||||
r.au.pause();
|
||||
mpl.pp();
|
||||
}
|
||||
else if (r.fvol > r.vol)
|
||||
r.fvol = r.vol;
|
||||
else
|
||||
done = false;
|
||||
|
||||
r.au.volume = r.expvol(r.fvol);
|
||||
if (!done)
|
||||
setTimeout(fader, 10);
|
||||
}
|
||||
|
||||
r.preload = function (url) {
|
||||
var au = null;
|
||||
if (need_ogv_for(url)) {
|
||||
au = mp.au_ogvjs2;
|
||||
if (!au && window['OGVPlayer']) {
|
||||
au = new OGVPlayer();
|
||||
au.preload = "auto";
|
||||
this.au_ogvjs2 = au;
|
||||
r.au_ogvjs2 = au;
|
||||
}
|
||||
} else {
|
||||
au = mp.au_native2;
|
||||
if (!au) {
|
||||
au = new Audio();
|
||||
au.preload = "auto";
|
||||
this.au_native2 = au;
|
||||
r.au_native2 = au;
|
||||
}
|
||||
}
|
||||
if (au) {
|
||||
@@ -573,12 +637,15 @@ var pbar = (function () {
|
||||
}
|
||||
|
||||
r.drawbuf = function () {
|
||||
var bc = r.buf,
|
||||
bctx = bc.ctx;
|
||||
|
||||
bctx.clearRect(0, 0, bc.w, bc.h);
|
||||
|
||||
if (!mp.au)
|
||||
return;
|
||||
|
||||
var bc = r.buf,
|
||||
bctx = bc.ctx,
|
||||
sm = bc.w * 1.0 / mp.au.duration,
|
||||
var sm = bc.w * 1.0 / mp.au.duration,
|
||||
gk = bc.h + '' + light;
|
||||
|
||||
if (gradh != gk) {
|
||||
@@ -586,7 +653,6 @@ var pbar = (function () {
|
||||
grad = glossy_grad(bc, 85, [35, 40, 37, 35], light ? [45, 56, 50, 45] : [42, 51, 47, 42]);
|
||||
}
|
||||
bctx.fillStyle = grad;
|
||||
bctx.clearRect(0, 0, bc.w, bc.h);
|
||||
for (var a = 0; a < mp.au.buffered.length; a++) {
|
||||
var x1 = sm * mp.au.buffered.start(a),
|
||||
x2 = sm * mp.au.buffered.end(a);
|
||||
@@ -596,15 +662,17 @@ var pbar = (function () {
|
||||
};
|
||||
|
||||
r.drawpos = function () {
|
||||
var bc = r.buf,
|
||||
pc = r.pos,
|
||||
pctx = pc.ctx;
|
||||
|
||||
pctx.clearRect(0, 0, pc.w, pc.h);
|
||||
|
||||
if (!mp.au || isNaN(mp.au.duration) || isNaN(mp.au.currentTime))
|
||||
return; // not-init || unsupp-codec
|
||||
|
||||
var bc = r.buf,
|
||||
pc = r.pos,
|
||||
pctx = pc.ctx,
|
||||
sm = bc.w * 1.0 / mp.au.duration;
|
||||
var sm = bc.w * 1.0 / mp.au.duration;
|
||||
|
||||
pctx.clearRect(0, 0, pc.w, pc.h);
|
||||
pctx.fillStyle = light ? 'rgba(0,64,0,0.15)' : 'rgba(204,255,128,0.15)';
|
||||
for (var p = 1, mins = mp.au.duration / 10; p <= mins; p++)
|
||||
pctx.fillRect(Math.floor(sm * p * 10), 0, 2, pc.h);
|
||||
@@ -735,9 +803,8 @@ function seek_au_sec(seek) {
|
||||
|
||||
mp.au.currentTime = seek;
|
||||
|
||||
// ogv.js breaks on .play() during playback
|
||||
if (mp.au === mp.au_native)
|
||||
mp.au.play();
|
||||
if (mp.au.paused)
|
||||
mp.fade_in();
|
||||
|
||||
mpui.progress_updater();
|
||||
}
|
||||
@@ -759,25 +826,29 @@ function next_song(e) {
|
||||
}
|
||||
function prev_song(e) {
|
||||
ev(e);
|
||||
|
||||
if (mp.au && !mp.au.paused && mp.au.currentTime > 3)
|
||||
return seek_au_sec(0);
|
||||
|
||||
return song_skip(-1);
|
||||
}
|
||||
|
||||
|
||||
function playpause(e) {
|
||||
// must be event-chain
|
||||
ev(e);
|
||||
if (mp.au) {
|
||||
if (mp.au.paused)
|
||||
mp.au.play();
|
||||
mp.fade_in();
|
||||
else
|
||||
mp.au.pause();
|
||||
mp.fade_out();
|
||||
|
||||
mpui.progress_updater();
|
||||
}
|
||||
else
|
||||
play(0);
|
||||
play(0, true);
|
||||
|
||||
if (navigator.mediaSession)
|
||||
navigator.mediaSession.playbackState = mp.au.paused ? "paused" : "playing";
|
||||
mpl.pp();
|
||||
};
|
||||
|
||||
|
||||
@@ -788,7 +859,8 @@ function playpause(e) {
|
||||
ebi('bnext').onclick = next_song;
|
||||
ebi('barpos').onclick = function (e) {
|
||||
if (!mp.au) {
|
||||
return play(0);
|
||||
play(0, true);
|
||||
return mp.fade_in();
|
||||
}
|
||||
|
||||
var rect = pbar.buf.can.getBoundingClientRect(),
|
||||
@@ -863,7 +935,12 @@ var mpui = (function () {
|
||||
// event from play button next to a file in the list
|
||||
function ev_play(e) {
|
||||
ev(e);
|
||||
play(this.getAttribute('id').slice(1));
|
||||
|
||||
var fade = !mp.au || mp.au.paused;
|
||||
play(this.getAttribute('id').slice(1), true);
|
||||
if (fade)
|
||||
mp.fade_in();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1102,10 +1179,12 @@ var audio_eq = (function () {
|
||||
|
||||
|
||||
// plays the tid'th audio file on the page
|
||||
function play(tid, seek, call_depth) {
|
||||
function play(tid, is_ev, seek, call_depth) {
|
||||
if (mp.order.length == 0)
|
||||
return console.log('no audio found wait what');
|
||||
|
||||
mp.stopfade(true);
|
||||
|
||||
var tn = tid;
|
||||
if ((tn + '').indexOf('f-') === 0)
|
||||
tn = mp.order.indexOf(tn);
|
||||
@@ -1147,7 +1226,7 @@ function play(tid, seek, call_depth) {
|
||||
}
|
||||
else if (window['OGVPlayer']) {
|
||||
mp.au = mp.au_ogvjs = new OGVPlayer();
|
||||
attempt_play = false;
|
||||
attempt_play = is_ev;
|
||||
mp.au.addEventListener('error', evau_error, true);
|
||||
mp.au.addEventListener('progress', pbar.drawpos);
|
||||
mp.au.addEventListener('ended', next_song);
|
||||
@@ -1160,7 +1239,7 @@ function play(tid, seek, call_depth) {
|
||||
show_modal('<h1>loading ogv.js</h1><h2>thanks apple</h2>');
|
||||
|
||||
import_js('/.cpr/deps/ogv.js', function () {
|
||||
play(tid, seek, 1);
|
||||
play(tid, false, seek, 1);
|
||||
});
|
||||
|
||||
return;
|
||||
@@ -1181,7 +1260,7 @@ function play(tid, seek, call_depth) {
|
||||
|
||||
mp.au.tid = tid;
|
||||
mp.au.src = url + (url.indexOf('?') < 0 ? '?cache' : '&cache');
|
||||
mp.au.volume = mp.expvol();
|
||||
mp.au.volume = mp.expvol(mp.vol);
|
||||
var oid = 'a' + tid;
|
||||
setclass(oid, 'play act');
|
||||
var trs = ebi('files').getElementsByTagName('tbody')[0].getElementsByTagName('tr');
|
||||
@@ -1272,7 +1351,8 @@ function show_modal(html) {
|
||||
|
||||
|
||||
// hide fullscreen message
|
||||
function unblocked() {
|
||||
function unblocked(e) {
|
||||
ev(e);
|
||||
var dom = ebi('blocked');
|
||||
if (dom)
|
||||
dom.parentNode.removeChild(dom);
|
||||
@@ -1287,21 +1367,19 @@ function autoplay_blocked(seek) {
|
||||
|
||||
var go = ebi('blk_go'),
|
||||
na = ebi('blk_na'),
|
||||
fn = mp.tracks[mp.au.tid].split(/\//).pop();
|
||||
tid = mp.au.tid,
|
||||
fn = mp.tracks[tid].split(/\//).pop();
|
||||
|
||||
fn = uricom_dec(fn.replace(/\+/g, ' '))[0];
|
||||
|
||||
go.textContent = 'Play "' + fn + '"';
|
||||
go.onclick = function (e) {
|
||||
if (e) e.preventDefault();
|
||||
unblocked();
|
||||
mp.au.play();
|
||||
if (seek)
|
||||
seek_au_sec(seek);
|
||||
else
|
||||
mpui.progress_updater();
|
||||
|
||||
mpl.announce();
|
||||
unblocked(e);
|
||||
// chrome 91 may permanently taint on a failed play()
|
||||
// depending on win10 settings or something? idk
|
||||
mp.au_native = mp.au_ogvjs = null;
|
||||
play(tid, true, seek);
|
||||
mp.fade_in();
|
||||
};
|
||||
na.onclick = unblocked;
|
||||
}
|
||||
@@ -1322,7 +1400,7 @@ function autoplay_blocked(seek) {
|
||||
if (!m)
|
||||
return play(id[0]);
|
||||
|
||||
return play(id[0], parseInt(m[1] || 0) * 60 + parseInt(m[2] || 0));
|
||||
return play(id[0], false, parseInt(m[1] || 0) * 60 + parseInt(m[2] || 0));
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -1606,16 +1684,18 @@ document.onkeydown = function (e) {
|
||||
if (e.ctrlKey || e.altKey || e.shiftKey || e.metaKey || e.isComposing)
|
||||
return;
|
||||
|
||||
var k = (e.code + ''), pos = -1;
|
||||
var k = (e.code + ''), pos = -1, n;
|
||||
if (k.indexOf('Digit') === 0)
|
||||
pos = parseInt(k.slice(-1)) * 0.1;
|
||||
|
||||
if (pos !== -1)
|
||||
return seek_au_mul(pos) || true;
|
||||
|
||||
var n = k == 'KeyJ' ? -1 : k == 'KeyL' ? 1 : 0;
|
||||
if (n !== 0)
|
||||
return song_skip(n) || true;
|
||||
if (k == 'KeyJ')
|
||||
return prev_song() || true;
|
||||
|
||||
if (k == 'KeyL')
|
||||
return next_song() || true;
|
||||
|
||||
if (k == 'KeyP')
|
||||
return playpause() || true;
|
||||
@@ -2838,8 +2918,10 @@ function reload_mp() {
|
||||
mp.au.pause();
|
||||
mp.au = null;
|
||||
}
|
||||
mpl.stop();
|
||||
widget.close();
|
||||
mp = new MPlayer();
|
||||
setTimeout(pbar.onresize, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -740,9 +740,17 @@ function up2k_init(subtle) {
|
||||
|
||||
function handshakes_permitted() {
|
||||
var lim = multitask ? 1 : 0;
|
||||
return lim >=
|
||||
|
||||
if (lim <
|
||||
st.todo.upload.length +
|
||||
st.busy.upload.length;
|
||||
st.busy.upload.length)
|
||||
return false;
|
||||
|
||||
var cd = st.todo.handshake.length ? st.todo.handshake[0].cooldown : 0;
|
||||
if (cd && cd - Date.now() > 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function hashing_permitted() {
|
||||
@@ -1155,6 +1163,15 @@ function up2k_init(subtle) {
|
||||
if (rsp.indexOf('<pre>') === 0)
|
||||
rsp = rsp.slice(5);
|
||||
|
||||
if (rsp.indexOf('rate-limit ') !== -1) {
|
||||
var penalty = rsp.replace(/.*rate-limit /, "").split(' ')[0];
|
||||
console.log("rate-limit: " + penalty);
|
||||
t.cooldown = Date.now() + parseFloat(penalty) * 1000;
|
||||
st.busy.handshake.splice(st.busy.handshake.indexOf(t), 1);
|
||||
st.todo.handshake.unshift(t);
|
||||
return;
|
||||
}
|
||||
|
||||
st.bytes.uploaded += t.size;
|
||||
if (rsp.indexOf('partial upload exists') !== -1 ||
|
||||
rsp.indexOf('file already exists') !== -1) {
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
}
|
||||
#ggrid>a[href$="/"]:before {
|
||||
content: '📂';
|
||||
display: block;
|
||||
position: absolute;
|
||||
margin: -.1em -.4em;
|
||||
text-shadow: 0 0 .1em #000;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +22,11 @@
|
||||
#ggrid>a:before {
|
||||
display: block;
|
||||
position: absolute;
|
||||
margin: -.1em -.4em;
|
||||
padding: .3em 0;
|
||||
margin: -.4em;
|
||||
text-shadow: 0 0 .1em #000;
|
||||
background: linear-gradient(135deg,rgba(255,255,255,0) 50%,rgba(255,255,255,0.2));
|
||||
border-radius: .3em;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
|
||||
@@ -106,6 +106,12 @@ find -iname up2k.db | while IFS= read -r x; do sqlite3 "$x" 'select substr(w,1,1
|
||||
# unschedule mtp scan for all files somewhere under "enc/"
|
||||
sqlite3 -readonly up2k.db 'select substr(up.w,1,16) from up inner join mt on mt.w = substr(up.w,1,16) where rd like "enc/%" and +mt.k = "t:mtp"' > keys; awk '{printf "delete from mt where w = \"%s\" and +k = \"t:mtp\";\n", $0}' <keys | tee /dev/stderr | sqlite3 up2k.db
|
||||
|
||||
# compare metadata key "key" between two databases
|
||||
sqlite3 -readonly up2k.db.key-full 'select w, v from mt where k = "key" order by w' > k1; sqlite3 -readonly up2k.db 'select w, v from mt where k = "key" order by w' > k2; ok=0; ng=0; while IFS='|' read w k2; do k1="$(grep -E "^$w" k1 | sed -r 's/.*\|//')"; [ "$k1" = "$k2" ] && ok=$((ok+1)) || { ng=$((ng+1)); printf '%3s %3s %s\n' "$k1" "$k2" "$(sqlite3 -readonly up2k.db.key-full "select * from up where substr(w,1,16) = '$w'" | sed -r 's/\|/ | /g')"; }; done < <(cat k2); echo "match $ok diff $ng"
|
||||
|
||||
# actually this is much better
|
||||
sqlite3 -readonly up2k.db.key-full 'select w, v from mt where k = "key" order by w' > k1; sqlite3 -readonly up2k.db 'select mt.w, mt.v, up.rd, up.fn from mt inner join up on mt.w = substr(up.w,1,16) where mt.k = "key" order by up.rd, up.fn' > k2; ok=0; ng=0; while IFS='|' read w k2 path; do k1="$(grep -E "^$w" k1 | sed -r 's/.*\|//')"; [ "$k1" = "$k2" ] && ok=$((ok+1)) || { ng=$((ng+1)); printf '%3s %3s %s\n' "$k1" "$k2" "$path"; }; done < <(cat k2); echo "match $ok diff $ng"
|
||||
|
||||
|
||||
##
|
||||
## media
|
||||
|
||||
Reference in New Issue
Block a user