fix(#5): update secret key fetch url

This commit is contained in:
Ritesh Ghosh
2023-11-22 13:57:57 +05:30
parent 087c1bada1
commit 5f4f7faf7e
+18 -10
View File
@@ -1,7 +1,7 @@
import axios from "axios"; import axios from "axios";
import { AES, enc as CryptojsEnc } from "crypto-js"; import CryptoJS from "crypto-js";
import { substringAfter, substringBefore } from "../utils"; import { substringAfter, substringBefore } from "../utils/index.js";
import { Video, Subtitle, Intro } from "../models/extractor"; import type { Video, Subtitle, Intro } from "../models/extractor.js";
type extractReturn = { sources: Video[]; subtitles: Subtitle[] }; type extractReturn = { sources: Video[]; subtitles: Subtitle[] };
@@ -40,7 +40,9 @@ class RapidCloud {
} = res; } = res;
let decryptKey = await ( let decryptKey = await (
await axios.get("https://github.com/enimax-anime/key/blob/e6/key.txt") await axios.get(
"https://raw.githubusercontent.com/theonlymo/keys/e1/key"
)
).data; ).data;
decryptKey = substringBefore( decryptKey = substringBefore(
@@ -51,7 +53,7 @@ class RapidCloud {
if (!decryptKey) { if (!decryptKey) {
decryptKey = await ( decryptKey = await (
await axios.get( await axios.get(
"https://raw.githubusercontent.com/enimax-anime/key/e6/key.txt" "https://raw.githubusercontent.com/theonlymo/keys/e1/key"
) )
).data; ).data;
} }
@@ -62,19 +64,24 @@ class RapidCloud {
if (encrypted) { if (encrypted) {
const sourcesArray = sources.split(""); const sourcesArray = sources.split("");
let extractedKey = ""; let extractedKey = "";
let currentIndex = 0;
for (const index of decryptKey) { for (const index of decryptKey) {
for (let i = index[0]; i < index[1]; i++) { const start = index[0] + currentIndex;
extractedKey += sources[i]; const end = start + index[1];
for (let i = start; i < end; i++) {
extractedKey += res.data.sources[i];
sourcesArray[i] = ""; sourcesArray[i] = "";
} }
currentIndex += index[1];
} }
decryptKey = extractedKey; decryptKey = extractedKey;
sources = sourcesArray.join(""); sources = sourcesArray.join("");
const decrypt = AES.decrypt(sources, decryptKey); const decrypt = CryptoJS.AES.decrypt(sources, decryptKey);
sources = JSON.parse(decrypt.toString(CryptojsEnc.Utf8)); sources = JSON.parse(decrypt.toString(CryptoJS.enc.Utf8));
} }
} catch (err: any) { } catch (err: any) {
console.log(err.message); console.log(err.message);
@@ -111,6 +118,7 @@ class RapidCloud {
return [f1, f2]; return [f1, f2];
}); });
for (const [f1, f2] of TdArray) { for (const [f1, f2] of TdArray) {
this.sources.push({ this.sources.push({
url: `${source.file?.split("master.m3u8")[0]}${f2.replace( url: `${source.file?.split("master.m3u8")[0]}${f2.replace(
@@ -123,7 +131,7 @@ class RapidCloud {
} }
result.sources.push(...this.sources); result.sources.push(...this.sources);
} }
if (intro.end > 1) { if (intro?.end > 1) {
result.intro = { result.intro = {
start: intro.start, start: intro.start,
end: intro.end, end: intro.end,