From 050f0a39197d209446d6d0a66b5d021f65994512 Mon Sep 17 00:00:00 2001 From: Will Twomey Date: Fri, 10 Apr 2026 15:08:07 -0500 Subject: [PATCH] Add optional cookies.txt support for authenticated downloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sites like X/Twitter require login to access certain content — this lets yt-dlp use a cookies.txt file (Netscape format) when one is present, so those downloads just work. - app.py checks for cookies.txt and passes --cookies to yt-dlp - docker-compose.yml bind-mounts the file into the container - cookies.txt added to .gitignore since it contains session data --- .gitignore | 3 ++- app.py | 5 +++++ docker-compose.yml | 8 ++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 docker-compose.yml diff --git a/.gitignore b/.gitignore index 148142d..2dcbfa1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ assets/*.mov .env .env.local .env.production -.env.development \ No newline at end of file +.env.development +cookies.txt diff --git a/app.py b/app.py index 703f435..c4b81e2 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ app = Flask(__name__) DOWNLOAD_DIR = os.path.join(os.path.dirname(__file__), "downloads") +COOKIES_FILE = os.path.join(os.path.dirname(__file__), "cookies.txt") os.makedirs(DOWNLOAD_DIR, exist_ok=True) jobs = {} @@ -18,6 +19,8 @@ def run_download(job_id, url, format_choice, format_id): out_template = os.path.join(DOWNLOAD_DIR, f"{job_id}.%(ext)s") cmd = ["yt-dlp", "--no-playlist", "-o", out_template] + if os.path.isfile(COOKIES_FILE): + cmd += ["--cookies", COOKIES_FILE] if format_choice == "audio": cmd += ["-x", "--audio-format", "mp3"] @@ -86,6 +89,8 @@ def get_info(): return jsonify({"error": "No URL provided"}), 400 cmd = ["yt-dlp", "--no-playlist", "-j", url] + if os.path.isfile(COOKIES_FILE): + cmd += ["--cookies", COOKIES_FILE] try: result = subprocess.run(cmd, capture_output=True, text=True, timeout=60) if result.returncode != 0: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..4db70ea --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,8 @@ +services: + reclip: + build: . + ports: + - "8899:8899" + volumes: + - ./cookies.txt:/app/cookies.txt + restart: unless-stopped