diff --git a/hdfilme/hdfilme.js b/hdfilme/hdfilme.js new file mode 100644 index 0000000..3373b41 --- /dev/null +++ b/hdfilme/hdfilme.js @@ -0,0 +1,235 @@ +async function searchResults(keyword) { + const results = []; + try { + const response = await fetchv2("https://hdfilme.blog/?story=" + keyword + "&do=search&subaction=search"); + const html = await response.text(); + + const regex = /]*>\s*]*>\s*]+src="([^"]+)"[^>]*>\s*[\s\S]*?]*>([^<]+)<\/h3>/g; + let match; + + while ((match = regex.exec(html)) !== null) { + results.push({ + title: match[3].trim(), + image: match[2].trim().startsWith("http") ? match[2].trim() : "https://hdfilme.blog" + match[2].trim(), + href: match[1].trim() + }); + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ + title: "Error", + image: "Error", + href: "Error" + }]); + } +} + +async function extractDetails(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + const match = html.match(/
([\s\S]*?)<\/div>/); + const description = match + ? match[1].replace(/<[^>]+>/g, "").trim() + : "N/A"; + + return JSON.stringify([{ + description: description, + aliases: "N/A", + airdate: "N/A" + }]); + } catch (err) { + return JSON.stringify([{ + description: "Error", + aliases: "Error", + airdate: "Error" + }]); + } +} + +async function extractEpisodes(url) { + const results = []; + try { + const response = await fetchv2(url); + const html = await response.text(); + + const seasonRegex = /Staffel\s+(\d+)([\s\S]*?)(?=
|$)/g; + let seasonMatch; + + while ((seasonMatch = seasonRegex.exec(html)) !== null) { + const seasonNumber = parseInt(seasonMatch[1], 10); + const seasonContent = seasonMatch[2]; + + const episodeRegex = /href="(https:\/\/supervideo\.tv\/[^"]+)"/g; + let episodeMatch; + let episodeNumber = 1; + + while ((episodeMatch = episodeRegex.exec(seasonContent)) !== null) { + results.push({ + number: episodeNumber, + href: episodeMatch[1].replace("https://supervideo.tv", "https://supervideo.cc").trim() + }); + episodeNumber++; + } + } + + if (results.length === 0) { + const playerMatch = html.match(/
]*>]+src="([^"]+)"/); + if (playerMatch) { + const playerUrl = playerMatch[1]; + + const playerResponse = await fetchv2(playerUrl); + const playerHtml = await playerResponse.text(); + + const mirrorRegex = /]*data-link="([^"]+)"[^>]*>[\s\S]*?<\/li>/g; + let mirrorMatch; + + while ((mirrorMatch = mirrorRegex.exec(playerHtml)) !== null) { + let link = mirrorMatch[1].trim(); + + if (link.includes("supervideo")) { + if (link.startsWith("//")) { + link = "https:" + link; + } + results.push({ + number: 1, + href: link + }); + break; + } + } + } + } + + return JSON.stringify(results); + } catch (err) { + return JSON.stringify([{ href: "Error", number: "Error" }]); + } +} + +async function extractStreamUrl(url) { + try { + const response = await fetchv2(url); + const html = await response.text(); + + const obfuscatedScript = html.match(/]*>\s*(eval\(function\(p,a,c,k,e,d.*?\)[\s\S]*?)<\/script>/); + if (obfuscatedScript) { + const unpackedScript = unpack(obfuscatedScript[1]); + console.log(unpackedScript); + const hlsMatch = unpackedScript.match(/file:"([^"]*\.m3u8[^"]*)"/); + if (hlsMatch) { + return hlsMatch[1]; + } + } + + return "https://error.org/"; + } catch (err) { + console.error("Error extracting stream URL:", err); + return "https://error.org/"; + } +} + +/* + * DEOBFUSCATOR CODE + * + * Copy the below code fully and paste it in your + * code. No need to modify anything. + */ + +class Unbaser { + constructor(base) { + this.ALPHABET = { + 62: "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", + 95: "' !\"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'", + }; + this.dictionary = {}; + this.base = base; + if (36 < base && base < 62) { + this.ALPHABET[base] = this.ALPHABET[base] || + this.ALPHABET[62].substr(0, base); + } + if (2 <= base && base <= 36) { + this.unbase = (value) => parseInt(value, base); + } + else { + try { + [...this.ALPHABET[base]].forEach((cipher, index) => { + this.dictionary[cipher] = index; + }); + } + catch (er) { + throw Error("Unsupported base encoding."); + } + this.unbase = this._dictunbaser; + } + } + _dictunbaser(value) { + let ret = 0; + [...value].reverse().forEach((cipher, index) => { + ret = ret + ((Math.pow(this.base, index)) * this.dictionary[cipher]); + }); + return ret; + } +} + +function detect(source) { + return source.replace(" ", "").startsWith("eval(function(p,a,c,k,e,"); +} + +function unpack(source) { + let { payload, symtab, radix, count } = _filterargs(source); + if (count != symtab.length) { + throw Error("Malformed p.a.c.k.e.r. symtab."); + } + let unbase; + try { + unbase = new Unbaser(radix); + } + catch (e) { + throw Error("Unknown p.a.c.k.e.r. encoding."); + } + function lookup(match) { + const word = match; + let word2; + if (radix == 1) { + word2 = symtab[parseInt(word)]; + } + else { + word2 = symtab[unbase.unbase(word)]; + } + return word2 || word; + } + source = payload.replace(/\b\w+\b/g, lookup); + return _replacestrings(source); + function _filterargs(source) { + const juicers = [ + /}\('(.*)', *(\d+|\[\]), *(\d+), *'(.*)'\.split\('\|'\), *(\d+), *(.*)\)\)/, + /}\('(.*)', *(\d+|\[\]), *(\d+), *'(.*)'\.split\('\|'\)/, + ]; + for (const juicer of juicers) { + const args = juicer.exec(source); + if (args) { + let a = args; + if (a[2] == "[]") { + } + try { + return { + payload: a[1], + symtab: a[4].split("|"), + radix: parseInt(a[2]), + count: parseInt(a[3]), + }; + } + catch (ValueError) { + throw Error("Corrupted p.a.c.k.e.r. data."); + } + } + } + throw Error("Could not make sense of p.a.c.k.e.r data (unexpected code structure)"); + } + function _replacestrings(source) { + return source; + } +}