added 4movies, aether, castle, framextv, meowtv, and re-added vidora

This commit is contained in:
2026-10-31 23:40:45 -07:00
parent 8e56a0684b
commit 9fb01f8b49
8 changed files with 1118 additions and 20 deletions

View File

@@ -1,6 +1,15 @@
import { HEALTH_PROBE_ID } from "./config.js";
const withTimeout = (promise, ms) => Promise.race([promise, new Promise(r => setTimeout(() => r(null), ms))]);
const MOVIE_PROBE_ID = "936075";
const TV_PROBE_ID = "37854";
const TV_PROBE_SEASON = "1";
const TV_PROBE_EPISODE = "1";
const withTimeout = (promise, ms) =>
Promise.race([
promise,
new Promise(resolve => setTimeout(() => resolve(null), ms))
]);
async function withRetry(fn, attempts = 2, delay = 300) {
for (let i = 0; i < attempts; i++) {
try {
@@ -8,31 +17,62 @@ async function withRetry(fn, attempts = 2, delay = 300) {
if (result != null) return result;
} catch (err) {
if (i === attempts - 1) throw err;
await new Promise(r => setTimeout(r, delay + Math.random() * delay * 0.5));
await new Promise(resolve =>
setTimeout(resolve, delay + Math.random() * delay * 0.5)
);
}
}
return null;
}
function hasStream(result) {
const urls = [
result?.url,
...(result?.allUrls || []).map(item => item?.url)
];
return urls.some(url =>
typeof url === "string" && url.startsWith("http")
);
}
export async function probeSource(sdk, cfg, mod) {
const audio = /dub$/.test(cfg.key) ? 'dub' : 'sub';
const streamArgs = {
id: HEALTH_PROBE_ID,
s: null,
e: null,
clientIP: null,
absoluteBase: null,
audio,
sdk,
config: cfg,
const audio = /dub$/.test(cfg.key) ? "dub" : "sub";
const start = Date.now();
const test = async (id, s = null, e = null) => {
const streamArgs = {
id,
s,
e,
clientIP: null,
absoluteBase: null,
audio,
sdk,
config: cfg,
};
const result = await withTimeout(
withRetry(
() => mod.getStream(streamArgs),
cfg.retries,
300
),
cfg.timeout
);
return hasStream(result);
};
const t = Date.now();
const result = await withTimeout(
withRetry(() => mod.getStream(streamArgs), cfg.retries, 300),
cfg.timeout
);
const [movie, tv] = await Promise.all([
test(MOVIE_PROBE_ID),
test(TV_PROBE_ID, TV_PROBE_SEASON, TV_PROBE_EPISODE)
]);
const firstUrl = result?.url ?? result?.allUrls?.[0]?.url;
return { ok: !!(typeof firstUrl === 'string' && firstUrl.startsWith('http')), ms: Date.now() - t };
return {
ok: movie || tv,
movie,
tv,
ms: Date.now() - start
};
}