fix: manual kodik manifest parsing
Some checks failed
V3 Preview Deployment / Deploy-Preview (push) Has been cancelled

This commit is contained in:
Kentai Radiquum 2025-04-13 02:43:32 +05:00
parent 73fb51d914
commit 42d838a497
Signed by: Radiquum
GPG key ID: 858E8EE696525EED

View file

@ -61,6 +61,15 @@ export async function _fetchPlayer(
return data; return data;
} }
function decryptKodikLink(enc: string) {
const decryptedBase64 = enc.replace(/[a-zA-Z]/g, (e: any) => {
return String.fromCharCode(
(e <= "Z" ? 90 : 122) >= (e = e.charCodeAt(0) + 18) ? e : e - 26
);
});
return atob(decryptedBase64);
}
export const _fetchKodikManifest = async ( export const _fetchKodikManifest = async (
url: string, url: string,
setPlayerError: (state) => void setPlayerError: (state) => void
@ -75,12 +84,7 @@ export const _fetchKodikManifest = async (
if (!lowQualityLink.includes("//")) { if (!lowQualityLink.includes("//")) {
// check if link is encrypted, else do nothing // check if link is encrypted, else do nothing
const decryptedBase64 = lowQualityLink.replace(/[a-zA-Z]/g, (e) => { lowQualityLink = decryptKodikLink(lowQualityLink);
return String.fromCharCode(
(e <= "Z" ? 90 : 122) >= (e = e.charCodeAt(0) + 18) ? e : e - 26
);
});
lowQualityLink = atob(decryptedBase64);
} }
if (lowQualityLink.includes("https://")) { if (lowQualityLink.includes("https://")) {
@ -100,30 +104,87 @@ export const _fetchKodikManifest = async (
if (data.links.hasOwnProperty("240")) { if (data.links.hasOwnProperty("240")) {
blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=427x240,BANDWIDTH=200000\n"; blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=427x240,BANDWIDTH=200000\n";
!data.links["240"][0].src.startsWith("https:") ? let link = data.links["240"][0].src;
(blobTxt += `https:${data.links["240"][0].src}\n`) let dec = null;
: (blobTxt += `${data.links["240"][0].src}\n`); link.includes("//") ?
link.startsWith("https:") ?
(blobTxt += `${link}\n`)
: (blobTxt += `https:${link}\n`)
: (dec = decryptKodikLink(link));
dec ?
dec.startsWith("https:") ?
(blobTxt += `${dec}\n`)
: (blobTxt += `https:${dec}\n`)
: null;
} }
if (data.links.hasOwnProperty("360")) { if (data.links.hasOwnProperty("360")) {
blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=578x360,BANDWIDTH=400000\n"; blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=578x360,BANDWIDTH=400000\n";
!data.links["360"][0].src.startsWith("https:") ? let link = data.links["360"][0].src;
(blobTxt += `https:${data.links["360"][0].src}\n`) let dec = null;
: (blobTxt += `${data.links["360"][0].src}\n`); link.includes("//") ?
link.startsWith("https:") ?
(blobTxt += `${link}\n`)
: (blobTxt += `https:${link}\n`)
: (dec = decryptKodikLink(link));
dec ?
dec.startsWith("https:") ?
(blobTxt += `${dec}\n`)
: (blobTxt += `https:${dec}\n`)
: null;
} }
if (data.links.hasOwnProperty("480")) { if (data.links.hasOwnProperty("480")) {
blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=854x480,BANDWIDTH=596000\n"; blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=854x480,BANDWIDTH=596000\n";
!data.links["480"][0].src.startsWith("https:") ? let link = data.links["480"][0].src;
(blobTxt += `https:${data.links["480"][0].src}\n`) let dec = null;
: (blobTxt += `${data.links["480"][0].src}\n`); link.includes("//") ?
link.startsWith("https:") ?
(blobTxt += `${link}\n`)
: (blobTxt += `https:${link}\n`)
: (dec = decryptKodikLink(link));
dec ?
dec.startsWith("https:") ?
(blobTxt += `${dec}\n`)
: (blobTxt += `https:${dec}\n`)
: null;
} }
if (data.links.hasOwnProperty("720")) { if (data.links.hasOwnProperty("720")) {
blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=1280x720,BANDWIDTH=1280000\n"; blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=1280x720,BANDWIDTH=1280000\n";
!data.links["720"][0].src.startsWith("https:") ? let link = data.links["720"][0].src;
(blobTxt += `https:${data.links["720"][0].src}\n`) let dec = null;
: (blobTxt += `${data.links["720"][0].src}\n`); link.includes("//") ?
link.startsWith("https:") ?
(blobTxt += `${link}\n`)
: (blobTxt += `https:${link}\n`)
: (dec = decryptKodikLink(link));
dec ?
dec.startsWith("https:") ?
(blobTxt += `${dec}\n`)
: (blobTxt += `https:${dec}\n`)
: null;
}
if (data.links.hasOwnProperty("1080")) {
blobTxt += "#EXT-X-STREAM-INF:RESOLUTION=1920x1080,BANDWIDTH=2560000\n";
let link = data.links["1080"][0].src;
let dec = null;
link.includes("//") ?
link.startsWith("https:") ?
(blobTxt += `${link}\n`)
: (blobTxt += `https:${link}\n`)
: (dec = decryptKodikLink(link));
dec ?
dec.startsWith("https:") ?
(blobTxt += `${dec}\n`)
: (blobTxt += `https:${dec}\n`)
: null;
} }
let file = new File([blobTxt], "manifest.m3u8", { let file = new File([blobTxt], "manifest.m3u8", {