mirror of
https://github.com/Inside4ndroid/TMDB-Embed-API.git
synced 2026-10-22 09:35:11 +00:00
fixed 2embed issue.
This commit is contained in:
@@ -213,7 +213,11 @@ async function resolve(url, referer) {
|
|||||||
|
|
||||||
await parseSubs(unpackedJS);
|
await parseSubs(unpackedJS);
|
||||||
|
|
||||||
const fileRegex = /sources\s*:\s*\[\s*\{\s*file\s*:\s*"([^"]+)"/;
|
const docheck = unpackedJS.includes("\"hls2\":\"https");
|
||||||
|
|
||||||
|
if (docheck) {
|
||||||
|
const fileRegex = /links=.*hls2\":\"(.*?)\"};/;
|
||||||
|
|
||||||
const matchUri = unpackedJS.match(fileRegex);
|
const matchUri = unpackedJS.match(fileRegex);
|
||||||
|
|
||||||
if (matchUri && matchUri[1]) {
|
if (matchUri && matchUri[1]) {
|
||||||
@@ -222,6 +226,20 @@ async function resolve(url, referer) {
|
|||||||
console.error("Could not find file URL in unpacked JS");
|
console.error("Could not find file URL in unpacked JS");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
const fileRegex = /sources\s*:\s*\[\s*\{\s*file\s*:\s*"([^"]+)"/;
|
||||||
|
|
||||||
|
const matchUri = unpackedJS.match(fileRegex);
|
||||||
|
|
||||||
|
if (matchUri && matchUri[1]) {
|
||||||
|
return matchUri[1];
|
||||||
|
} else {
|
||||||
|
console.error("Could not find file URL in unpacked JS");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.error("JsUnpacker could not detect packed data in resolve response");
|
console.error("JsUnpacker could not detect packed data in resolve response");
|
||||||
return null;
|
return null;
|
||||||
@@ -302,22 +320,52 @@ async function parseSubs(scriptstring) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const setupMatch = scriptstring.match(/jwplayer\([\s\S]*?\)\.setup\((\{[\s\S]*?\})\)/);
|
// First extract the links object from the script
|
||||||
|
const linksMatch = scriptstring.match(/var links\s*=\s*({[^;]*});/);
|
||||||
|
if (!linksMatch) {
|
||||||
|
console.error("Could not find links object in script");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let linksStr = linksMatch[1]
|
||||||
|
.replace(/'/g, '"') // Replace single quotes with double quotes for JSON
|
||||||
|
.replace(/([{,]\s*)([a-zA-Z0-9_$]+)(\s*:)/g, '$1"$2"$3'); // Ensure proper JSON keys
|
||||||
|
|
||||||
|
const links = JSON.parse(linksStr);
|
||||||
|
const videoUrl = links.hls2; // Use hls2 as fallback if hls4 doesn't exist
|
||||||
|
|
||||||
|
// Now extract the JWPlayer setup configuration
|
||||||
|
const setupMatch = scriptstring.match(/jwplayer\(["']vplayer["']\)\.setup\((\{[\s\S]*?\})\);[\s\S]*?$/);
|
||||||
if (!setupMatch || !setupMatch[1]) {
|
if (!setupMatch || !setupMatch[1]) {
|
||||||
|
console.error("Could not find JWPlayer setup configuration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let setupStr = setupMatch[1];
|
let setupStr = setupMatch[1];
|
||||||
|
|
||||||
setupStr = setupStr.replace(/\\'/g, "'");
|
// Replace JavaScript expressions with actual values
|
||||||
setupStr = setupStr.replace(/'/g, '"');
|
setupStr = setupStr.replace(/links\.hls4\s*\|\|\s*links\.hls2/g, `"${videoUrl}"`);
|
||||||
setupStr = setupStr.replace(/([{,]\s*)([a-zA-Z0-9_$]+)(\s*:)/g, '$1"$2"$3');
|
|
||||||
setupStr = setupStr.replace(/,\s*([}\]])/g, '$1');
|
// Clean the string for JSON parsing
|
||||||
|
setupStr = setupStr
|
||||||
|
.replace(/\\'/g, "'")
|
||||||
|
.replace(/([{,]\s*)([a-zA-Z0-9_$]+)(\s*:)/g, '$1"$2"$3')
|
||||||
|
.replace(/'/g, '"')
|
||||||
|
.replace(/,\s*([}\]])/g, '$1')
|
||||||
|
.replace(/"true"/g, 'true')
|
||||||
|
.replace(/"false"/g, 'false')
|
||||||
|
.replace(/"null"/g, 'null');
|
||||||
|
|
||||||
let setupConfig;
|
let setupConfig;
|
||||||
try {
|
try {
|
||||||
setupConfig = JSON.parse(setupStr);
|
setupConfig = JSON.parse(setupStr);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
console.error("JSON parse error:", err, "in string:", setupStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!setupConfig.tracks) {
|
||||||
|
console.log("No tracks found in setup configuration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user