Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] How to configure cookies? #529

Open
janusn opened this issue Oct 18, 2024 · 6 comments
Open

[Help] How to configure cookies? #529

janusn opened this issue Oct 18, 2024 · 6 comments

Comments

@janusn
Copy link

janusn commented Oct 18, 2024

I have installed metube via docker compose using the following content as compose.yaml

---
services:
  metube:
    image: "ghcr.io/alexta69/metube"
    container_name: metube
    environment:
      CUSTOM_DIRS: true
      STATE_DIR: "/config"
      TEMP_DIR: "/tmp"
      YTDL_OPTIONS: '{"cookiefile":"/cookies/cookies.txt"}'
    deploy:
      resources:
        limits:
          memory: 4G
    volumes:
      - "./config:/config:rw"
      - "./cookies:/cookies:rw"
      - "/mnt/download:/downloads:rw"
      - type: tmpfs # Optional: 4GB of memory, reduces SSD/SD Card wear
        target: /tmp
        tmpfs:
          size: 4294967296
    ports:
      - "8081:8081"
    restart: unless-stopped

When I initiated download from the web UI, it failed. The docker logged the following messages:

INFO:aiohttp.access:10.27.0.40 [18/Oct/2024:20:26:05 +0000] "POST /delete HTTP/1.1" 200 287 "https://metube.home.arpa/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
INFO:ytdl:adding https://www.youtube.com/watch?v=OWcJwXmUhuk: quality='best' format='any' already=None folder=None custom_name_prefix='' playlist_strict_mode=False playlist_item_limit=0
WARNING: [youtube] Sign in to confirm your age. This video may be inappropriate for some users.
WARNING: No video formats found!
WARNING: Requested format is not available
DEBUG:ytdl:Processing as a video
INFO:ytdl:downloading Getting a Heart Transplant at Yale
INFO:aiohttp.access:10.27.0.40 [18/Oct/2024:20:26:06 +0000] "POST /add HTTP/1.1" 200 287 "https://metube.home.arpa/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
WARNING: [youtube] Sign in to confirm your age. This video may be inappropriate for some users.
WARNING: No video formats found!
WARNING: Requested format is not available
ERROR: [youtube] OWcJwXmUhuk: No video formats found!
INFO:ytdl:waiting for item to download

However, when I called yt-dlp directly inside the container, it downloaded successfully as illustrated below:

# docker exec -it metube sh
/app # cd /downloads/
/downloads # yt-dlp --cookies '/cookies/cookies.txt' https://www.youtube.com/watch?v=OWcJwXmUhuk
[youtube] Extracting URL: https://www.youtube.com/watch?v=OWcJwXmUhuk
[youtube] OWcJwXmUhuk: Downloading webpage
[youtube] OWcJwXmUhuk: Downloading ios player API JSON
[youtube] OWcJwXmUhuk: Downloading mweb player API JSON
[youtube] OWcJwXmUhuk: Downloading player e627e516
[youtube] OWcJwXmUhuk: Downloading m3u8 information
[info] OWcJwXmUhuk: Downloading 1 format(s): 248+251
[download] Destination: Getting a Heart Transplant at Yale [OWcJwXmUhuk].f248.webm
[download] 100% of   57.10MiB in 00:00:01 at 35.56MiB/s
[download] Destination: Getting a Heart Transplant at Yale [OWcJwXmUhuk].f251.webm
[download] 100% of    6.30MiB in 00:00:00 at 41.37MiB/s
[Merger] Merging formats into "Getting a Heart Transplant at Yale [OWcJwXmUhuk].webm"
Deleting original file Getting a Heart Transplant at Yale [OWcJwXmUhuk].f251.webm (pass -k to keep)
Deleting original file Getting a Heart Transplant at Yale [OWcJwXmUhuk].f248.webm (pass -k to keep)

Could somebody tell me how to fix it? Many thanks!

@PikuZheng
Copy link
Contributor

PikuZheng commented Oct 19, 2024

write /cookies/cookies.txt with Netscape format:

# Netscape HTTP Cookie File
www.youtube.com	TRUE	/	FALSE	0	LOGIN_INFO	AFmm..........
...................

@janusn
Copy link
Author

janusn commented Oct 20, 2024

The cookies.txt file was written by a Chrome extension Get cookies.txt LOCALLY.

And I checked the content. It should be Netscape format:

# Netscape HTTP Cookie File
# This file is generated by yt-dlp.  Do not edit.

accounts.google.com	FALSE	/	TRUE	1	OTZ	7…
accounts.google.com	FALSE	/	TRUE	2	ACCOUNT_CHOOSER	AFx_…
…

It should be correct as calling yt-dlp inside the container works as illustrated above.

@janusn
Copy link
Author

janusn commented Oct 22, 2024

Instead of using the environment variable YTDL_OPTIONS, I work around by mapping a file on host to /etc/yt-dlp/config/yt-dlp.conf with the following content and it works. 😕

--cookies /cookies/cookies.txt

@JonasR
Copy link

JonasR commented Nov 6, 2024

Did you try if YTDL_OPTIONS is correctly parsed at all? Should it not be YTDL_OPTIONS: {"cookiefile":"/cookies/cookies.txt"} ?

You could also use YTDL_OPTIONS_FILE instead, referencing a .json file (also makes it more readable once you add more things)

@janusn
Copy link
Author

janusn commented Nov 6, 2024

Thanks for your help.
I have retried again and it turns out the youtube cookies expire quickly. It works with a fresh generated cookies.txt.

@JonasR
Copy link

JonasR commented Nov 6, 2024

Ah yes, that is a confounding factor. For me they only last a few minutes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants