push
This commit is contained in:
1 parent
bcf05e8063
commit
f37985b4c8
109 files changed
+22810
-6143
No files matched your search
+846
-1
@@ -1 +1,846 @@
|
||||
function _0x1d41(){const _0x4db01a=['zw5J','n1nlz1L4BW','Cg9ZDf90AhvTyM5HAwW','mtK5nZj3s3fituK','Ahr0Chm6lY9UzxCXlMHKAhvInhuUy2W','DgL0Bgu','mtbqEM54yNi','y2HHCKf0','ChvZAa','Ahr0Chm6lY9HCgKUDgHLBw92AwvKyI5VCMCVmW','Ahr0Chm6lY9YyxCUz2L0AhvIDxnLCMnVBNrLBNqUy29Tl3bOAxnOzxi5oc9uvLzwvI9YzwzZl2HLywrZl21HAw4Vzg9TywLUCY5QC29U','yM9KEq','ndm5yZq3oge3nZfMmZvJmduWmJjMowzLywjJy2eWmwm','p2LKpq','CJiUzgv2','zwfJAa','BwvZC2fNzq','zMLUza','zMLYC3rFywLYx2rHDgu','DxjS','CgL4zwXKCMe','w0HeshvInhvDifrnreiGsw5MBZOGiG','C3rHDhvZvgv4Da','qNL0zxm','mZC5oduXB1z0Bwvf','i2rVD25SB2fK','ieHIBgLUA3m','Dgv4Da','lNPPCa','ttnvoa','seriDwi0Dsa','w0HeshvInhvDiezLDgnOAw5Nihn0CMvHBxmGzM9YifrnreiGsuq6ia','jMfWCgvUzf90B19YzxnWB25Zzt1LEhrLCM5HBf9Pzhm','ywXS','vw5RBM93BG','qvzd','ChjVDg9JB2W','AduGysWGAdqGysWGAdmGyq','sgv4','CgvYBwfSAw5R','C3rHCNrZv2L0Aa','C3bSAxq','q0fn','AM9PBG','BM93','mtu2odaWmdDdugDQq3e','AgrZDhjLyw00Dq','v0vcuKLq','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9Y','C291CMnL','zMLSzu5HBwu','mZu3mJGZmgz6u1nLqG','Aw1KyL9Pza','Ahr0Chm6lY9ZzwfYy2GUCgLUz29Yys5MEwKVy29SBgvJDgLVBNmVCg9ZDc9KB2n1BwvUDhmVC2vHCMnOp3e9','BwfNBMv0oG','DMfSDwu','Ahr0Ca','EMLWzgLZAW','y3j5ChrVAw5ZAwDODhmUC2L0zq','z2v0','AgfZ','AgfZt3DUuhjVCgvYDhK','sdi2nq','BMv4Da','EwvHCG','w0HeshvInhvDiejLC3qGDgL0BguGBwf0y2G6ici','nZiWCa','iIaO','nJyWmdy0ogLmC0r3vG','p2rVD25SB2fK','lNbHz2uTyM9KEsa+igrPDIbH','u3rYzwfTvgfWzq','sfGTuMvKAxjLy3q','DhjPBq','BwfW','v0vclurm','re9mqLLwsvnjt04','wMLWrgLZAYbtzxj2zxi','shvIq2XVDwqGlsbgu0W','zMXHDa','AhvIy2XVDwqUy3G','w0HeshvInhvDiezHAwXLzcb0BYbMzxrJAcbSyxrLC3qGzg9TywLUCZOG','mdeYmZq1nJC4owfIy2rLzG','C3vIC3rYAw5N','y2HLzxjPBY13AxrOB3v0lw5VzguTBMf0AxzL','DgHYB3C','BgLUAZ0','A2LLBxrPzw5TDwe5mtfJyq','qufd','Cg9ZDf90AxrSzq','shvIq2rU','ChjVCgvYDhLjC0vUDw1LCMfIBgu','BNvTyMvY','ywrK','zNjVBunOyxjdB2rL','ihrVia','serivui0Dq','CxvHBgL0Eq','q0jd','shvIq2XVDwqGlsaXmeDIChmG','CMvWBgfJzq','Dg9mB3DLCKnHC2u','EgXHpxm0Da','qujdrevgr0HjsKTmtu5puffsu1rvvLDywvPHyMnKzwzNAgLQA2XTBM9WCxjZDhv2D3H5EJaXmJm0nty3odKRlZ0','mtu4mda0nhn6yMLUra','x19LC01VzhvSzq','Bwf0y2G','AgL0CW','sgjmAw5RCW','Cg9W','l2rVD25SB2fK','CgfYC2u','zxbPC29Kzq','C29Tzq','Bg9N','z2v0t3DUuhjVCgvYDhLtEw1IB2XZ','BgfZDeLUzgv4t2y','mJiZnJq1oeHyBwv5BW','zgvMAw5LuhjVCgvYDhK','CMvZB2X2zq','zNvUy3rPB24','C2v0','zgvMyxvSDa','rgLYzwn0ifiY','z2v0t3DUuhjVCgvYDhLoyw1LCW','ChjVDg90ExbL','uMvMzxjLCG','C3rHDhvZ','AhGTCMvKAxjLy3q','Aw5JBhvKzxm','AdeUCgfNzs10AxrSzsbZCgfU','CMv1CMW','AsnZAxPL','qLjssva','CZmGC2vYDMvY','w0HeshvInhvDifnLBgvJDgvKoIaI','y2fSBa','ifnLyxnVBIa','mta4mha','yMXVz191CMW','iIaOC2nVCMu6ia','AhvIy2XVDwqUAw5R','mtiZndu2nZG5mg9PDxL0CG','AhrTBa','C3rYAw5N','CMvSzwfZzv9KyxrL','C2L6zq','DgvJAhLIB3K0Dq','l2fWAs92ms92AwrLBZ9Pzd0','C2vHC29Uia','C3rYzwfTDgfWzs5JB20','zw51BwvYywjSzq','lcbuExbLoIa','yxr0CG','shvIq2XVDwq','BgvUz3rO','AhjLzG','vxrMoa','zgvMAw5LuhjVCgvYDgLLCW','tw96AwXSys81lJaGkfDPBMrVD3mGtLqGmtaUmdSGv2LUnJq7ihG2ncKGqxbWBgvxzwjlAxqVntm3lJm2','zNnSDJi','z2v0t3DUuhjVCgvYDhLezxnJCMLWDg9YCW','zNnSihnLCNzLCG','zxHWB3j0CW','Bw92Awu','AdmGysWGAdqGyq','zgf0yq','z2fKz2v0C3DLyI54ExO','tw96AwXSys81lJa','Dg9tDhjPBMC','ugL4zwXKCMfPBG','Ag9ZDg5HBwu','AhvIy2rU','AgrODwi0Dq','sdi2na','BwfUDwfS','Dg9vChbLCKnHC2u','rfrt','BMfTzq','zMLSDgvY','zxHLyW','wMLWrgLZAYbtzxj2zxiG','sgrtDhjLyw00Dq','Bg9Hza','B2jQzwn0','p2fWAv9RzxK9','r0vu','AgvHzgvYCW','neTsywD4ua','zxH0zxjUywXFAwrZ','Cg93','CgfKu3rHCNq','shvIC3rYzwfT','Bg9JyxrPB24','zMLUywXmAw5RCW'];_0x1d41=function(){return _0x4db01a;};return _0x1d41();}const _0x4cfe8c=_0x1850;(function(_0x4bd1e8,_0x326e94){const _0x3f3482={_0x2ebcc9:0xb1,_0x1082ec:0xe1,_0x1f3a99:0xaf,_0xdb40a:0xb4},_0x432f61=_0x1850,_0x252534=_0x4bd1e8();while(!![]){try{const _0x7c34e9=-parseInt(_0x432f61(_0x3f3482._0x2ebcc9))/0x1+-parseInt(_0x432f61(0x116))/0x2+parseInt(_0x432f61(0xc6))/0x3+parseInt(_0x432f61(0x16a))/0x4*(parseInt(_0x432f61(_0x3f3482._0x1082ec))/0x5)+-parseInt(_0x432f61(0x123))/0x6*(parseInt(_0x432f61(_0x3f3482._0x1f3a99))/0x7)+-parseInt(_0x432f61(0xf2))/0x8+parseInt(_0x432f61(0xdb))/0x9*(parseInt(_0x432f61(_0x3f3482._0xdb40a))/0xa);if(_0x7c34e9===_0x326e94)break;else _0x252534['push'](_0x252534['shift']());}catch(_0x3cc61a){_0x252534['push'](_0x252534['shift']());}}}(_0x1d41,0x8c864));var __create=Object['create'],__defProp=Object[_0x4cfe8c(0x124)],__defProps=Object[_0x4cfe8c(0x14c)],__getOwnPropDesc=Object[_0x4cfe8c(0xde)],__getOwnPropDescs=Object[_0x4cfe8c(0x14f)],__getOwnPropNames=Object[_0x4cfe8c(0x12a)],__getOwnPropSymbols=Object[_0x4cfe8c(0x121)],__getProtoOf=Object['getPrototypeOf'],__hasOwnProp=Object['prototype'][_0x4cfe8c(0xeb)],__propIsEnum=Object[_0x4cfe8c(0x12b)][_0x4cfe8c(0x109)],__defNormalProp=(_0x88bbc8,_0x59e2f6,_0x38ec05)=>_0x59e2f6 in _0x88bbc8?__defProp(_0x88bbc8,_0x59e2f6,{'enumerable':!![],'configurable':!![],'writable':!![],'value':_0x38ec05}):_0x88bbc8[_0x59e2f6]=_0x38ec05,__spreadValues=(_0x586ac9,_0x243eff)=>{const _0x3d2fc4=_0x4cfe8c;for(var _0x4d4ed6 in _0x243eff||(_0x243eff={}))if(__hasOwnProp['call'](_0x243eff,_0x4d4ed6))__defNormalProp(_0x586ac9,_0x4d4ed6Line truncated
|
||||
/**
|
||||
* hdhub4u - Built from src/hdhub4u/
|
||||
* Generated: 2026-10-02T12:34:10.590Z
|
||||
*/
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __defProps = Object.defineProperties;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
||||
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
||||
var __spreadValues = (a, b) => {
|
||||
for (var prop in b || (b = {}))
|
||||
if (__hasOwnProp.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
if (__getOwnPropSymbols)
|
||||
for (var prop of __getOwnPropSymbols(b)) {
|
||||
if (__propIsEnum.call(b, prop))
|
||||
__defNormalProp(a, prop, b[prop]);
|
||||
}
|
||||
return a;
|
||||
};
|
||||
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
||||
// If the importer is in node compatibility mode or this is not an ESM
|
||||
// file that has been converted to a CommonJS file using a Babel-
|
||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
||||
mod
|
||||
));
|
||||
var __async = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
|
||||
// src/hdhub4u/index.js
|
||||
var import_cheerio_without_node_native2 = __toESM(require("cheerio-without-node-native"));
|
||||
|
||||
// src/hdhub4u/constants.js
|
||||
var TMDB_API_KEY = "439c478a771f35c05022f9feabcca01c";
|
||||
var TMDB_BASE_URL = "https://api.themoviedb.org/3";
|
||||
var MAIN_URL = "https://new6.hdhub4u.cl";
|
||||
var DOMAINS_URL = "https://raw.githubusercontent.com/phisher98/TVVVV/refs/heads/main/domains.json";
|
||||
var DOMAIN_CACHE_TTL = 4 * 60 * 60 * 1e3;
|
||||
var HEADERS = {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0",
|
||||
"Cookie": "xla=s4t",
|
||||
"Referer": `${MAIN_URL}/`
|
||||
};
|
||||
function updateMainUrl(url) {
|
||||
MAIN_URL = url;
|
||||
HEADERS.Referer = `${url}/`;
|
||||
}
|
||||
|
||||
// src/hdhub4u/utils.js
|
||||
var domainCacheTimestamp = 0;
|
||||
function formatBytes(bytes) {
|
||||
if (!bytes || bytes === 0)
|
||||
return "Unknown";
|
||||
const k = 1024;
|
||||
const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(1)) + " " + sizes[i];
|
||||
}
|
||||
function extractServerName(source) {
|
||||
if (!source)
|
||||
return "Unknown";
|
||||
if (source.startsWith("HubCloud")) {
|
||||
const serverMatch = source.match(/HubCloud(?:\s*-\s*([^[\]]+))?/);
|
||||
return serverMatch ? serverMatch[1] || "Download" : "HubCloud";
|
||||
}
|
||||
if (source.startsWith("Pixeldrain"))
|
||||
return "Pixeldrain";
|
||||
if (source.startsWith("StreamTape"))
|
||||
return "StreamTape";
|
||||
if (source.startsWith("HubCdn"))
|
||||
return "HubCdn";
|
||||
if (source.startsWith("HbLinks"))
|
||||
return "HbLinks";
|
||||
if (source.startsWith("Hubstream"))
|
||||
return "Hubstream";
|
||||
return source.replace(/^www\./, "").split(".")[0];
|
||||
}
|
||||
function rot13(value) {
|
||||
return value.replace(/[a-zA-Z]/g, function(c) {
|
||||
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
||||
});
|
||||
}
|
||||
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
function atob(value) {
|
||||
if (!value)
|
||||
return "";
|
||||
let input = String(value).replace(/=+$/, "");
|
||||
let output = "";
|
||||
let bc = 0, bs, buffer, idx = 0;
|
||||
while (buffer = input.charAt(idx++)) {
|
||||
buffer = BASE64_CHARS.indexOf(buffer);
|
||||
if (~buffer) {
|
||||
bs = bc % 4 ? bs * 64 + buffer : buffer;
|
||||
if (bc++ % 4) {
|
||||
output += String.fromCharCode(255 & bs >> (-2 * bc & 6));
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
function cleanTitle(title) {
|
||||
let name = title.replace(/\.[a-zA-Z0-9]{2,4}$/, "");
|
||||
const normalized = name.replace(/WEB[-_. ]?DL/gi, "WEB-DL").replace(/WEB[-_. ]?RIP/gi, "WEBRIP").replace(/H[ .]?265/gi, "H265").replace(/H[ .]?264/gi, "H264").replace(/DDP[ .]?([0-9]\.[0-9])/gi, "DDP$1");
|
||||
const parts = normalized.split(/[\s_.]/);
|
||||
const sourceTags = /* @__PURE__ */ new Set(["WEB-DL", "WEBRIP", "BLURAY", "HDRIP", "DVDRIP", "HDTV", "CAM", "TS", "BRRIP", "BDRIP"]);
|
||||
const codecTags = /* @__PURE__ */ new Set(["H264", "H265", "X264", "X265", "HEVC", "AVC"]);
|
||||
const audioTags = ["AAC", "AC3", "DTS", "MP3", "FLAC", "DD", "DDP", "EAC3"];
|
||||
const audioExtras = /* @__PURE__ */ new Set(["ATMOS"]);
|
||||
const hdrTags = /* @__PURE__ */ new Set(["SDR", "HDR", "HDR10", "HDR10+", "DV", "DOLBYVISION"]);
|
||||
const filtered = parts.map((part) => {
|
||||
const p = part.toUpperCase();
|
||||
if (sourceTags.has(p))
|
||||
return p;
|
||||
if (codecTags.has(p))
|
||||
return p;
|
||||
if (audioTags.some((tag) => p.startsWith(tag)))
|
||||
return p;
|
||||
if (audioExtras.has(p))
|
||||
return p;
|
||||
if (hdrTags.has(p))
|
||||
return p === "DOLBYVISION" || p === "DV" ? "DOLBYVISION" : p;
|
||||
if (p === "NF" || p === "CR")
|
||||
return p;
|
||||
return null;
|
||||
}).filter(Boolean);
|
||||
return [...new Set(filtered)].join(" ");
|
||||
}
|
||||
function fetchAndUpdateDomain() {
|
||||
return __async(this, null, function* () {
|
||||
const now = Date.now();
|
||||
if (now - domainCacheTimestamp < DOMAIN_CACHE_TTL)
|
||||
return;
|
||||
console.log("[HDHub4u] Fetching latest domain...");
|
||||
try {
|
||||
const response = yield fetch(DOMAINS_URL, {
|
||||
method: "GET",
|
||||
headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" }
|
||||
});
|
||||
if (response.ok) {
|
||||
const data = yield response.json();
|
||||
if (data && data.HDHUB4u) {
|
||||
const newDomain = data.HDHUB4u;
|
||||
if (newDomain !== MAIN_URL) {
|
||||
console.log(`[HDHub4u] Updating domain from ${MAIN_URL} to ${newDomain}`);
|
||||
updateMainUrl(newDomain);
|
||||
domainCacheTimestamp = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`[HDHub4u] Failed to fetch latest domains: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function getCurrentDomain() {
|
||||
return __async(this, null, function* () {
|
||||
yield fetchAndUpdateDomain();
|
||||
return MAIN_URL;
|
||||
});
|
||||
}
|
||||
function normalizeTitle(title) {
|
||||
if (!title)
|
||||
return "";
|
||||
return title.toLowerCase().replace(/\b(the|a|an)\b/g, "").replace(/[:\-_]/g, " ").replace(/\s+/g, " ").replace(/[^\w\s]/g, "").trim();
|
||||
}
|
||||
function calculateTitleSimilarity(title1, title2) {
|
||||
const norm1 = normalizeTitle(title1);
|
||||
const norm2 = normalizeTitle(title2);
|
||||
if (norm1 === norm2)
|
||||
return 1;
|
||||
const words1 = norm1.split(/\s+/).filter((w) => w.length > 0);
|
||||
const words2 = norm2.split(/\s+/).filter((w) => w.length > 0);
|
||||
if (words1.length === 0 || words2.length === 0)
|
||||
return 0;
|
||||
const set1 = new Set(words1);
|
||||
const set2 = new Set(words2);
|
||||
const intersection = words1.filter((w) => set2.has(w));
|
||||
const union = /* @__PURE__ */ new Set([...words1, ...words2]);
|
||||
const jaccard = intersection.length / union.size;
|
||||
const extraWordsCount = words2.filter((w) => !set1.has(w)).length;
|
||||
let score = jaccard - extraWordsCount * 0.05;
|
||||
if (words1.length > 0 && words1.every((w) => set2.has(w))) {
|
||||
score += 0.2;
|
||||
}
|
||||
return score;
|
||||
}
|
||||
function findBestTitleMatch(mediaInfo, searchResults, mediaType, season) {
|
||||
if (!searchResults || searchResults.length === 0)
|
||||
return null;
|
||||
let bestMatch = null;
|
||||
let bestScore = 0;
|
||||
for (const result of searchResults) {
|
||||
let score = calculateTitleSimilarity(mediaInfo.title, result.title);
|
||||
if (mediaInfo.year && result.year) {
|
||||
const yearDiff = Math.abs(mediaInfo.year - result.year);
|
||||
if (yearDiff === 0)
|
||||
score += 0.2;
|
||||
else if (yearDiff <= 1)
|
||||
score += 0.1;
|
||||
else if (yearDiff > 5)
|
||||
score -= 0.3;
|
||||
}
|
||||
if (mediaType === "tv" && season) {
|
||||
const titleLower = result.title.toLowerCase();
|
||||
const seasonPatterns = [
|
||||
`season ${season}`,
|
||||
`s${season}`,
|
||||
`season ${season.toString().padStart(2, "0")}`,
|
||||
`s${season.toString().padStart(2, "0")}`
|
||||
];
|
||||
const hasSeason = seasonPatterns.some((p) => titleLower.includes(p));
|
||||
const otherSeasonMatch = titleLower.match(/season\s*(\d+)|s(\d+)/i);
|
||||
if (otherSeasonMatch) {
|
||||
const foundSeason = parseInt(otherSeasonMatch[1] || otherSeasonMatch[2]);
|
||||
if (foundSeason !== season) {
|
||||
score -= 0.8;
|
||||
}
|
||||
}
|
||||
if (hasSeason)
|
||||
score += 0.5;
|
||||
else
|
||||
score -= 0.3;
|
||||
}
|
||||
if (result.title.toLowerCase().includes("2160p") || result.title.toLowerCase().includes("4k")) {
|
||||
score += 0.05;
|
||||
}
|
||||
if (score > bestScore && score > 0.3) {
|
||||
bestScore = score;
|
||||
bestMatch = result;
|
||||
}
|
||||
}
|
||||
if (bestMatch)
|
||||
console.log(`[HDHub4u] Best title match: "${bestMatch.title}" (score: ${bestScore.toFixed(2)})`);
|
||||
return bestMatch;
|
||||
}
|
||||
function getTMDBDetails(tmdbId, mediaType) {
|
||||
return __async(this, null, function* () {
|
||||
var _a;
|
||||
const endpoint = mediaType === "tv" ? "tv" : "movie";
|
||||
const url = `${TMDB_BASE_URL}/${endpoint}/${tmdbId}?api_key=${TMDB_API_KEY}&append_to_response=external_ids`;
|
||||
const response = yield fetch(url, {
|
||||
method: "GET",
|
||||
headers: { "Accept": "application/json", "User-Agent": "Mozilla/5.0" }
|
||||
});
|
||||
if (!response.ok)
|
||||
throw new Error(`TMDB API error: ${response.status}`);
|
||||
const data = yield response.json();
|
||||
const title = mediaType === "tv" ? data.name : data.title;
|
||||
const releaseDate = mediaType === "tv" ? data.first_air_date : data.release_date;
|
||||
const year = releaseDate ? parseInt(releaseDate.split("-")[0]) : null;
|
||||
return { title, year, imdbId: ((_a = data.external_ids) == null ? void 0 : _a.imdb_id) || null };
|
||||
});
|
||||
}
|
||||
|
||||
// src/hdhub4u/extractors.js
|
||||
var import_cheerio_without_node_native = __toESM(require("cheerio-without-node-native"));
|
||||
var import_crypto_js = __toESM(require("crypto-js"));
|
||||
function getRedirectLinks(url) {
|
||||
return __async(this, null, function* () {
|
||||
try {
|
||||
const response = yield fetch(url, { headers: HEADERS });
|
||||
if (!response.ok)
|
||||
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
||||
const doc = yield response.text();
|
||||
const regex = /s\s*\(\s*['"]o['"]\s*,\s*['"]([A-Za-z0-9+/=]+)['"]|ck\s*\(\s*['"]_wp_http_\d+['"]\s*,\s*['"]([^'"]+)['"]/g;
|
||||
let combinedString = "";
|
||||
let match;
|
||||
while ((match = regex.exec(doc)) !== null) {
|
||||
const extractedValue = match[1] || match[2];
|
||||
if (extractedValue)
|
||||
combinedString += extractedValue;
|
||||
}
|
||||
if (!combinedString) {
|
||||
const redirectMatch = doc.match(/window\.location\.href\s*=\s*['"]([^'"]+)['"]/);
|
||||
if (redirectMatch && redirectMatch[1]) {
|
||||
const newUrl = redirectMatch[1];
|
||||
if (newUrl !== url && !newUrl.includes(url)) {
|
||||
return yield getRedirectLinks(newUrl);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const decodedString = atob(rot13(atob(atob(combinedString))));
|
||||
const jsonObject = JSON.parse(decodedString);
|
||||
const encodedUrl = atob(jsonObject.o || "").trim();
|
||||
if (encodedUrl)
|
||||
return encodedUrl;
|
||||
const data = atob(jsonObject.data || "").trim();
|
||||
const wpHttp = (jsonObject.blog_url || "").trim();
|
||||
if (wpHttp && data) {
|
||||
const directLinkResponse = yield fetch(`${wpHttp}?re=${data}`, { headers: HEADERS });
|
||||
const html = yield directLinkResponse.text();
|
||||
const $ = import_cheerio_without_node_native.default.load(html);
|
||||
return ($("body").text() || html).trim();
|
||||
}
|
||||
return null;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
function vidStackExtractor(url) {
|
||||
return __async(this, null, function* () {
|
||||
var _a, _b, _c;
|
||||
try {
|
||||
const hash = url.split("#").pop().split("/").pop();
|
||||
const baseUrl = new URL(url).origin;
|
||||
const apiUrl = `${baseUrl}/api/v1/video?id=${hash}`;
|
||||
const response = yield fetch(apiUrl, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: url }) });
|
||||
const encoded = (yield response.text()).trim();
|
||||
const key = import_crypto_js.default.enc.Utf8.parse("kiemtienmua911ca");
|
||||
const ivs = ["1234567890oiuytr", "0123456789abcdef"];
|
||||
for (const ivStr of ivs) {
|
||||
try {
|
||||
const iv = import_crypto_js.default.enc.Utf8.parse(ivStr);
|
||||
const decrypted = import_crypto_js.default.AES.decrypt(
|
||||
{ ciphertext: import_crypto_js.default.enc.Hex.parse(encoded) },
|
||||
key,
|
||||
{ iv, mode: import_crypto_js.default.mode.CBC, padding: import_crypto_js.default.pad.Pkcs7 }
|
||||
);
|
||||
const decryptedText = decrypted.toString(import_crypto_js.default.enc.Utf8);
|
||||
if (decryptedText && decryptedText.includes("source")) {
|
||||
const m3u8 = (_b = (_a = decryptedText.match(/"source":"(.*?)"/)) == null ? void 0 : _a[1]) == null ? void 0 : _b.replace(/\\/g, "");
|
||||
const subtitles = [];
|
||||
const subtitleSection = (_c = decryptedText.match(/"subtitle":\{(.*?)\}/)) == null ? void 0 : _c[1];
|
||||
if (subtitleSection) {
|
||||
const subtitlePattern = /"([^"]+)":\s*"([^"]+)"/g;
|
||||
let subMatch;
|
||||
while ((subMatch = subtitlePattern.exec(subtitleSection)) !== null) {
|
||||
const lang = subMatch[1];
|
||||
const subPath = subMatch[2].split("#")[0].replace(/\\/g, "");
|
||||
if (subPath) {
|
||||
subtitles.push({
|
||||
language: lang,
|
||||
url: subPath.startsWith("http") ? subPath : `${baseUrl}${subPath}`
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (m3u8) {
|
||||
return [{
|
||||
source: "Vidstack Hubstream",
|
||||
quality: "M3U8",
|
||||
url: m3u8.replace("https:", "http:"),
|
||||
headers: {
|
||||
"Referer": url,
|
||||
"Origin": url.split("/").pop()
|
||||
},
|
||||
subtitles
|
||||
}];
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
function hbLinksExtractor(url) {
|
||||
return __async(this, null, function* () {
|
||||
try {
|
||||
const response = yield fetch(url, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: url }) });
|
||||
const data = yield response.text();
|
||||
const $ = import_cheerio_without_node_native.default.load(data);
|
||||
const links = [...new Set($("h3 a, h5 a, div.entry-content p a, div.entry-content a").map((i, el) => $(el).attr("href")).get().filter(Boolean))];
|
||||
const results = yield Promise.all(links.map((l) => loadExtractor(l, url)));
|
||||
return results.flat().map((link) => __spreadProps(__spreadValues({}, link), {
|
||||
source: `${link.source} Hblinks`
|
||||
}));
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
function pixelDrainExtractor(link) {
|
||||
return __async(this, null, function* () {
|
||||
var _a;
|
||||
try {
|
||||
const urlObj = new URL(link);
|
||||
const baseUrl = `${urlObj.protocol}//${urlObj.hostname}`;
|
||||
const fileId = ((_a = link.match(/(?:file|u)\/([A-Za-z0-9]+)/)) == null ? void 0 : _a[1]) || link.split("/").pop();
|
||||
if (!fileId)
|
||||
return [{ source: "Pixeldrain", quality: 0, url: link }];
|
||||
const finalUrl = link.includes("?download") ? link : `${baseUrl}/api/file/${fileId}?download`;
|
||||
return [{ source: "Pixeldrain", quality: 0, url: finalUrl }];
|
||||
} catch (e) {
|
||||
return [{ source: "Pixeldrain", quality: 0, url: link }];
|
||||
}
|
||||
});
|
||||
}
|
||||
function streamTapeExtractor(link) {
|
||||
return __async(this, null, function* () {
|
||||
var _a, _b, _c, _d;
|
||||
try {
|
||||
const url = new URL(link);
|
||||
url.hostname = "streamtape.com";
|
||||
const res = yield fetch(url.toString(), { headers: HEADERS });
|
||||
const data = yield res.text();
|
||||
let videoSrc = (_c = (_b = (_a = data.match(/document\.getElementById\('videolink'\)\.innerHTML = (.*?);/)) == null ? void 0 : _a[1]) == null ? void 0 : _b.match(/'(\/\/streamtape\.com\/get_video[^']+)'/)) == null ? void 0 : _c[1];
|
||||
if (!videoSrc) {
|
||||
videoSrc = (_d = data.match(/'(\/\/streamtape\.com\/get_video[^']+)'/)) == null ? void 0 : _d[1];
|
||||
}
|
||||
return videoSrc ? [{ source: "StreamTape", quality: 720, url: "https:" + videoSrc }] : [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
function hubCloudExtractor(url, referer) {
|
||||
return __async(this, null, function* () {
|
||||
var _a;
|
||||
try {
|
||||
let currentUrl = url.replace("hubcloud.ink", "hubcloud.dad");
|
||||
const pageResponse = yield fetch(currentUrl, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: referer }) });
|
||||
let pageData = yield pageResponse.text();
|
||||
let finalUrl = currentUrl;
|
||||
if (!currentUrl.includes("hubcloud.php")) {
|
||||
let nextHref = "";
|
||||
const $first = import_cheerio_without_node_native.default.load(pageData);
|
||||
const downloadBtn = $first("#download");
|
||||
if (downloadBtn.length) {
|
||||
nextHref = downloadBtn.attr("href");
|
||||
} else {
|
||||
const scriptUrlMatch = pageData.match(/var url = '([^']*)'/);
|
||||
if (scriptUrlMatch)
|
||||
nextHref = scriptUrlMatch[1];
|
||||
}
|
||||
if (nextHref) {
|
||||
if (!nextHref.startsWith("http")) {
|
||||
const urlObj = new URL(currentUrl);
|
||||
nextHref = `${urlObj.protocol}//${urlObj.hostname}/${nextHref.replace(/^\//, "")}`;
|
||||
}
|
||||
finalUrl = nextHref;
|
||||
const secondResponse = yield fetch(finalUrl, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: currentUrl }) });
|
||||
pageData = yield secondResponse.text();
|
||||
}
|
||||
}
|
||||
const $ = import_cheerio_without_node_native.default.load(pageData);
|
||||
const size = $("i#size").text().trim();
|
||||
const header = $("div.card-header").text().trim();
|
||||
const qualityStr = (_a = header.match(/(\d{3,4})[pP]/)) == null ? void 0 : _a[1];
|
||||
const quality = qualityStr ? parseInt(qualityStr) : 1080;
|
||||
const headerDetails = cleanTitle(header);
|
||||
const labelExtras = (headerDetails ? `[${headerDetails}]` : "") + (size ? `[${size}]` : "");
|
||||
const sizeInBytes = (() => {
|
||||
const sizeMatch = size.match(/([\d.]+)\s*(GB|MB|KB)/i);
|
||||
if (!sizeMatch)
|
||||
return 0;
|
||||
const multipliers = { GB: 1024 ** 3, MB: 1024 ** 2, KB: 1024 };
|
||||
return parseFloat(sizeMatch[1]) * (multipliers[sizeMatch[2].toUpperCase()] || 0);
|
||||
})();
|
||||
const links = [];
|
||||
const elements = $("a.btn").get();
|
||||
for (const element of elements) {
|
||||
const link = $(element).attr("href");
|
||||
const text = $(element).text().toLowerCase();
|
||||
const fileName = header || headerDetails || "Unknown";
|
||||
if (text.includes("download file") || text.includes("fsl server") || text.includes("s3 server") || text.includes("fslv2") || text.includes("mega server") || link && link.includes("r2.dev")) {
|
||||
let label = "HubCloud";
|
||||
if (link && link.includes("r2.dev"))
|
||||
label = "Direct R2";
|
||||
else if (link && link.includes("workers.dev"))
|
||||
label = "ZipDisk Server";
|
||||
else if (text.includes("fsl server"))
|
||||
label = "HubCloud - FSL";
|
||||
else if (text.includes("s3 server"))
|
||||
label = "HubCloud - S3";
|
||||
else if (text.includes("fslv2"))
|
||||
label = "HubCloud - FSLv2";
|
||||
else if (text.includes("mega server"))
|
||||
label = "HubCloud - Mega";
|
||||
links.push({ source: `${label} ${labelExtras}`, quality, url: link, size: sizeInBytes, fileName });
|
||||
} else if (text.includes("buzzserver")) {
|
||||
try {
|
||||
const buzzResp = yield fetch(`${link}/download`, { method: "GET", headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: link }), redirect: "manual" });
|
||||
let dlink = buzzResp.headers.get("hx-redirect") || buzzResp.headers.get("HX-Redirect");
|
||||
if (!dlink && buzzResp.url && buzzResp.url !== `${link}/download`) {
|
||||
dlink = buzzResp.url;
|
||||
}
|
||||
if (dlink) {
|
||||
links.push({ source: `HubCloud - BuzzServer ${labelExtras}`, quality, url: dlink, size: sizeInBytes, fileName });
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
} else if (text.includes("10gbps") || link && link.includes("hubcloud.cx")) {
|
||||
let targetUrl = link;
|
||||
if (link && !link.includes("hubcloud.cx")) {
|
||||
try {
|
||||
const resp = yield fetch(link, { method: "GET", redirect: "manual" });
|
||||
const loc = resp.headers.get("location");
|
||||
if (loc && loc.includes("link=")) {
|
||||
targetUrl = loc.substring(loc.indexOf("link=") + 5);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
links.push({ source: `HubCloud - 10Gbps ${labelExtras}`, quality, url: targetUrl, size: sizeInBytes, fileName });
|
||||
} else if (text.includes("zipdisk") || link && link.includes("workers.dev")) {
|
||||
links.push({ source: `ZipDisk Server ${labelExtras}`, quality, url: link, size: sizeInBytes, fileName });
|
||||
} else if (link && link.includes("pixeldra")) {
|
||||
const results = yield pixelDrainExtractor(link);
|
||||
links.push(...results.map((l) => __spreadProps(__spreadValues({}, l), { source: `${l.source} ${labelExtras}`, size: sizeInBytes, fileName })));
|
||||
} else if (link && !link.includes("magnet:") && link.startsWith("http")) {
|
||||
const extracted = yield loadExtractor(link, finalUrl);
|
||||
links.push(...extracted.map((l) => __spreadProps(__spreadValues({}, l), { quality: l.quality || quality })));
|
||||
}
|
||||
}
|
||||
return links;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
function hubCdnExtractor(url, referer) {
|
||||
return __async(this, null, function* () {
|
||||
try {
|
||||
const response = yield fetch(url, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: referer }) });
|
||||
const data = yield response.text();
|
||||
const $ = import_cheerio_without_node_native.default.load(data);
|
||||
let scriptContent = "";
|
||||
$("script").each((i, el) => {
|
||||
const html = $(el).html();
|
||||
if (html && html.includes("reurl")) {
|
||||
scriptContent = html;
|
||||
}
|
||||
});
|
||||
if (scriptContent) {
|
||||
const match = scriptContent.match(/reurl\s*=\s*["']([^"']+)["']/);
|
||||
if (match && match[1]) {
|
||||
const reurlVal = match[1];
|
||||
if (reurlVal.includes("?r=")) {
|
||||
const queryPart = reurlVal.split("?r=").pop();
|
||||
try {
|
||||
const decoded = atob(queryPart);
|
||||
const m3u8Link = decoded.substring(decoded.lastIndexOf("link=") + 5);
|
||||
if (m3u8Link && m3u8Link.startsWith("http")) {
|
||||
return [{ source: "HubCdn", quality: 1080, url: m3u8Link }];
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
} else if (reurlVal.includes("link=")) {
|
||||
const m3u8Link = reurlVal.split("link=").pop();
|
||||
if (m3u8Link && m3u8Link.startsWith("http")) {
|
||||
return [{ source: "HubCdn", quality: 1080, url: m3u8Link }];
|
||||
}
|
||||
} else if (reurlVal.startsWith("http")) {
|
||||
return [{ source: "HubCdn", quality: 1080, url: reurlVal }];
|
||||
}
|
||||
}
|
||||
}
|
||||
const encodedMatch = data.match(/r=([A-Za-z0-9+/=]+)/);
|
||||
if (encodedMatch && encodedMatch[1]) {
|
||||
try {
|
||||
const decoded = atob(encodedMatch[1]);
|
||||
const m3u8Link = decoded.substring(decoded.lastIndexOf("link=") + 5);
|
||||
if (m3u8Link && m3u8Link.startsWith("http")) {
|
||||
return [{ source: "HubCdn", quality: 1080, url: m3u8Link }];
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
function loadExtractor(_0) {
|
||||
return __async(this, arguments, function* (url, referer = MAIN_URL) {
|
||||
try {
|
||||
const hostname = new URL(url).hostname;
|
||||
const isRedirect = url.includes("?id=") || hostname.includes("techyboy4u") || hostname.includes("gadgetsweb.xyz") || hostname.includes("cryptoinsights.site") || hostname.includes("bloggingvector") || hostname.includes("ampproject.org");
|
||||
if (isRedirect) {
|
||||
const finalLink = yield getRedirectLinks(url);
|
||||
if (finalLink && finalLink !== url)
|
||||
return yield loadExtractor(finalLink, url);
|
||||
return [];
|
||||
}
|
||||
if (hostname.includes("hubcloud"))
|
||||
return yield hubCloudExtractor(url, referer);
|
||||
if (hostname.includes("hubcdn"))
|
||||
return yield hubCdnExtractor(url, referer);
|
||||
if (hostname.includes("hblinks") || hostname.includes("hubstream.dad"))
|
||||
return yield hbLinksExtractor(url);
|
||||
if (hostname.includes("hubstream") || hostname.includes("vidstack"))
|
||||
return yield vidStackExtractor(url);
|
||||
if (hostname.includes("pixeldrain"))
|
||||
return yield pixelDrainExtractor(url);
|
||||
if (hostname.includes("streamtape"))
|
||||
return yield streamTapeExtractor(url);
|
||||
if (hostname.includes("hdstream4u"))
|
||||
return [{ source: "HdStream4u", quality: 1080, url }];
|
||||
if (hostname.includes("hubdrive")) {
|
||||
const res = yield fetch(url, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: referer }) });
|
||||
const data = yield res.text();
|
||||
const href = import_cheerio_without_node_native.default.load(data)(".btn.btn-primary.btn-user.btn-success1.m-1").attr("href");
|
||||
if (href)
|
||||
return yield loadExtractor(href, url);
|
||||
}
|
||||
return [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// src/hdhub4u/index.js
|
||||
function search(query) {
|
||||
return __async(this, null, function* () {
|
||||
const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
||||
const searchUrl = `https://search.hdhub4u.glass/collections/post/documents/search?q=${encodeURIComponent(query)}&query_by=post_title,category&query_by_weights=4,2&sort_by=sort_by_date:desc&limit=15&highlight_fields=none&use_cache=true&page=1&analytics_tag=${today}`;
|
||||
const response = yield fetch(searchUrl, { headers: HEADERS });
|
||||
const data = yield response.json();
|
||||
if (!data || !data.hits)
|
||||
return [];
|
||||
return data.hits.map((hit) => {
|
||||
const doc = hit.document;
|
||||
const title = doc.post_title;
|
||||
const yearMatch = title.match(/\((\d{4})\)|\b(\d{4})\b/);
|
||||
const year = yearMatch ? parseInt(yearMatch[1] || yearMatch[2]) : null;
|
||||
let url = doc.permalink;
|
||||
if (url && url.startsWith("/")) {
|
||||
url = `${MAIN_URL}${url}`;
|
||||
}
|
||||
return {
|
||||
title,
|
||||
url,
|
||||
poster: doc.post_thumbnail,
|
||||
year
|
||||
};
|
||||
});
|
||||
});
|
||||
}
|
||||
function getDownloadLinks(mediaUrl) {
|
||||
return __async(this, null, function* () {
|
||||
const domain = yield getCurrentDomain();
|
||||
if (mediaUrl.includes("hdhub4u.")) {
|
||||
try {
|
||||
const urlObj = new URL(mediaUrl);
|
||||
const domainObj = new URL(domain);
|
||||
urlObj.hostname = domainObj.hostname;
|
||||
mediaUrl = urlObj.toString();
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
const response = yield fetch(mediaUrl, { headers: __spreadProps(__spreadValues({}, HEADERS), { Referer: `${domain}/` }) });
|
||||
const data = yield response.text();
|
||||
const $ = import_cheerio_without_node_native2.default.load(data);
|
||||
const typeRaw = $("h1.page-title span").text();
|
||||
const isMovie = typeRaw.toLowerCase().includes("movie");
|
||||
if (isMovie) {
|
||||
const qualityLinks = $("h3 a, h4 a").filter((i, el) => $(el).text().match(/480|720|1080|2160|4K/i));
|
||||
const bodyLinks = $(".page-body > div a").filter((i, el) => {
|
||||
const href = $(el).attr("href");
|
||||
return href && (href.includes("hdstream4u") || href.includes("hubstream"));
|
||||
});
|
||||
const initialLinks = [.../* @__PURE__ */ new Set([
|
||||
...qualityLinks.map((i, el) => $(el).attr("href")).get(),
|
||||
...bodyLinks.map((i, el) => $(el).attr("href")).get()
|
||||
])];
|
||||
const results = yield Promise.all(initialLinks.map((url) => loadExtractor(url, mediaUrl)));
|
||||
const allFinalLinks = results.flat();
|
||||
const seenUrls = /* @__PURE__ */ new Set();
|
||||
const uniqueFinalLinks = allFinalLinks.filter((link) => {
|
||||
var _a;
|
||||
if (!link.url || link.url.includes(".zip") || ((_a = link.name) == null ? void 0 : _a.toLowerCase().includes(".zip")))
|
||||
return false;
|
||||
if (seenUrls.has(link.url))
|
||||
return false;
|
||||
seenUrls.add(link.url);
|
||||
return true;
|
||||
});
|
||||
return { finalLinks: uniqueFinalLinks, isMovie };
|
||||
} else {
|
||||
const episodeLinksMap = /* @__PURE__ */ new Map();
|
||||
const directLinkBlocks = [];
|
||||
$("h3, h4").each((i, element) => {
|
||||
const $el = $(element);
|
||||
const text = $el.text();
|
||||
const anchors = $el.find("a");
|
||||
const links = anchors.map((i2, a) => $(a).attr("href")).get();
|
||||
const isDirectLinkBlock = anchors.get().some((a) => $(a).text().match(/1080|720|4K|2160/i));
|
||||
if (isDirectLinkBlock) {
|
||||
directLinkBlocks.push(...links);
|
||||
return;
|
||||
}
|
||||
const episodeMatch = text.match(/(?:EPiSODE\s*(\d+)|E(\d+))/i);
|
||||
if (episodeMatch) {
|
||||
const epNum = parseInt(episodeMatch[1] || episodeMatch[2]);
|
||||
if (!episodeLinksMap.has(epNum))
|
||||
episodeLinksMap.set(epNum, []);
|
||||
episodeLinksMap.get(epNum).push(...links);
|
||||
let nextElement = $el.next();
|
||||
while (nextElement.length && nextElement.get(0).tagName !== "hr") {
|
||||
const siblingLinks = nextElement.find("a[href]").map((i2, a) => $(a).attr("href")).get();
|
||||
episodeLinksMap.get(epNum).push(...siblingLinks);
|
||||
nextElement = nextElement.next();
|
||||
}
|
||||
}
|
||||
});
|
||||
if (directLinkBlocks.length > 0) {
|
||||
yield Promise.all(directLinkBlocks.map((blockUrl) => __async(this, null, function* () {
|
||||
try {
|
||||
const resolvedUrl = yield getRedirectLinks(blockUrl);
|
||||
if (!resolvedUrl)
|
||||
return;
|
||||
const blockRes = yield fetch(resolvedUrl, { headers: HEADERS });
|
||||
const blockData = yield blockRes.text();
|
||||
const $$ = import_cheerio_without_node_native2.default.load(blockData);
|
||||
$$("h5 a, h4 a, h3 a").each((i, el) => {
|
||||
const linkText = $$(el).text();
|
||||
const linkHref = $$(el).attr("href");
|
||||
const epMatch = linkText.match(/Episode\s*(\d+)/i);
|
||||
if (epMatch && linkHref) {
|
||||
const epNum = parseInt(epMatch[1]);
|
||||
if (!episodeLinksMap.has(epNum))
|
||||
episodeLinksMap.set(epNum, []);
|
||||
episodeLinksMap.get(epNum).push(linkHref);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
}
|
||||
})));
|
||||
}
|
||||
const initialLinks = [];
|
||||
episodeLinksMap.forEach((links, epNum) => {
|
||||
const uniqueLinks = [...new Set(links)];
|
||||
initialLinks.push(...uniqueLinks.map((link) => ({ url: link, episode: epNum })));
|
||||
});
|
||||
const results = yield Promise.all(initialLinks.map((linkInfo) => __async(this, null, function* () {
|
||||
try {
|
||||
const extracted = yield loadExtractor(linkInfo.url, mediaUrl);
|
||||
return extracted.map((ext) => __spreadProps(__spreadValues({}, ext), { episode: linkInfo.episode }));
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
})));
|
||||
const allFinalLinks = results.flat();
|
||||
const seenUrls = /* @__PURE__ */ new Set();
|
||||
const uniqueFinalLinks = allFinalLinks.filter((link) => {
|
||||
if (!link.url || link.url.includes(".zip"))
|
||||
return false;
|
||||
if (seenUrls.has(link.url))
|
||||
return false;
|
||||
seenUrls.add(link.url);
|
||||
return true;
|
||||
});
|
||||
return { finalLinks: uniqueFinalLinks, isMovie };
|
||||
}
|
||||
});
|
||||
}
|
||||
function getStreams(tmdbId, mediaType = "movie", season = null, episode = null) {
|
||||
return __async(this, null, function* () {
|
||||
console.log(`[HDHub4u] Fetching streams for TMDB ID: ${tmdbId}, Type: ${mediaType}`);
|
||||
try {
|
||||
const mediaInfo = yield getTMDBDetails(tmdbId, mediaType);
|
||||
console.log(`[HDHub4u] TMDB Info: "${mediaInfo.title}" (${mediaInfo.year || "N/A"})`);
|
||||
const searchQuery = mediaType === "tv" && season ? `${mediaInfo.title} Season ${season}` : mediaInfo.title;
|
||||
const searchResults = yield search(searchQuery);
|
||||
if (searchResults.length === 0)
|
||||
return [];
|
||||
const bestMatch = findBestTitleMatch(mediaInfo, searchResults, mediaType, season);
|
||||
const selectedMedia = bestMatch || searchResults[0];
|
||||
console.log(`[HDHub4u] Selected: "${selectedMedia.title}" (${selectedMedia.url})`);
|
||||
const result = yield getDownloadLinks(selectedMedia.url);
|
||||
const finalLinks = result.finalLinks;
|
||||
let filteredLinks = finalLinks;
|
||||
if (mediaType === "tv" && episode !== null) {
|
||||
filteredLinks = finalLinks.filter((link) => link.episode === episode);
|
||||
}
|
||||
const streams = filteredLinks.map((link) => {
|
||||
let mediaTitle = link.fileName && link.fileName !== "Unknown" ? link.fileName : mediaInfo.title;
|
||||
if (mediaType === "tv" && season && episode) {
|
||||
mediaTitle = `${mediaInfo.title} S${String(season).padStart(2, "0")}E${String(episode).padStart(2, "0")}`;
|
||||
}
|
||||
const serverName = extractServerName(link.source);
|
||||
let qualityStr = "Unknown";
|
||||
if (typeof link.quality === "number" && link.quality > 0) {
|
||||
if (link.quality >= 2160)
|
||||
qualityStr = "4K";
|
||||
else if (link.quality >= 1080)
|
||||
qualityStr = "1080p";
|
||||
else if (link.quality >= 720)
|
||||
qualityStr = "720p";
|
||||
else if (link.quality >= 480)
|
||||
qualityStr = "480p";
|
||||
} else if (typeof link.quality === "string") {
|
||||
qualityStr = link.quality;
|
||||
}
|
||||
return {
|
||||
name: `HDHub4u ${serverName}`,
|
||||
title: mediaTitle,
|
||||
url: link.url,
|
||||
quality: qualityStr,
|
||||
size: formatBytes(link.size),
|
||||
headers: link.headers || void 0,
|
||||
provider: "hdhub4u"
|
||||
};
|
||||
});
|
||||
const qualityOrder = { "4K": 4, "1080p": 2, "720p": 1, "480p": 0, "Unknown": -2 };
|
||||
return streams.sort((a, b) => (qualityOrder[b.quality] || -3) - (qualityOrder[a.quality] || -3));
|
||||
} catch (error) {
|
||||
console.error(`[HDHub4u] Scraping error: ${error.message}`);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
module.exports = { getStreams };
|
||||
Reference in new issue
Block a user