blackjack4494 / youtube-dlc

Command-line program to download various media from YouTube.com and other sites
https://blackjack4494.github.io/youtube-dlc/
The Unlicense
1.21k stars 13 forks source link

[Broken] Reddit video doesn't download highest resolution with `bestvideo` option. #212

Open nicolaasjan opened 3 years ago

nicolaasjan commented 3 years ago

Checklist

Verbose log

youtube-dlc -v https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/
[debug] System config: []
[debug] User config: ['-o', '/dev/shm/%(title)s.%(ext)s', '-f', 'bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-mtime', '--add-metadata', '--embed-thumbnail', '--cookies', '/home/nico/.config/youtube-dlc/cookies.txt']
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/']
[debug] Loading archive file None
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dlc version 2020.10.09
[debug] Python version 3.6.9 (CPython) - Linux-4.15.0-122-generic-x86_64-with-LinuxMint-19.3-tricia
[debug] exe versions: ffmpeg N-99430-g9d8f9b2-Nico_20201001, ffprobe N-99430-g9d8f9b2-Nico_20201001
[debug] Proxy map: {}
[RedditR] dhp55u: Downloading JSON metadata
[Reddit] y1ew7xk4qhs31: Downloading m3u8 information
[Reddit] y1ew7xk4qhs31: Downloading MPD manifest
[Reddit] y1ew7xk4qhs31: Downloading thumbnail ...
[Reddit] y1ew7xk4qhs31: Writing thumbnail to: /dev/shm/We just met, but we made a doubles routine together! ♥️.jpg
[download] /dev/shm/We just met, but we made a doubles routine together! ♥️.mp4 has already been downloaded and merged
[ffmpeg] Adding metadata to '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' -map 0 -c copy -metadata 'title=We just met, but we made a doubles routine together! ♥️' -metadata date=20191014 -metadata purl=https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/ -metadata artist=h0l 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'
[atomicparsley] Adding thumbnail to "/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4"
[debug] AtomicParsley command line: AtomicParsley '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' --artwork '/dev/shm/We just met, but we made a doubles routine together! ♥️.jpg' -o '/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'

Description

(Issue from /r/youtubedl) Above command downloads the 1024x576 video, while the command:

youtube-dlc -f dash-VIDEO-2+dash-AUDIO-1 https://www.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/

downloads the 1280x720 version (highest resolution):

youtube-dlc -v -f dash-VIDEO-2+dash-AUDIO-1 https://www.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/[debug] System config: []
[debug] User config: ['-o', '/dev/shm/%(title)s.%(ext)s', '-f', 'bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-mtime', '--add-metadata', '--embed-thumbnail', '--cookies', '/home/nico/.config/youtube-dlc/cookies.txt']
[debug] Custom config: []
[debug] Command-line args: ['-v', '-f', 'dash-VIDEO-2+dash-AUDIO-1', 'https://www.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/']
[debug] Loading archive file None
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dlc version 2020.10.09
[debug] Python version 3.6.9 (CPython) - Linux-4.15.0-122-generic-x86_64-with-LinuxMint-19.3-tricia
[debug] exe versions: ffmpeg N-99430-g9d8f9b2-Nico_20201001, ffprobe N-99430-g9d8f9b2-Nico_20201001
[debug] Proxy map: {}
[RedditR] dhp55u: Downloading JSON metadata
[Reddit] y1ew7xk4qhs31: Downloading m3u8 information
[Reddit] y1ew7xk4qhs31: Downloading MPD manifest
[Reddit] y1ew7xk4qhs31: Downloading thumbnail ...
[Reddit] y1ew7xk4qhs31: Writing thumbnail to: /dev/shm/We just met, but we made a doubles routine together! ♥️.jpg
[download] /dev/shm/We just met, but we made a doubles routine together! ♥️.mp4 has already been downloaded and merged
[ffmpeg] Adding metadata to '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' -map 0 -c copy -metadata 'title=We just met, but we made a doubles routine together! ♥️' -metadata date=20191014 -metadata purl=https://www.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/ -metadata artist=h0l 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'
[atomicparsley] Adding thumbnail to "/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4"
[debug] AtomicParsley command line: AtomicParsley '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' --artwork '/dev/shm/We just met, but we made a doubles routine together! ♥️.jpg' -o '/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'

Formats:

youtube-dlc -F https://www.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/
[RedditR] dhp55u: Downloading JSON metadata
[Reddit] y1ew7xk4qhs31: Downloading m3u8 information
[Reddit] y1ew7xk4qhs31: Downloading MPD manifest
[info] Available formats for y1ew7xk4qhs31:
format code          extension  resolution note
hls-audio-0-Default  mp4        audio only 
hls-audio-1-Default  mp4        audio only 
dash-AUDIO-1         m4a        audio only DASH audio  129k , m4a_dash container, mp4a.40.2 (48000Hz)
hls-462              mp4        400x224     462k , avc1.42001e, video only
hls-567              mp4        400x224     567k , avc1.42001e, video only
dash-VIDEO-5         mp4        426x240    DASH video  599k , mp4_dash container, avc1.4d401e, 30fps, video only
dash-VIDEO-4         mp4        640x360    DASH video  797k , mp4_dash container, avc1.4d401e, 30fps, video only
hls-822              mp4        480x270     822k , avc1.42001e, video only
dash-VIDEO-3         mp4        854x480    DASH video 1193k , mp4_dash container, avc1.4d401f, 30fps, video only
hls-1334             mp4        640x360    1334k , avc1.4d001e, video only
hls-2001             mp4        960x540    2001k , avc1.4d001f, video only
dash-VIDEO-2         mp4        1280x720   DASH video 2380k , mp4_dash container, avc1.4d401f, 30fps, video only
hls-2621             mp4        1024x576   2621k , avc1.4d001f, video only (best)
blackjack4494 commented 3 years ago

Yeah that's probably because of the way youtube-dl defines what the best option is and that is plainly done by comparing size/bitrate if I remember correctly. Reddit extractor is using self._sort_formats(formats)
So maybe it's better to use a custom sort where higher resolution is picked over higher bitrate.

blackjack4494 commented 3 years ago

PS D:\gitkraken\youtube-dl> python3 -m youtube_dlc "https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/" -v -F [debug] System config: [] [debug] User config: [] [debug] Custom config: [] [debug] Command-line args: ['https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/', '-v', '-F'] [debug] Loading archive file None [debug] Encodings: locale cp65001, fs utf-8, out utf-8, pref cp65001 [debug] youtube-dlc version 2020.09.29 [debug] Git HEAD: 957c523ee [debug] Python version 3.6.5 (CPython) - Windows-10-10.0.19041-SP0 [debug] exe versions: ffmpeg 4.2.1, ffprobe 4.2.1 [debug] Proxy map: {} [RedditR] dhp55u: Downloading JSON metadata [Reddit] y1ew7xk4qhs31: Downloading m3u8 information [Reddit] y1ew7xk4qhs31: Downloading MPD manifest [info] Available formats for y1ew7xk4qhs31: format code extension resolution note hls-audio-0-Default mp4 audio only hls-audio-1-Default mp4 audio only dash-AUDIO-1 m4a audio only DASH audio 129k , m4a_dash container, mp4a.40.2 (48000Hz) hls-567 mp4 400x224 567k , avc1.42001e, video only hls-462 mp4 400x224 462k , avc1.42001e, video only dash-VIDEO-5 mp4 426x240 DASH video 599k , mp4_dash container, avc1.4d401e, 30fps, video only hls-822 mp4 480x270 822k , avc1.42001e, video only hls-1334 mp4 640x360 1334k , avc1.4d001e, video only dash-VIDEO-4 mp4 640x360 DASH video 797k , mp4_dash container, avc1.4d401e, 30fps, video only dash-VIDEO-3 mp4 854x480 DASH video 1193k , mp4_dash container, avc1.4d401f, 30fps, video only hls-2001 mp4 960x540 2001k , avc1.4d001f, video only hls-2621 mp4 1024x576 2621k , avc1.4d001f, video only dash-VIDEO-2 mp4 1280x720 DASH video 2380k , mp4_dash container, avc1.4d401f, 30fps, video only (best)

Hotfix is to change self._sort_formats(formats, ('height', 'width'))

nicolaasjan commented 3 years ago

Thanks!

I just cloned the repo; compiled a new executable and it works!


youtube-dlc -v https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/
[debug] System config: []
[debug] User config: ['-o', '/dev/shm/%(title)s.%(ext)s', '-f', 'bestvideo[height<=1080][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best', '--no-mtime', '--add-metadata', '--embed-thumbnail']
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/']
[debug] Loading archive file None
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dlc version 2020.09.29
[debug] Python version 3.6.9 (CPython) - Linux-4.15.0-122-generic-x86_64-with-LinuxMint-19.3-tricia
[debug] exe versions: ffmpeg N-99430-g9d8f9b2-Nico_20201001, ffprobe N-99430-g9d8f9b2-Nico_20201001
[debug] Proxy map: {}
[RedditR] dhp55u: Downloading JSON metadata
[Reddit] y1ew7xk4qhs31: Downloading m3u8 information
[Reddit] y1ew7xk4qhs31: Downloading MPD manifest
[Reddit] y1ew7xk4qhs31: Downloading thumbnail ...
[Reddit] y1ew7xk4qhs31: Writing thumbnail to: /dev/shm/We just met, but we made a doubles routine together! ♥️.jpg
[debug] Invoking downloader on 'https://vcf.redd.it/y1ew7xk4qhs31/DASH_720?Expires=1608555217&Signature=G2jy5reLNgdVfxh7OS1FLK87O66UpDZNFNr3c91Kg2jkTGhy3L1jS0eBiNEJCokZoNDNjHBvWuKBoPFiqXug~jvUsCh3pgjXZ1HLAEvmR~UG4wAsppJxtALxsleEKwaWXi4ZPpSDfkb3nAabMXWCXIxidw21~YprVUjUA47RYM5Eg4ZlWBh3cPAYP2sAWWUv53mbwnVhFPCJc6LYwf9-53c6UVpJeW0Uz4ECLeo7kFpnHLYKe0hEk1ljeAasDjwAyZcgkpahBCm~hN1HTG929WdCuzuCWuWh31Y9ygTqbghySCaMwmkXiSUgMU6TTZ0JtB8oz7AiaFtF0GyY9geW~wy-X1qYbkhOFhTq6FqsbNgl5QYzFoMuuRaCFR2ibyAUoN5FQma4-sjSSR7Ce4el5VBYI77kbyQPaU9GoXMTG1gniCel8IzCpDD-ZRj1Bef80nUwBlxkQzCZex4QaX7ZDI0sQsWyvIGRQ7omUL1UXwY2JDwdizT0GRrwyjjGt6diaPV~wOImG2LR2s62jhbIFU8uD6Is2SG8jLLWKKvLlX3ckHn2-4RljLjEsHKKZ8gJrpUHZaeEL6crN2AXqULoQM7bu3PPByM8ft94MWS12ACn7WmBOkhtz6K3i-MSvb4B3TJOgFnob3qn4X1YelWCyBUXYjR8pzneveKAcLvmLsA_&Key-Pair-Id=APKAIMMXAY5SL7WT6XIA'
[download] Destination: /dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-VIDEO-2.mp4
[download] 100% of 24.23MiB in 00:04
[debug] Invoking downloader on 'https://vcf.redd.it/y1ew7xk4qhs31/audio?Expires=1608555218&Signature=r8Vdwjmk3fqSUMF67RGq2BZstOO2FS5wVezny2R47oRFL5jzHC82tvAZEr5ecRCt9B72-Jkm-oZgbrmtMleFPWIot-o6LsTw55rBQBaYHnsM2cx9MNmmwAwblvl4-L~y7ShkwFBBmicpsi7i3gJAwHM9Z-2Q3ksq42WuEOZ~Kq4FPn9AdNiCJjKXLahKUisWDAFeNCuHyP5P7xFgS7TGDuBsjupoI0DYVmScJr36fgvmtBUBnlGdt3sB7NTv-GPMemlrs~fkoRfB~UJZyKmg49Wz~mCsWTR6DPmmj3-QP7uUmZ-ZfbZXMK21XB~6kMQvYN5KopQoeAJfBWkbXQVXkMH7UBHnrFgeKFYTc3rIE0M5vYy8P1ZnEE0VkMpPjg28e6RdJb3E-DstdxcN0FvhTgaVVyk34e~dTSLR0eTrUQl1F~82J42mWPAx9raYMbKO9NPcMi1JWNVFCCxeFEp6Wu~kT5sXGqmidYbNQu2QTQv3NqJVYqMb9Bybht0ScdBnz8K~DoWIwNNPOjCZMwU6LqcOMztBWBci06JC3WFgPwG7X-X6apDla9Lpl2cA1jj6fmOfQn71rJKIm867zq6dshS85fBcx03Ov-K~VhwB0DkzVe8jcZc4prbVRcZT7EbBJCnhsucnGvM3-DP21U~3gr8ay-RM0NatG2JPTTbcarw_&Key-Pair-Id=APKAIMMXAY5SL7WT6XIA'
[download] Destination: /dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-AUDIO-1.m4a
[download] 100% of 1.32MiB in 00:00
[ffmpeg] Merging formats into "/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-VIDEO-2.mp4' -i 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-AUDIO-1.m4a' -c copy -map 0:v:0 -map 1:a:0 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'
Deleting original file /dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-AUDIO-1.m4a (pass -k to keep)
Deleting original file /dev/shm/We just met, but we made a doubles routine together! ♥️.fdash-VIDEO-2.mp4 (pass -k to keep)
[ffmpeg] Adding metadata to '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' -map 0 -c copy -metadata 'title=We just met, but we made a doubles routine together! ♥️' -metadata date=20191014 -metadata purl=https://old.reddit.com/r/poledancing/comments/dhp55u/we_just_met_but_we_made_a_doubles_routine_together/ -metadata artist=h0l 'file:/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'
[atomicparsley] Adding thumbnail to "/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4"
[debug] AtomicParsley command line: AtomicParsley '/dev/shm/We just met, but we made a doubles routine together! ♥️.mp4' --artwork '/dev/shm/We just met, but we made a doubles routine together! ♥️.jpg' -o '/dev/shm/We just met, but we made a doubles routine together! ♥️.temp.mp4'