organized/fixed streams

This commit is contained in:
2026-10-31 12:37:24 -07:00
parent 95f4991914
commit 7473c0fa15
51 changed files with 2920 additions and 3059 deletions

View File

@@ -1,6 +1,6 @@
import { fetchJson, fetchText } from '../utils/helpers.js';
const API = "https://enc-dec.app/api";
const API = 'https://enc-dec.app/api';
async function solveStage1(challenge1, seed) {
const K = [
@@ -210,91 +210,93 @@ async function solveStage2(data) {
throw new Error('no solution found');
}
export async function getStream({ id, s, e }) {
export async function getStream(args) {
const { id, s, e } = args || {};
const isTv = s != null && e != null;
const mediaType = isTv ? 'tv' : 'movie';
const type = isTv ? 'tv' : 'movie';
const url = isTv
? `https://cinesrc.st/embed/tv/${id}?s=${s}&e=${e}`
: `https://cinesrc.st/embed/movie/${id}`;
const headers = {
"Origin": "https://cinesrc.st",
"Referer": "https://cinesrc.st/",
"Content-Type": "text/plain;charset=UTF-8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.37 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.37"
Origin: 'https://cinesrc.st',
Referer: 'https://cinesrc.st/',
'Content-Type': 'text/plain;charset=UTF-8',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.37 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.37',
};
const fields = [type, id, s ? String(s) : null, e ? String(e) : null];
const encoded = btoa(JSON.stringify(fields).replace(/ /g, '')).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
const bootstrapHeaders = { ...headers, "x-cs-q": encoded };
const bootstrap = await fetchJson("https://cinesrc.st/api/c/bootstrap", {
method: "POST",
const bootstrapHeaders = { ...headers, 'x-cs-q': encoded };
const bootstrap = await fetchJson('https://cinesrc.st/api/c/bootstrap', {
method: 'POST',
headers: bootstrapHeaders,
body: "{}"
body: '{}',
});
const cookies = {
"x-cs-b": "20261014-a",
"x-cs-q": encoded,
"x-cs-r": bootstrap.r,
"x-cs-p": bootstrap.p,
'x-cs-b': '20261014-a',
'x-cs-q': encoded,
'x-cs-r': bootstrap.r,
'x-cs-p': bootstrap.p,
};
const challenge1 = await fetchJson("https://cinesrc.st/api/c/issue", {
headers: { ...headers, ...cookies }
const challenge1 = await fetchJson('https://cinesrc.st/api/c/issue', {
headers: { ...headers, ...cookies },
});
const payload1 = {
data: {
url,
user_agent: headers["User-Agent"],
challenge_data: challenge1
user_agent: headers['User-Agent'],
challenge_data: challenge1,
},
type: "seed"
type: 'seed',
};
const seedRes = await fetchJson(`${API}/enc-cinesrc`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload1)
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload1),
});
const seedData = seedRes.result;
const solution1 = await solveStage1(challenge1, seedData.seed);
const challenge2 = await fetchJson("https://cinesrc.st/api/c/stage2/issue", {
headers: { ...headers, ...cookies }
const challenge2 = await fetchJson('https://cinesrc.st/api/c/stage2/issue', {
headers: { ...headers, ...cookies },
});
const solution2 = await solveStage2(challenge2);
const payload2 = {
data: {
url,
user_agent: headers["User-Agent"],
user_agent: headers['User-Agent'],
challenge_data: {
stage1: { challenge: challenge1, solution: solution1 },
stage2: { challenge: challenge2, solution: solution2 }
stage2: { challenge: challenge2, solution: solution2 },
},
state: seedData.state
state: seedData.state,
},
type: "encrypt"
type: 'encrypt',
};
const encryptRes = await fetchJson(`${API}/enc-cinesrc`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload2)
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload2),
});
const encData = encryptRes.result;
const token = `${encData.token}::c3::${cookies["x-cs-r"]}`;
const token = `${encData.token}::c3::${cookies['x-cs-r']}`;
const nextActions = encData.headers;
const providersText = await fetchText(url, {
method: "POST",
headers: { ...headers, ...cookies, "Next-Action": nextActions.getProviderList },
body: JSON.stringify([])
method: 'POST',
headers: { ...headers, ...cookies, 'Next-Action': nextActions.getProviderList },
body: JSON.stringify([]),
});
const lines = providersText.split('\n');
@@ -320,19 +322,19 @@ export async function getStream({ id, s, e }) {
const provider = providerObj.id;
const streamPayload = [
id,
isTv ? "show" : type,
isTv ? String(s) : "$undefined",
isTv ? String(e) : "$undefined",
isTv ? 'show' : type,
isTv ? String(s) : '$undefined',
isTv ? String(e) : '$undefined',
token,
provider
provider,
];
let streamRes;
try {
streamRes = await fetchText(url, {
method: "POST",
headers: { ...headers, ...cookies, "Next-Action": nextActions.getStream },
body: JSON.stringify(streamPayload)
method: 'POST',
headers: { ...headers, ...cookies, 'Next-Action': nextActions.getStream },
body: JSON.stringify(streamPayload),
});
} catch {
continue;
@@ -343,9 +345,9 @@ export async function getStream({ id, s, e }) {
let decryptRes;
try {
decryptRes = await fetchJson(`${API}/dec-cinesrc`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ text: streamRes, state: encData.state })
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ text: streamRes, state: encData.state }),
});
} catch {
continue;
@@ -378,10 +380,12 @@ export async function getStream({ id, s, e }) {
allUrls.push({
url: streamUrl,
server: `CineSrc - ${providerObj.name || provider}`,
quality: 'Auto',
type: streamUrl.includes('.m3u8') ? 'hls' : 'mp4',
headers: resultData.headers || {
Referer: "https://cinesrc.st/",
Origin: "https://cinesrc.st"
}
Referer: 'https://cinesrc.st/',
Origin: 'https://cinesrc.st',
},
});
break;
}
@@ -393,6 +397,6 @@ export async function getStream({ id, s, e }) {
return {
url: allUrls[0].url,
headers: allUrls[0].headers,
allUrls
allUrls,
};
}