fix: copy cookies to temp file so yt-dlp doesn't overwrite originals
yt-dlp saves rotated cookies back on exit, destroying fresh exports. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
c5505417a5
commit
be3b1ca706
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import logging
|
||||
import tempfile
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
|
|
@ -38,7 +40,11 @@ def extract_video_id(url: str) -> Optional[str]:
|
|||
def _base_opts() -> dict:
|
||||
opts = {"quiet": True, "no_warnings": True}
|
||||
if COOKIES_FILE and os.path.exists(COOKIES_FILE):
|
||||
opts["cookiefile"] = COOKIES_FILE
|
||||
# Copy cookies to a temp file so yt-dlp doesn't overwrite the original
|
||||
tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".txt")
|
||||
shutil.copy2(COOKIES_FILE, tmp.name)
|
||||
tmp.close()
|
||||
opts["cookiefile"] = tmp.name
|
||||
return opts
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue