tropicoo / yt-dlp-bot

Self-hosted Video Download Telegram Bot 🇺🇦
BSD 3-Clause "New" or "Revised" License
198 stars 70 forks source link

Worker container does not use user.py #279

Closed mrpredalien closed 3 weeks ago

mrpredalien commented 2 months ago

I'm setting up video format settings for yt-dlp in user.py as described in readme to download 1920x1080 max, but worker still tries to get 4k if available. Same format options works fine with local yt-dlp and is set globally in my /etc/yt-dlp.conf

Added section of user.py regarding video format:

VIDEO_YTDL_OPTS = [ '--format', 'best[res=1920x1080]/best[height<=1080]/bestvideo[hetght<=1080]+bestaudio', '--write-thumbnail', '--convert-thumbnails', FINAL_THUMBNAIL_FORMAT, ]

Part of worker container logs:

2024-05-05 16:43:21,204 - [INFO] - [RMQCallbacks:25] - [x] Received message b'{"id":null,"from_chat_id":***,"from_chat_type":"private","from_user_id":***,"message_id":339,"ack_message_id":340,"url":"***","original_url":"***","source":"BOT","save_to_storage":true,"download_media_type":"VIDEO","custom_filenam
e":null,"automatic_extension":false,"added_at":"2024-05-05T16:43:21.200544Z"}'
2024-05-05 16:43:21,248 - [INFO] - [DefaultHost:79] - Instantiating "DefaultHost" for url "***"
2024-05-05 16:43:21,258 - [INFO] - [MediaDownloader:54] - Downloading ***, media_type VIDEO
[debug] Override config: ['--output', '%(title).200B.%(ext)s', '--no-playlist', '--playlist-items', '1:1', '--concurrent-fragments', '5', '--ignore-errors', '--verbose', '--format', 'bestvideo[ext=mp4]+bestaudio
[ext=m4a]/mp4', '--write-thumbnail', '--convert-thumbnails', 'jpg', '--format-sort', 'res,vcodec:h265,h264']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8 (No ANSI), error utf-8 (No ANSI), screen utf-8 (No ANSI)
[debug] yt-dlp version stable@2024.04.09 from yt-dlp/yt-dlp [ff0779267] (pip) API
[debug] params: {'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4', 'format_sort': ['res', 'vcodec:h265', 'h264'], 'outtmpl': {'default': '/tmp/download_tmpfs/downloading/tmp_media_dir-aw5h5w4p/%(title).200B
.%(ext)s'}, 'ignoreerrors': True, 'concurrent_fragment_downloads': 5, 'noplaylist': True, 'writethumbnail': True, 'verbose': True, 'postprocessors': [{'key': 'FFmpegThumbnailsConvertor', 'format': 'jpg', 'when':
 'before_dl'}], 'playlist_items': '1:1', 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
, 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}

As you can see in log, worker gets 'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4', which is default in default.py under app_worker/ytdl_opts

When I replace value in default.py it works just fine and gets desired format options:

2024-05-05 16:55:35,349 - [INFO] - [RMQCallbacks:25] - [x] Received message b'{"id":null,"from_chat_id":***,"from_chat_type":"private","from_user_id":***,"message_id":343,"ack_message_id":344,"url":"***","original_url":"***","source":"BOT","save_to_storage":true,"download_media_type":"VIDEO","custom_filenam
e":null,"automatic_extension":false,"added_at":"2024-05-05T16:55:35.345276Z"}'
2024-05-05 16:55:35,404 - [INFO] - [DefaultHost:79] - Instantiating "DefaultHost" for url "***"
2024-05-05 16:55:35,415 - [INFO] - [MediaDownloader:54] - Downloading ***, media_type VIDEO
[debug] Override config: ['--output', '%(title).200B.%(ext)s', '--no-playlist', '--playlist-items', '1:1', '--concurrent-fragments', '5', '--ignore-errors', '--verbose', '--format', 'best[res=1920x1080]/best[hei
ght<=1080]/bestvideo[hetght<=1080]+bestaudio', '--write-thumbnail', '--convert-thumbnails', 'jpg', '--format-sort', 'res,vcodec:h265,h264']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8 (No ANSI), error utf-8 (No ANSI), screen utf-8 (No ANSI)
[debug] yt-dlp version stable@2024.04.09 from yt-dlp/yt-dlp [ff0779267] (pip) API
[debug] params: {'format': 'best[res=1920x1080]/best[height<=1080]/bestvideo[hetght<=1080]+bestaudio', 'format_sort': ['res', 'vcodec:h265', 'h264'], 'outtmpl': {'default': '/tmp/download_tmpfs/downloading/tmp_m
edia_dir-zuyympau/%(title).200B.%(ext)s'}, 'ignoreerrors': True, 'concurrent_fragment_downloads': 5, 'noplaylist': True, 'writethumbnail': True, 'verbose': True, 'postprocessors': [{'key': 'FFmpegThumbnailsConve
rtor', 'format': 'jpg', 'when': 'before_dl'}], 'playlist_items': '1:1', 'compat_opts': set(), 'http_headers': {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chro
me/90.0.4430.93 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': 'en-us,en;q=0.5', 'Sec-Fetch-Mode': 'navigate'}}
tropicoo commented 2 months ago

Try to copy everything from default.py to user.py and modify what's needed. Also, you have a typo in height: bestvideo[hetght<=1080]

mrpredalien commented 3 weeks ago

Thank you, my bad, missed this part of copying everything from default file. And thank you for typo fix also