commit b29971148dcb34ca9ff5ce2bdfc2ff455916b796
parent 67e5827098f0fe726e24424e8eb8c9eeaf867ab2
Author: notamitgamer2 <notamitgamer2@users.noreply.github.com>
Date: Thu, 17 Sep 2026 05:04:33 +0000
Wire up optional YOUTUBE_COOKIE_HEADER for authenticated Cobalt/YouTube
Adds support for the COOKIE_PATH mechanism Cobalt already has, without
ever committing cookies to the repo:
- start.sh: if YOUTUBE_COOKIE_HEADER is set, writes a cookies.json
compatible with Cobalt's expected format
({"youtube": ["name=value; name2=value2"]}) to /tmp at boot and
passes COOKIE_PATH to the cobalt process. If unset, behavior is
unchanged (no cookies, same error.api.youtube.login as now).
- render.yaml: documents the YOUTUBE_COOKIE_HEADER env var
(sync: false, so it must be set manually in the Render dashboard,
never committed).
To use: export cookies for youtube.com via the Cookie-Editor browser
extension's 'Header String' format (name=value; name2=value2 - NOT
Netscape/JSON-array format) while logged into the account to use, and
paste that string as YOUTUBE_COOKIE_HEADER in Render's dashboard.
Diffstat:
2 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/render.yaml b/render.yaml
@@ -20,4 +20,7 @@ services:
value: https://cdn.amit.is-a.dev/cobalt/
- key: COBALT_PORT
- value: "9000"
-\ No newline at end of file
+ value: "9000"
+
+ - key: YOUTUBE_COOKIE_HEADER
+ sync: false
+\ No newline at end of file
diff --git a/start.sh b/start.sh
@@ -10,10 +10,33 @@ echo ""
echo "========== COBALT ENV =========="
echo "API_URL=${API_URL:-https://cdn.amit.is-a.dev/cobalt/}"
echo "API_PORT=9000"
-echo "COOKIE_PATH=${COOKIE_PATH:-NOT_SET}"
echo "================================"
echo ""
+COBALT_COOKIE_PATH=""
+
+if [ -n "$YOUTUBE_COOKIE_HEADER" ]; then
+ echo "YOUTUBE_COOKIE_HEADER is set - writing cookies.json..."
+
+ COBALT_COOKIE_PATH="/tmp/cobalt-cookies.json"
+
+ YOUTUBE_COOKIE_HEADER="$YOUTUBE_COOKIE_HEADER" python3 -c "
+import json
+import os
+
+cookie_header = os.environ['YOUTUBE_COOKIE_HEADER'].strip()
+
+with open('$COBALT_COOKIE_PATH', 'w') as f:
+ json.dump({'youtube': [cookie_header]}, f)
+"
+
+ echo "Wrote $COBALT_COOKIE_PATH"
+else
+ echo "YOUTUBE_COOKIE_HEADER not set - continuing without YouTube cookies"
+ echo "(YouTube downloads will likely fail with error.api.youtube.login)"
+fi
+
+echo ""
echo "Starting Cobalt..."
cd /opt/cobalt-api
@@ -26,9 +49,16 @@ cd /opt/cobalt-api
# exact path previously killed the whole container on every boot even
# when the Cobalt build itself was fine. Instead we start the process and
# let the readiness probe below be the real success/failure signal.
-API_URL="https://cdn.amit.is-a.dev/cobalt/" \
-API_PORT=9000 \
-node src/cobalt &
+if [ -n "$COBALT_COOKIE_PATH" ]; then
+ API_URL="https://cdn.amit.is-a.dev/cobalt/" \
+ API_PORT=9000 \
+ COOKIE_PATH="$COBALT_COOKIE_PATH" \
+ node src/cobalt &
+else
+ API_URL="https://cdn.amit.is-a.dev/cobalt/" \
+ API_PORT=9000 \
+ node src/cobalt &
+fi
COBALT_PID=$!