alexta69 / metube

Self-hosted YouTube downloader (web UI for youtube-dl / yt-dlp)
GNU Affero General Public License v3.0
6.07k stars 377 forks source link

Unable to Set `YTDL_OPTIONS` Environment Variable for Subtitles in Docker Run Command #479

Open TeomanEgeSelcuk opened 1 month ago

TeomanEgeSelcuk commented 1 month ago

Issue Description:

I am experiencing an issue with setting the YTDL_OPTIONS environment variable to download subtitles when running the MeTube Docker container. Despite following the documentation, the container exits immediately with the error YTDL_OPTIONS is invalid.

Steps to Reproduce:

  1. Ensure Docker Desktop is installed and running on Windows 11.
  2. Create a directory for downloads: C:\path\to\downloads.
  3. Run the following Docker command:
    docker run -d -p 8081:8081 --name metube_yt_downloader -v C:\path\to\downloads:/downloads -e YTDL_OPTIONS="{\"writesubtitles\":true,\"subtitleslangs\":[\"en\",\"-live_chat\"],\"updatetime\":false,\"postprocessors\":[{\"key\":\"Exec\",\"exec_cmd\":\"chmod 0664\",\"when\":\"after_move\"},{\"key\":\"FFmpegEmbedSubtitle\",\"already_have_subtitle\":false},{\"key\":\"FFmpegMetadata\",\"add_chapters\":true}]}" ghcr.io/alexta69/metube

Expected Behavior:

The container should run successfully, allowing videos to be downloaded with embedded English subtitles.

Actual Behavior:

The container exits immediately with the error message:

YTDL_OPTIONS is invalid

Additional Information:

Attempts to Resolve:

Request:

Could you provide guidance on the correct format for the YTDL_OPTIONS environment variable when using Docker on Windows? Any help in resolving this issue would be greatly appreciated.

References:

Thank you!

PikuZheng commented 1 month ago

3. Run the following Docker command:

    docker run -d -p 8081:8081 --name metube_yt_downloader -v C:\path\to\downloads:/downloads -e YTDL_OPTIONS="{\"writesubtitles\":true,\"subtitleslangs\":[\"en\",\"-live_chat\"],\"updatetime\":false,\"postprocessors\":[{\"key\":\"Exec\",\"exec_cmd\":\"chmod 0664\",\"when\":\"after_move\"},{\"key\":\"FFmpegEmbedSubtitle\",\"already_have_subtitle\":false},{\"key\":\"FFmpegMetadata\",\"add_chapters\":true}]}" ghcr.io/alexta69/metube

works fine with my linux my suggestion is writing it to a text file and using YTDL_OPTIONS_FILE

TeomanEgeSelcuk commented 1 month ago

Is there a way to configure it so that the subtitles will be of the extension as subtitle files (e.g., .srt, .vtt). It creates meta subtitles for me, but I am trying to use it in VLC media player in Windows 11 and I'm not able to get the subtitles to work correctly. Also, thanks for the help. Much appreciated.

PikuZheng commented 1 month ago

you can convert the format of the subtitle after download with postprocessers like

 YTDL_OPTIONS={"postprocessors": [{"format": "srt", "key": "FFmpegSubtitlesConvertor", when": "before_dl"}]}
TeomanEgeSelcuk commented 1 month ago

Despite trying the suggested solutions, I still could not get the subtitles to work. The videos are downloaded fine in the quality and format that I like, but the subtitle functionality is not working as expected.

I attempted the following methods:

  1. JSON File Integration: Created a JSON file with the following content:

    {
     "writesubtitles": true,
     "subtitleslangs": ["en", "-live_chat"],
     "updatetime": false,
     "postprocessors": [
       {
         "key": "Exec",
         "exec_cmd": "chmod 0664",
         "when": "after_move"
       },
       {
         "key": "FFmpegEmbedSubtitle",
         "already_have_subtitle": false
       },
       {
         "key": "FFmpegMetadata",
         "add_chapters": true
       },
       {
         "key": "FFmpegSubtitlesConvertor",
         "format": "srt",
         "when": "before_dl"
       }
     ]
    }

    Placed this file in the directory C:\Users\...\ytdl_options.json and ran the following Docker command:

    docker run -d -p 8081:8081 --name metube_yt_downloader -v C:\Users\...\Downloaded-YT-Vids:/downloads -v C:\Users\...\ytdl_options.json:/app/ytdl_options.json -e YTDL_OPTIONS_FILE=/app/ytdl_options.json ghcr.io/alexta69/metube
  2. Direct JSON String in Docker Command: Attempted to pass the JSON string directly in the Docker command as follows:

    docker run -d -p 8081:8081 --name metube_yt_downloader -v C:\Users\...\Downloaded-YT-Vids:/downloads -e YTDL_OPTIONS="{\"writesubtitles\":true,\"subtitleslangs\":[\"en\",\"-live_chat\"],\"updatetime\":false,\"postprocessors\":[{\"key\":\"Exec\",\"exec_cmd\":\"chmod 0664\",\"when\":\"after_move\"},{\"key\":\"FFmpegEmbedSubtitle\",\"already_have_subtitle\":false},{\"key\":\"FFmpegMetadata\",\"add_chapters\":true},{\"key\":\"FFmpegSubtitlesConvertor\",\"format\":\"srt\",\"when\":\"before_dl\"}]}" ghcr.io/alexta69/metube

Both methods resulted in the same issue where subtitles are not working, while the videos are downloaded correctly.

Any further guidance on resolving the subtitle issue would be greatly appreciated. Thank you!

PikuZheng commented 1 month ago

with -live_chat , please confirm that the video is live streaming now. on the other hand, you can set YTDL_OPTIONS={"verbose":true} to see detailed debug logs. also you can use yt-dlp --list-subs https://www.youtube.com/watch?v=xxxxxx to check which subtitle is available for the video.

solidsnakex37 commented 1 day ago

I am having this same problem. I am running MeTube in Docker on Unraid, I added the variable as described in the documentation but it's saying that YTDL_OPTIONS is invalid.

image

alexta69 commented 5 hours ago

In the Value field put only the value, you don't need YTDL_OPTIONS=, and likely you don't need the quotes either.