Update index.js
Browse files
index.js
CHANGED
|
@@ -20,6 +20,7 @@ const TMDB_KEY = process.env.TMDB_KEY || '83d364331c40bfbe29858aeed82f45c
|
|
| 20 |
const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36';
|
| 21 |
const TORRENTCLAW_API = 'https://torrentclaw.com/api/stremio';
|
| 22 |
|
|
|
|
| 23 |
const MAX_SIZE_GB_MOVIE = 4;
|
| 24 |
const MAX_SIZE_GB_SERIES = 1.5;
|
| 25 |
const LINKS_PER_QUALITY = 5;
|
|
@@ -51,10 +52,6 @@ const TR = [
|
|
| 51 |
'https://tracker.zhuqiy.com:443/announce',
|
| 52 |
].map(t => '&tr=' + encodeURIComponent(t)).join('');
|
| 53 |
|
| 54 |
-
function buildMagnet(hash, name) {
|
| 55 |
-
return 'magnet:?xt=urn:btih:' + hash.toLowerCase() + '&dn=' + encodeURIComponent(name) + TR;
|
| 56 |
-
}
|
| 57 |
-
|
| 58 |
function getQuality(str = '') {
|
| 59 |
const s = str.toLowerCase();
|
| 60 |
if (s.includes('4k') || s.includes('2160p') || s.includes('uhd')) return '4k';
|
|
@@ -135,8 +132,20 @@ function processStreams(streams, type) {
|
|
| 135 |
|
| 136 |
const filtered = streams.filter(s => {
|
| 137 |
if (!s.infoHash && !s.url) return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
const sizeGB = s._sizeGB ?? getSizeGB(s);
|
| 139 |
-
if (sizeGB !== null && sizeGB > maxSize)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
return true;
|
| 141 |
});
|
| 142 |
|
|
@@ -169,6 +178,7 @@ function processStreams(streams, type) {
|
|
| 169 |
result.push(...byQuality[q].slice(0, LINKS_PER_QUALITY));
|
| 170 |
});
|
| 171 |
|
|
|
|
| 172 |
return result;
|
| 173 |
}
|
| 174 |
|
|
@@ -338,7 +348,6 @@ app.get('/diag-raw/:type/:id', async (req, res) => {
|
|
| 338 |
|
| 339 |
// ββββββββββββββββββββββββββ LANDING PAGE βββββββββββββββββββββββββββ
|
| 340 |
app.get('/', (req, res) => {
|
| 341 |
-
// β
Dynamic URLs β works on HF Spaces, custom domains, or local
|
| 342 |
const proto = (req.headers['x-forwarded-proto'] || req.protocol || 'https').split(',')[0].trim();
|
| 343 |
const host = req.headers['x-forwarded-host'] || req.get('host');
|
| 344 |
const base = `${proto}://${host}`;
|
|
@@ -409,7 +418,7 @@ body{font-family:-apple-system,'Segoe UI',system-ui,sans-serif;background:#05081
|
|
| 409 |
</html>`);
|
| 410 |
});
|
| 411 |
|
| 412 |
-
// βββ Health check
|
| 413 |
app.get('/health', (_, res) => res.json({ ok: true, uptime: process.uptime() }));
|
| 414 |
|
| 415 |
app.listen(PORT, '0.0.0.0', () =>
|
|
|
|
| 20 |
const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36';
|
| 21 |
const TORRENTCLAW_API = 'https://torrentclaw.com/api/stremio';
|
| 22 |
|
| 23 |
+
// β
RESTORED: Original size caps
|
| 24 |
const MAX_SIZE_GB_MOVIE = 4;
|
| 25 |
const MAX_SIZE_GB_SERIES = 1.5;
|
| 26 |
const LINKS_PER_QUALITY = 5;
|
|
|
|
| 52 |
'https://tracker.zhuqiy.com:443/announce',
|
| 53 |
].map(t => '&tr=' + encodeURIComponent(t)).join('');
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
function getQuality(str = '') {
|
| 56 |
const s = str.toLowerCase();
|
| 57 |
if (s.includes('4k') || s.includes('2160p') || s.includes('uhd')) return '4k';
|
|
|
|
| 132 |
|
| 133 |
const filtered = streams.filter(s => {
|
| 134 |
if (!s.infoHash && !s.url) return false;
|
| 135 |
+
|
| 136 |
+
// β
NEW: Exclude 4K streams
|
| 137 |
+
const quality = s._quality || getQuality(s.title || s.name || '');
|
| 138 |
+
if (quality === '4k') {
|
| 139 |
+
console.log(`[processStreams] Filtered out 4K: ${s.title?.substring(0, 50)}...`);
|
| 140 |
+
return false;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
const sizeGB = s._sizeGB ?? getSizeGB(s);
|
| 144 |
+
if (sizeGB !== null && sizeGB > maxSize) {
|
| 145 |
+
console.log(`[processStreams] Filtered out ${sizeGB.toFixed(2)} GB (Max: ${maxSize} GB): ${s.title?.substring(0, 50)}...`);
|
| 146 |
+
return false;
|
| 147 |
+
}
|
| 148 |
+
|
| 149 |
return true;
|
| 150 |
});
|
| 151 |
|
|
|
|
| 178 |
result.push(...byQuality[q].slice(0, LINKS_PER_QUALITY));
|
| 179 |
});
|
| 180 |
|
| 181 |
+
console.log(`[processStreams] Input: ${streams.length}, Filtered: ${filtered.length}, Unique: ${unique.length}, Final: ${result.length}`);
|
| 182 |
return result;
|
| 183 |
}
|
| 184 |
|
|
|
|
| 348 |
|
| 349 |
// ββββββββββββββββββββββββββ LANDING PAGE βββββββββββββββββββββββββββ
|
| 350 |
app.get('/', (req, res) => {
|
|
|
|
| 351 |
const proto = (req.headers['x-forwarded-proto'] || req.protocol || 'https').split(',')[0].trim();
|
| 352 |
const host = req.headers['x-forwarded-host'] || req.get('host');
|
| 353 |
const base = `${proto}://${host}`;
|
|
|
|
| 418 |
</html>`);
|
| 419 |
});
|
| 420 |
|
| 421 |
+
// βββ Health check βββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 422 |
app.get('/health', (_, res) => res.json({ ok: true, uptime: process.uptime() }));
|
| 423 |
|
| 424 |
app.listen(PORT, '0.0.0.0', () =>
|