fix: canlı-tespit fetch'ine cookie ekle — AB consent duvarını aş

Coolify sunucusu AB'de; oturumsuz istek YouTube'un interaktif consent
sayfasına düşüyor (o sayfada videoDetails yok), bu da gerçekten canlı
bir kanalı "değil" gibi gösteriyordu (doğrulandı: @ertemsener canlıydı,
sistem "değil" dedi). yt-dlp için zaten sakladığımız oturum açık
cookie'leri aynı fetch'e Cookie header'ı olarak eklendi — giriş yapılmış
hesaplar consent duvarını hiç görmüyor.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-30 19:50:55 +03:00
co-authored by Claude Sonnet 5
parent 0547018cc3
commit 32c09de896
2 changed files with 34 additions and 1 deletions
+22
View File
@@ -33,3 +33,25 @@ export async function ytdlpAntiBotArgs(): Promise<string[]> {
return args;
}
/**
* Same cookies, formatted as a `Cookie:` header for plain fetch() calls
* (youtubePolling.ts's live-check). Logged-in cookies also skip YouTube's
* interactive EU consent wall, which an unauthenticated fetch from an
* EU-geolocated server IP otherwise hits — that page has no `videoDetails`,
* so the check would misreport a genuinely live channel as offline.
*/
export async function getCookieHeader(): Promise<string | null> {
const setting = await prisma.appSetting.findUnique({ where: { key: COOKIES_SETTING_KEY } });
if (!setting?.value) return null;
const pairs = setting.value
.split("\n")
.map((line) => line.trim())
.filter((line) => line && !line.startsWith("#"))
.map((line) => line.split("\t"))
.filter((fields) => fields.length >= 7)
.map(([, , , , , name, value]) => `${name}=${value}`);
return pairs.length > 0 ? pairs.join("; ") : null;
}