torrent-online 1.7.2 → 1.7.4
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 +24 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "torrent-online",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
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
|
@@ -321,7 +321,7 @@ function btihKey(mag) { const m = /btih:([0-9a-fA-F]{40}|[0-9a-fA-F]{32})/.exec(
|
|
|
321
321
|
|
|
322
322
|
|
|
323
323
|
async function searchTPB(q, host = '') {
|
|
324
|
-
const hosts = ['https://tpb.party', 'https://piratebay.live'];
|
|
324
|
+
const hosts = ['https://tpb.party', 'https://piratebay.live', 'https://tpbay.site', 'https://piratebay6.org', 'https://thepiratebay3.org'];
|
|
325
325
|
let html = '', lastErr = new Error('TPB: нет ответа');
|
|
326
326
|
for (const h of (host ? [host] : hosts)) {
|
|
327
327
|
try {
|
|
@@ -349,12 +349,19 @@ async function searchTPB(q, host = '') {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
async function searchRutor(q) {
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
352
|
+
const hosts = ['https://rutor.info', 'https://rutor.is', 'https://newrutor.info'];
|
|
353
|
+
let html = '', lastErr = new Error('Rutor: нет ответа');
|
|
354
|
+
for (const h of hosts) {
|
|
355
|
+
try {
|
|
356
|
+
const r = await fetch(`${h}/search/0/0/0/0/${encodeURIComponent(q)}/`, {
|
|
357
|
+
headers: { 'user-agent': UA },
|
|
358
|
+
signal: AbortSignal.timeout(9000),
|
|
359
|
+
});
|
|
360
|
+
if (r.ok) { html = await r.text(); lastErr = null; break; }
|
|
361
|
+
lastErr = new Error(`Rutor: HTTP ${r.status}`);
|
|
362
|
+
} catch (e) { lastErr = e; }
|
|
363
|
+
}
|
|
364
|
+
if (lastErr) throw lastErr;
|
|
358
365
|
const out = [];
|
|
359
366
|
for (const row of html.split('<tr class="gai">').slice(1, 26)) {
|
|
360
367
|
const magRaw = /href="(magnet:[^"]+)"/.exec(row)?.[1];
|
|
@@ -586,17 +593,25 @@ video{width:100vw;height:100vh;background:#000;display:block;margin:0}
|
|
|
586
593
|
var BASE="__BASE__";
|
|
587
594
|
function esc(s){return String(s).replace(/[&<>"']/g,function(c){return {'&':'&','<':'<','>':'>','"':'"',"'":'''}[c];});}
|
|
588
595
|
function api(p,body){var o=body?{method:'POST',headers:{'content-type':'application/json'},body:JSON.stringify(body)}:undefined;return fetch(BASE+p,o).then(function(r){return r.json();});}
|
|
596
|
+
function addTorrent(mag){
|
|
597
|
+
var box=document.getElementById('torrents');
|
|
598
|
+
var dn=(/dn=([^&]*)/.exec(mag)||[,''])[1];try{dn=decodeURIComponent(dn.replace(/\+/g,' '))}catch(e){}
|
|
599
|
+
var ph=document.createElement('div');ph.className='card';
|
|
600
|
+
ph.innerHTML='<div class=tname>⏳ '+esc(dn||'торрент')+'</div><div class=tmeta>добавляю в клиент…</div>';
|
|
601
|
+
box.prepend(ph);
|
|
602
|
+
api('/api/add',{source:mag}).then(function(d){if(d&&d.error){ph.innerHTML='<div class=tname>⚠ '+esc(d.error)+'</div>';}poll();toTorrents();}).catch(function(e){ph.innerHTML='<div class=tname>⚠ Ошибка /api/add: '+esc(e&&e.message||e)+'</div>';});
|
|
603
|
+
}
|
|
589
604
|
function doSearch(){var q=document.getElementById('q').value.trim();if(!q)return;var box=document.getElementById('results');box.innerHTML='<div class=note>Ищу…</div>';
|
|
590
605
|
api('/api/search?q='+encodeURIComponent(q)).then(function(d){
|
|
591
606
|
var h='';(d.notes||[]).forEach(function(n){h+='<div class=note>⚠ '+esc(n)+'</div>';});
|
|
592
607
|
if(!d.items.length){box.innerHTML=h+'<div class=note>Ничего не найдено</div>';return;}
|
|
593
608
|
h+=d.items.map(function(it){return '<div class=row data-mag="'+esc(it.mag)+'"><span class=tag>'+esc(it.src)+'</span><span class=rname>'+esc(it.name)+'</span>'+(it.size?'<span class=meta>'+esc(it.size)+'</span>':'')+(it.seeds?'<span class=meta>🌱 '+it.seeds+'</span>':'')+'</div>';}).join('');
|
|
594
609
|
box.innerHTML=h;
|
|
595
|
-
[].forEach.call(box.querySelectorAll('.row'),function(r){r.onclick=function(){
|
|
610
|
+
[].forEach.call(box.querySelectorAll('.row'),function(r){r.onclick=function(){addTorrent(r.getAttribute('data-mag'));};});
|
|
596
611
|
}).catch(function(){box.innerHTML='<div class=note>Ошибка поиска</div>';});}
|
|
597
612
|
document.getElementById('go').onclick=doSearch;
|
|
598
613
|
document.getElementById('q').addEventListener('keydown',function(e){if(e.key==='Enter')doSearch();});
|
|
599
|
-
document.getElementById('mag').onclick=function(){var m=prompt('magnet:');if(m&&m.indexOf('magnet:')===0){
|
|
614
|
+
document.getElementById('mag').onclick=function(){var m=prompt('magnet:');if(m&&m.indexOf('magnet:')===0){addTorrent(m);}};
|
|
600
615
|
document.getElementById('tpath').onclick=function(){document.getElementById('tt').click();};
|
|
601
616
|
document.getElementById('tt').onchange=function(){if(this.files&&this.files[0])uploadFile(this.files[0]);this.value='';};
|
|
602
617
|
function uploadFile(f){var nb=document.getElementById('notes');nb.innerHTML='<div class=note>⏳ Загружаю '+esc(f.name)+'…</div>';
|