Question
Has anyone succeeded in setting up own instance with custom cookie for YouTube?
What I tried
Self hosted instance behind residential proxy, see Instance configuration.
I exported cookies from private browser session using this fork https://github.com/sertraline/Get-cookies.txt-LOCALLY-Cobalt?tab=readme-ov-file
And got a cookies.json with something like
{
"youtube":[
"PREF=xxxxxxxxx;SOCS=xxxxxxxxx;VISITOR_INFO1_LIVE=xxxxxxxxx;__Secure-1PSIDTS=xxxxxxxxxxx;__Secure-3PSIDTS=xxxxxxx;<OTHER_COOKIES>"
]
}
When I try to download any video using this setup I receive
{
"status": "error",
"error": {
"code": "error.api.youtube.api_error"
}
}
Container output
cobalt API ^ω^
~~~~~~
version: 10.9.4
commit: 4b9644ebdfbfe7bc6f7ec2d476692e3619cb59bd
branch: main
remote: imputnet/cobalt
start time: Fri, 02 May 2025 20:15:46 GMT
~~~~~~
url: <OMIT>
port: 9000
[✓] api keys loaded successfully!
[✓] cookies loaded successfully!
[✓] poToken & visitor_data loaded successfully!
If I remove cookies (comment out COOKIE_PATH) - everything works just fine. Am I missing something?
Note: I used the same approach with yt-dlp and everything has worked. So I assume there's an issue in youtube.js or the cookie handling in cobalt, not sure.
Instance configuration
services:
cobalt-api:
image: ghcr.io/imputnet/cobalt
init: true
read_only: true
restart: unless-stopped
container_name: cobalt-api
ports:
- 9000:9000/tcp
environment:
API_URL: "<OMIT>"
API_KEY_URL: "file:///keys.json"
API_AUTH_REQUIRED: 1
API_EXTERNAL_PROXY: "<OMIT>"
YOUTUBE_SESSION_SERVER: "http://host.docker.internal:8080/token"
COOKIE_PATH: "/cookies.json"
labels:
- com.centurylinklabs.watchtower.scope=cobalt
volumes:
- ./keys.json:/keys.json:ro
- ./cookies.json:/cookies.json:ro
extra_hosts:
- "host.docker.internal:host-gateway"
depends_on:
yt-session-generator:
condition: service_started
watchtower:
image: ghcr.io/containrrr/watchtower
restart: unless-stopped
command: --cleanup --scope cobalt --interval 900 --include-restarting
volumes:
- /var/run/docker.sock:/var/run/docker.sock
yt-session-generator:
image: ghcr.io/imputnet/yt-session-generator:webserver
init: true
restart: unless-stopped
container_name: yt-session-generator
ports:
- 8080:8080/tcp
Question
Has anyone succeeded in setting up own instance with custom cookie for YouTube?
What I tried
Self hosted instance behind residential proxy, see Instance configuration.
I exported cookies from private browser session using this fork https://github.com/sertraline/Get-cookies.txt-LOCALLY-Cobalt?tab=readme-ov-file
And got a
cookies.jsonwith something likeWhen I try to download any video using this setup I receive
Container output
If I remove cookies (comment out
COOKIE_PATH) - everything works just fine. Am I missing something?Instance configuration
services: cobalt-api: image: ghcr.io/imputnet/cobalt init: true read_only: true restart: unless-stopped container_name: cobalt-api ports: - 9000:9000/tcp environment: API_URL: "<OMIT>" API_KEY_URL: "file:///keys.json" API_AUTH_REQUIRED: 1 API_EXTERNAL_PROXY: "<OMIT>" YOUTUBE_SESSION_SERVER: "http://host.docker.internal:8080/token" COOKIE_PATH: "/cookies.json" labels: - com.centurylinklabs.watchtower.scope=cobalt volumes: - ./keys.json:/keys.json:ro - ./cookies.json:/cookies.json:ro extra_hosts: - "host.docker.internal:host-gateway" depends_on: yt-session-generator: condition: service_started watchtower: image: ghcr.io/containrrr/watchtower restart: unless-stopped command: --cleanup --scope cobalt --interval 900 --include-restarting volumes: - /var/run/docker.sock:/var/run/docker.sock yt-session-generator: image: ghcr.io/imputnet/yt-session-generator:webserver init: true restart: unless-stopped container_name: yt-session-generator ports: - 8080:8080/tcp