cookie update

This commit is contained in:
2025-12-01 23:35:09 +03:00
parent 1c39ef5d37
commit 551ed77eb0
2 changed files with 117 additions and 11 deletions

View File

@@ -73,6 +73,7 @@ const INFO_FILENAME = "info.json";
const YT_ID_REGEX = /^[A-Za-z0-9_-]{11}$/;
const YT_DLP_BIN = process.env.YT_DLP_BIN || null;
let resolvedYtDlpBinary = null;
const COOKIES_FILE = path.join(__dirname, "cookies.txt");
const TMDB_API_KEY = process.env.TMDB_API_KEY;
const TMDB_BASE_URL = "https://api.themoviedb.org/3";
const TMDB_IMG_BASE =
@@ -619,6 +620,9 @@ function launchYoutubeJob(job) {
"--write-info-json",
job.url
];
if (fs.existsSync(COOKIES_FILE)) {
args.splice(-1, 0, "--cookies", COOKIES_FILE);
}
const child = spawn(binary, args, {
cwd: job.savePath,
env: process.env
@@ -5707,6 +5711,32 @@ app.post("/api/youtube/download", requireAuth, async (req, res) => {
}
});
// --- Cookie yükleme (YouTube için) ---
app.post(
"/api/cookies/upload",
requireAuth,
upload.single("cookies"),
async (req, res) => {
try {
if (!req.file) {
return res.status(400).json({ error: "cookies dosyası gerekli." });
}
const target = COOKIES_FILE;
try {
fs.renameSync(req.file.path, target);
} catch (err) {
// fallback: kopyala, sonra geçici dosyayı sil
fs.copyFileSync(req.file.path, target);
fs.rmSync(req.file.path, { force: true });
}
res.json({ ok: true });
} catch (err) {
console.error("🍪 Cookie yükleme hatası:", err?.message || err);
res.status(500).json({ error: "Cookie yüklenemedi." });
}
}
);
// --- 📺 TV dizileri listesi ---
app.get("/api/tvshows", requireAuth, (req, res) => {
try {