This commit is contained in:
@@ -14,20 +14,50 @@ const PROXIES = [
|
||||
'https://thingproxy.freeboard.io/fetch/',
|
||||
'https://cors-anywhere.herokuapp.com/',
|
||||
'https://corsproxy.ca/',
|
||||
'https://proxy.t vot.pw/',
|
||||
];
|
||||
|
||||
// Кеш страниц фильмов и постеров
|
||||
const filmData = new Map();
|
||||
|
||||
async function fetchWithProxy(url) {
|
||||
for (const proxy of PROXIES) {
|
||||
try {
|
||||
const response = await fetch(proxy + encodeURIComponent(url), { timeout: 15000 });
|
||||
if (response.ok) return await response.text();
|
||||
} catch (e) {}
|
||||
function buildProxyUrl(proxy, url) {
|
||||
return proxy + encodeURIComponent(url);
|
||||
}
|
||||
|
||||
async function fetchWithProxy(url, timeout = 15000) {
|
||||
const controller = new AbortController();
|
||||
const timer = setTimeout(() => controller.abort(), timeout);
|
||||
|
||||
try {
|
||||
for (const proxy of PROXIES) {
|
||||
try {
|
||||
const response = await fetch(buildProxyUrl(proxy, url), {
|
||||
signal: controller.signal,
|
||||
headers: {
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
||||
}
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const text = await response.text();
|
||||
if (text && text.trim().length > 0) {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
// Прокси не сработал — пробуем следующий
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Все прокси недоступны');
|
||||
} finally {
|
||||
clearTimeout(timer);
|
||||
}
|
||||
throw new Error('Все прокси недоступны');
|
||||
}
|
||||
|
||||
function normalizePosterUrl(poster) {
|
||||
if (!poster) return '';
|
||||
if (poster.startsWith('http')) return poster;
|
||||
return targetUrl + poster;
|
||||
}
|
||||
|
||||
function parseColdfilm(html) {
|
||||
@@ -68,12 +98,7 @@ function parseColdfilm(html) {
|
||||
while ((match = posterRegex.exec(html)) !== null) {
|
||||
const poster = match[1];
|
||||
const alt = match[2].replace('[Смотреть Онлайн]', '').trim();
|
||||
|
||||
let fullPoster = poster;
|
||||
if (!fullPoster.startsWith('http')) {
|
||||
fullPoster = targetUrl + poster;
|
||||
}
|
||||
posterMap.set(alt, fullPoster);
|
||||
posterMap.set(alt, normalizePosterUrl(poster));
|
||||
}
|
||||
|
||||
// Альтернативно - title вместо alt
|
||||
@@ -83,11 +108,7 @@ function parseColdfilm(html) {
|
||||
const title = match[2].replace('[Смотреть Онлайн]', '').trim();
|
||||
|
||||
if (!posterMap.has(title)) {
|
||||
let fullPoster = poster;
|
||||
if (!fullPoster.startsWith('http')) {
|
||||
fullPoster = targetUrl + poster;
|
||||
}
|
||||
posterMap.set(title, fullPoster);
|
||||
posterMap.set(title, normalizePosterUrl(poster));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +213,7 @@ async function showQualityModal(filmName) {
|
||||
|
||||
// Ищем все торренты на странице
|
||||
let match;
|
||||
const torrentRegex = /href="(\/t\d+\/[^"]+\.torrent)"/gi;
|
||||
const torrentRegex = /href="(\/t\d+\/[^\"]+\.torrent(?:\?[^\"]*)?)"/gi;
|
||||
while ((match = torrentRegex.exec(filmPageHtml)) !== null) {
|
||||
let url = match[1];
|
||||
if (!url.startsWith('http')) {
|
||||
|
||||
Reference in New Issue
Block a user