fix(auth): always regenerate cookies.txt from auth.json, don't skip if yt-dlp overwrote it
All checks were successful
Build & Push Docker Image / test-and-build (push) Successful in 1m2s
All checks were successful
Build & Push Docker Image / test-and-build (push) Successful in 1m2s
Previously cookies.txt was only regenerated when auth.json was newer. But yt-dlp
overwrites cookies.txt during extraction with its own header ('generated by yt-dlp')
and potentially fewer/different cookies, losing the sessionid from auth.json.
Fix: remove mtime comparison — always regenerate cookies.txt from auth.json on each
extraction call. This ensures the full session cookie set is always present.
Also remove the now-unused statSync import.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
import { execFile } from 'node:child_process';
|
||||
import { promisify } from 'node:util';
|
||||
import { existsSync, readFileSync, writeFileSync, statSync } from 'node:fs';
|
||||
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
||||
import { logError } from './utils/logger';
|
||||
import type { ExtractedContent, ProgressCallback } from './extraction';
|
||||
|
||||
@@ -40,11 +40,7 @@ function maybeConvertAuthJson(): void {
|
||||
const cookiePath = COOKIE_PATHS[i];
|
||||
if (!existsSync(authPath)) continue;
|
||||
|
||||
// Re-generate whenever auth.json is newer than the existing cookies.txt
|
||||
const authMtime = statSync(authPath).mtimeMs;
|
||||
const cookieMtime = existsSync(cookiePath) ? statSync(cookiePath).mtimeMs : 0;
|
||||
if (cookieMtime >= authMtime) continue;
|
||||
|
||||
// Always regenerate from auth.json so yt-dlp cannot overwrite our session cookies
|
||||
try {
|
||||
const auth = JSON.parse(readFileSync(authPath, 'utf8')) as {
|
||||
cookies?: PlaywrightCookie[];
|
||||
|
||||
Reference in New Issue
Block a user