ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.99k stars 10.01k forks source link

--match-filter "!is_live" : does not work for youtube live channel url #29647

Open TapasKumarKundu opened 3 years ago

TapasKumarKundu commented 3 years ago

Checklist

Verbose log

tkundu2@tkundu-desktop:~$ youtube-dl -v --match-filter "!is_live" -F "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow/live"
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--match-filter', u'!is_live', u'-F', u'https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow/live']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 2.7.17 (CPython) - Linux-5.4.0-77-generic-x86_64-with-Ubuntu-18.04-bionic
[debug] exe versions: ffmpeg 3.4.8, ffprobe 3.4.8, phantomjs 2.1.1, rtmpdump 2.4
[debug] Proxy map: {}
[youtube:tab] UCSJ4gkVC6NrvII8umztf0Ow: Downloading webpage
[youtube] DWcJFNfaw9c: Downloading webpage
[youtube] DWcJFNfaw9c: Downloading m3u8 information
[youtube] DWcJFNfaw9c: Downloading MPD manifest
[info] Available formats for DWcJFNfaw9c:
format code  extension  resolution note
91           mp4        256x144     290k , avc1.42c00b, 15.0fps, mp4a.40.5
92           mp4        426x240     546k , avc1.4d4015, 30.0fps, mp4a.40.5
93           mp4        640x360    1209k , avc1.4d401e, 30.0fps, mp4a.40.2
94           mp4        854x480    1568k , avc1.4d401f, 30.0fps, mp4a.40.2
95           mp4        1280x720   2969k , avc1.4d401f, 30.0fps, mp4a.40.2
96           mp4        1920x1080  5420k , avc1.640028, 30.0fps, mp4a.40.2 (best)
tkundu2@tkundu-desktop:~$ 

Description

I am trying with following command to see if --match-file "is_live" works or not. youtube-dl -v --match-filter "!is_live" -F "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow/live"

My expectation was above command will print error. but instead it is printing details about live video !!

Could you please fix this bug

dirkf commented 3 years ago

From the manual

--match-filter FILTER Generic video filter. Specify any key (see the "OUTPUT TEM‐ PLATE" for a list of available keys) to match if the key is present, !key to check if the key is not present, ...

is_live is a valid possible key according to the referenced section, good.

$ youtube-dl -j DWcJFNfaw9c
{'is_live': true, ...
$ youtube-dl -v --match-filter '!is_live' -j DWcJFNfaw9c
[debug] System config: ['--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--match-filter', '!is_live', '-j', 'DWcJFNfaw9c']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.5.2 (CPython) - Linux-4.4.0-210-generic-i686-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[debug] Default format spec: bestvideo+bestaudio/best
$

So (a) is_live is present for the item in your example (b) it's true, and !is_live blocks the download (maybe it would have done so even with 'is_live': false?).

The issue is that -F produces output and returns before the filter is applied. Compare your output with this:

$ youtube-dl -v --match-filter '!is_live' --flat-playlist "https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow/live"
[debug] System config: ['--prefer-ffmpeg']
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--match-filter', '!is_live', '--flat-playlist', 'https://www.youtube.com/channel/UCSJ4gkVC6NrvII8umztf0Ow/live']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.5.2 (CPython) - Linux-4.4.0-210-generic-i686-with-Ubuntu-16.04-xenial
[debug] exe versions: avconv 4.3, avprobe 4.3, ffmpeg 4.3, ffprobe 4.3
[debug] Proxy map: {}
[youtube:tab] UCSJ4gkVC6NrvII8umztf0Ow: Downloading webpage
[youtube] DWcJFNfaw9c: Downloading webpage
[youtube] DWcJFNfaw9c: Downloading m3u8 information
[youtube] DWcJFNfaw9c: Downloading MPD manifest
[debug] Default format spec: best/bestvideo+bestaudio
[download] lofi hip hop radio - beats to sleep/chill to 2021-07-25 12:50 does not pass filter !is_live, skipping ..
$

Also, with bash, use '' around the filter instead of "".