Batch 1Fichier link checks before downloads start, populate original filenames, exact sizes, and availability, preserve resolved names across generic debrid responses, and normalize all supported mirror domains under one hoster identity. Pace batches to the hoster's documented safe interval and cover offline, private, delayed, malformed, alias, and 100-link boundary cases.
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
const DOMAIN_ALIASES: Readonly<Record<string, string>> = Object.freeze({
|
|
"rapidgator.net": "rapidgator",
|
|
"rapidgator.asia": "rapidgator",
|
|
"rg.to": "rapidgator",
|
|
"1fichier.com": "1fichier",
|
|
"alterupload.com": "1fichier",
|
|
"cjoint.net": "1fichier",
|
|
"desfichiers.com": "1fichier",
|
|
"desfichiers.net": "1fichier",
|
|
"dfichiers.com": "1fichier",
|
|
"megadl.fr": "1fichier",
|
|
"mesfichiers.org": "1fichier",
|
|
"piecejointe.net": "1fichier",
|
|
"pjointe.com": "1fichier",
|
|
"tenvoi.com": "1fichier",
|
|
"dl4free.com": "1fichier"
|
|
});
|
|
|
|
export function normalizeHosterHostname(hostname: string): string {
|
|
const normalized = hostname.trim().toLowerCase().replace(/^www\./, "").replace(/\.$/, "");
|
|
for (const [domain, hoster] of Object.entries(DOMAIN_ALIASES)) {
|
|
if (normalized === domain || normalized.endsWith(`.${domain}`)) {
|
|
return hoster;
|
|
}
|
|
}
|
|
const parts = normalized.split(".").filter(Boolean);
|
|
return parts.length >= 2 ? parts[parts.length - 2] : normalized;
|
|
}
|
|
|
|
export function extractHosterFromUrl(url: string): string {
|
|
try {
|
|
return normalizeHosterHostname(new URL(url).hostname);
|
|
} catch {
|
|
return "";
|
|
}
|
|
}
|