34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
/**
|
|
* Appels réseau pour free-telecharger.cam.
|
|
* Pas de challenge CF actif, fetch direct simple.
|
|
*/
|
|
|
|
const TIMEOUT = 20_000;
|
|
const UA = 'Mozilla/5.0 (X11; Linux x86_64; rv:135.0) Gecko/20100101 Firefox/135.0';
|
|
|
|
async function ftGet(url: string): Promise<string> {
|
|
const res = await fetch(url, {
|
|
headers: {
|
|
'User-Agent': UA,
|
|
'Accept': 'text/html,application/xhtml+xml,*/*;q=0.8',
|
|
'Accept-Language': 'fr-FR,fr;q=0.9,en;q=0.8',
|
|
},
|
|
redirect: 'follow',
|
|
signal: AbortSignal.timeout(TIMEOUT),
|
|
});
|
|
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
|
return res.text();
|
|
}
|
|
|
|
export async function fetchSearch(baseUrl: string, query: string): Promise<string> {
|
|
return ftGet(`${baseUrl}/1/recherche1/1.html?rech_fiche=${encodeURIComponent(query)}`);
|
|
}
|
|
|
|
export async function fetchTrending(baseUrl: string): Promise<string> {
|
|
return ftGet(`${baseUrl}/page/1.html`);
|
|
}
|
|
|
|
export async function fetchPage(pageUrl: string): Promise<string> {
|
|
return ftGet(pageUrl);
|
|
}
|