Skip to content

Commit 571967b

Browse files
committed
fixed broken streaming link
1 parent 424315e commit 571967b

1 file changed

Lines changed: 19 additions & 65 deletions

File tree

src/parsers/decryptors/decrypt_v1.decryptor.js

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import extractToken from "../../helper/token.helper.js";
66

77
export async function decryptSources_v1(epID, id, name, type) {
88
try {
9-
const [{ data: sourcesData }, { data: key }] = await Promise.all([
10-
axios.get(`https://${v1_base_url}/ajax/v2/episode/sources?id=${id}`),
11-
axios.get("https://raw.githubusercontent.com/itzzzme/megacloud-keys/refs/heads/main/key.txt"),
12-
]);
13-
9+
// const [{ data: sourcesData }, { data: key }] = await Promise.all([
10+
// axios.get(`https://${v1_base_url}/ajax/v2/episode/sources?id=${id}`),
11+
// axios.get("https://raw.githubusercontent.com/itzzzme/megacloud-keys/refs/heads/main/key.txt"),
12+
// ]);
13+
const { data: sourcesData } = await axios.get(
14+
`https://${v1_base_url}/ajax/v2/episode/sources?id=${id}`,
15+
);
1416
const ajaxLink = sourcesData?.link;
1517
if (!ajaxLink) throw new Error("Missing link in sourcesData");
1618

@@ -19,74 +21,26 @@ export async function decryptSources_v1(epID, id, name, type) {
1921
if (!sourceId) throw new Error("Unable to extract sourceId from link");
2022

2123
const baseUrlMatch = ajaxLink.match(/^(https?:\/\/[^\/]+(?:\/[^\/]+){3})/);
22-
if (!baseUrlMatch) throw new Error("Could not extract base URL from ajaxLink");
24+
if (!baseUrlMatch)
25+
throw new Error("Could not extract base URL from ajaxLink");
2326
const baseUrl = baseUrlMatch[1];
27+
const iframeURL = `${baseUrl}/${sourceId}?k=1&autoPlay=0&oa=0&asi=1`;
2428

25-
let decryptedSources = null;
26-
let rawSourceData = {};
27-
28-
try {
29-
const token = await extractToken(`${baseUrl}/${sourceId}?k=1&autoPlay=0&oa=0&asi=1`);
30-
const { data } = await axios.get(`${baseUrl}/getSources?id=${sourceId}&_k=${token}`);
31-
rawSourceData = data;
32-
const encrypted = rawSourceData?.sources;
33-
rawSourceData.iframe=`${baseUrl}/${sourceId}?k=1&autoPlay=0&oa=0&asi=1`;
34-
if (!encrypted) throw new Error("Encrypted source missing");
35-
const decrypted = CryptoJS.AES.decrypt(encrypted, key.trim()).toString(CryptoJS.enc.Utf8);
36-
if (!decrypted) throw new Error("Failed to decrypt source");
37-
decryptedSources = JSON.parse(decrypted);
38-
} catch (decryptionError) {
39-
try {
40-
const fallback = name.toLowerCase() === "hd-1" ? fallback_1 : fallback_2;
41-
42-
const { data: html } = await axios.get(
43-
`https://${fallback}/stream/s-2/${epID}/${type}`,
44-
{
45-
headers: {
46-
Referer: `https://${fallback_1}/`,
47-
},
48-
}
49-
);
50-
rawSourceData.iframe=`https://${fallback}/stream/s-2/${epID}/${type}`;
51-
const dataIdMatch = html.match(/data-id=["'](\d+)["']/);
52-
const realId = dataIdMatch?.[1];
53-
if (!realId) throw new Error("Could not extract data-id for fallback");
54-
55-
const { data: fallback_data } = await axios.get(
56-
`https://${fallback}/stream/getSources?id=${realId}`,
57-
{
58-
headers: {
59-
"X-Requested-With": "XMLHttpRequest",
60-
},
61-
}
62-
);
63-
64-
decryptedSources = [{ file: fallback_data.sources.file }];
65-
if (!rawSourceData.tracks || rawSourceData.tracks.length === 0) {
66-
rawSourceData.tracks = fallback_data.tracks ?? [];
67-
}
68-
if (!rawSourceData.intro) {
69-
rawSourceData.intro = fallback_data.intro ?? null;
70-
}
71-
if (!rawSourceData.outro) {
72-
rawSourceData.outro = fallback_data.outro ?? null;
73-
}
74-
} catch (fallbackError) {
75-
throw new Error("Fallback failed: " + fallbackError.message);
76-
}
77-
}
78-
29+
const { data: rawSourceData } = await axios.get(
30+
`https://decrypt.zenime.site/extract?embed_url=${iframeURL}`,
31+
);
32+
const decryptedSources = rawSourceData.data;
7933
return {
8034
id,
8135
type,
8236
link: {
83-
file: decryptedSources?.[0]?.file ?? "",
37+
file: decryptedSources?.sources[0]?.file ?? "",
8438
type: "hls",
8539
},
86-
tracks: rawSourceData.tracks ?? [],
87-
intro: rawSourceData.intro ?? null,
88-
outro: rawSourceData.outro ?? null,
89-
iframe: rawSourceData.iframe,
40+
tracks: decryptedSources.tracks ?? [],
41+
intro: decryptedSources.intro ?? null,
42+
outro: decryptedSources.outro ?? null,
43+
iframe: iframeURL,
9044
server: name,
9145
};
9246
} catch (error) {

0 commit comments

Comments
 (0)