torrent-online 1.6.1 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/wtui.js +13 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torrent-online",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Stream .torrent / magnet to VLC or browser — torrent streaming for macOS/Linux without a torrent client. Стрим торрентов в VLC или браузер.",
|
|
6
6
|
"keywords": [
|
package/wtui.js
CHANGED
|
@@ -851,7 +851,7 @@ async function webReq(req, res, client, st, opts, cacheDir, base) {
|
|
|
851
851
|
const name = mH[3];
|
|
852
852
|
if (name.includes('..')) { res.statusCode = 400; res.end('bad'); return; }
|
|
853
853
|
const a = u.searchParams.get('a') || '0';
|
|
854
|
-
const si = (u.searchParams.get('si') || '').split(',').map(Number).filter(n => Number.isFinite(n)).slice(0,
|
|
854
|
+
const si = (u.searchParams.get('si') || '').split(',').map(Number).filter(n => Number.isFinite(n)).slice(0, 1);
|
|
855
855
|
const key = mH[1] + '-' + mH[2] + '-' + a + (si.length ? '-s' + si.join('.') : '');
|
|
856
856
|
const dir = path.join(HLS_ROOT, key);
|
|
857
857
|
const fp = path.join(dir, name);
|
|
@@ -871,7 +871,9 @@ async function webReq(req, res, client, st, opts, cacheDir, base) {
|
|
|
871
871
|
for (const i of si) args.push('-map', '0:s:' + i);
|
|
872
872
|
if (si.length) args.push('-c:s', 'webvtt');
|
|
873
873
|
const vsm = ['v:0', 'a:0']; for (let i = 0; i < si.length; i++) vsm.push('s:' + i);
|
|
874
|
-
|
|
874
|
+
const segTpl = si.length ? 'seg-%s-%d.ts' : 'seg-%d.ts';
|
|
875
|
+
const plTpl = si.length ? 'pl-%s.m3u8' : 'pl.m3u8';
|
|
876
|
+
args.push('-f', 'hls', '-hls_time', '4', '-hls_list_size', '0', '-hls_playlist_type', 'event', '-hls_flags', 'independent_segments', '-hls_segment_type', 'mpegts', '-master_pl_name', 'master.m3u8', '-var_stream_map', vsm.join(','), '-hls_segment_filename', dir + '/' + segTpl, dir + '/' + plTpl);
|
|
875
877
|
const proc = spawn(ffmpeg, args, { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
876
878
|
let ffErr = 0;
|
|
877
879
|
proc.stderr.on('data', d => { if (ffErr < 3) { console.error('hls:', String(d).trim().slice(0, 200)); ffErr++; } });
|
|
@@ -909,16 +911,11 @@ async function webReq(req, res, client, st, opts, cacheDir, base) {
|
|
|
909
911
|
'var v=document.getElementById("v"),aS=document.getElementById("a"),sS=document.getElementById("s"),n=document.getElementById("n"),ov=document.getElementById("ov");' +
|
|
910
912
|
'ov.onclick=function(){v.play().catch(function(){});ov.style.display="none"};' +
|
|
911
913
|
'var tries=0,hls=null;' +
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
'var
|
|
915
|
-
'
|
|
916
|
-
'
|
|
917
|
-
'sS.style.display="";sS.value="0";sS.onchange=function(){applySub(+sS.value)};applySub(0)};' +
|
|
918
|
-
'var play=function(u){if(hls){try{hls.destroy()}catch(e){}hls=null}' +
|
|
919
|
-
'if(NAT){v.src=u;v.play().catch(function(){ov.style.display="flex"});setTimeout(fillSubs,2000);setTimeout(fillSubs,5000)}' +
|
|
920
|
-
'else if(window.Hls&&Hls.isSupported()){hls=new Hls({startPosition:0,enableWorker:true,lowLatencyMode:false});hls.loadSource(u);hls.attachMedia(v);' +
|
|
921
|
-
'hls.on(Hls.Events.MANIFEST_PARSED,function(){v.play().catch(function(){ov.style.display="flex"});fillSubs()});' +
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
'var play=function(u,seek){if(hls){try{hls.destroy()}catch(e){}hls=null}' +
|
|
917
|
+
'if(window.Hls&&Hls.isSupported()){hls=new Hls({startPosition:0,enableWorker:true,lowLatencyMode:false});hls.loadSource(u);hls.attachMedia(v);' +
|
|
918
|
+
'hls.on(Hls.Events.MANIFEST_PARSED,function(){v.play().catch(function(){ov.style.display="flex"});if(seek>1){var iv=setInterval(function(){if(v.duration>seek+3){v.currentTime=seek;clearInterval(iv)}},1000);setTimeout(function(){clearInterval(iv)},120000)}});' +
|
|
922
919
|
'hls.on(Hls.Events.ERROR,function(ev,d){if(d.fatal)n.textContent="⚠ HLS: "+d.type})}' +
|
|
923
920
|
'else{v.src=u;v.play().catch(function(){ov.style.display="flex"})}};' +
|
|
924
921
|
'var load=function(){fetch(B+"/api/tracks/"+ID+"/"+I).then(function(r){return r.json()}).then(function(d){' +
|
|
@@ -929,8 +926,10 @@ async function webReq(req, res, client, st, opts, cacheDir, base) {
|
|
|
929
926
|
'var SI=S.filter(function(t){return ["subrip","ass","ssa","srt","mov_text","webvtt","text"].indexOf(t.codec)>=0}).map(function(t){return t.s});' +
|
|
930
927
|
'A.forEach(function(t){var o=document.createElement("option");o.value=t.a;o.textContent="♪ "+(t.lang&&t.lang!=="und"?t.lang:"дорожка "+(t.a+1))+(t.title?" — "+t.title:"")+" ["+t.codec+"]";aS.appendChild(o)});' +
|
|
931
928
|
'if(A.length>1){aS.value=A[0].a;aS.style.display=""}' +
|
|
932
|
-
'var go=function(){var a=aS.style.display!==""?aS.value:0;play(B+"/hls/"+ID+"/"+I+"/master.m3u8?a="+a+(
|
|
933
|
-
'
|
|
929
|
+
'var go=function(){var a=aS.style.display!==""?aS.value:0;var s=sS.style.display!==""?sS.value:"";var t=v.currentTime>1?v.currentTime:0;play(B+"/hls/"+ID+"/"+I+"/master.m3u8?a="+a+(s!==""?"&si="+s:""),t)};' +
|
|
930
|
+
'if(SI.length){var o0=document.createElement("option");o0.value="";o0.textContent="без субтитров";sS.appendChild(o0);' +
|
|
931
|
+
'S.filter(function(t){return SI.indexOf(t.s)>=0}).forEach(function(t){var o=document.createElement("option");o.value=t.s;o.textContent="💬 "+(t.lang&&t.lang!=="und"?t.lang:"субтитры "+(t.s+1))+(t.title?" — "+t.title:"");sS.appendChild(o)});sS.value="";sS.style.display=""}' +
|
|
932
|
+
'aS.onchange=go;sS.onchange=go;go();' +
|
|
934
933
|
'}).catch(function(){if(tries++<15)setTimeout(load,4000)})};' +
|
|
935
934
|
'v.addEventListener("playing",function(){n.textContent="";ov.style.display="none"});' +
|
|
936
935
|
'setInterval(function(){fetch(B+"/api/status").then(function(r){return r.json()}).then(function(l){var t=l.find(function(x){return x.id===ID});if(t&&v.readyState<2)n.textContent="⏬ "+t.speed+" · пиры "+t.peers+(t.progress>0?" · "+t.progress+"%":"")}).catch(function(){})},2000);' +
|