[vlc-devel] [PATCH 2/4] ytdl: access module for YoutubeDL

Marvin Scholz epirat07 at gmail.com
Tue Sep 22 23:25:10 CEST 2020


On 22 Sep 2020, at 22:31, Rémi Denis-Courmont wrote:

> Le tiistaina 22. syyskuuta 2020, 21.06.01 EEST Pierre Ynard via 
> vlc-devel a écrit :
>> On Tue, Sep 22, 2020, Pierre Ynard wrote:
>>> It forks a new process and launches the python interpreter in it, 
>>> then
>>> youtube-dl checks the URL against its list of supported websites. If
>>> unsupported, it throws an exception
>>
>> Wait I just noticed that in at least some if not all cases, it 
>> actually
>> connects to the website, sends a HEAD then a GET request, and 
>> downloads
>> the whole page, before figuring out that the website is unsupported 
>> and
>> exiting?! That's some god-awful and rather pointless overhead, why??
>
> https://github.com/ytdl-org/youtube-dl/blob/master/README.md#how-can-i-detect-whether-a-given-url-is-supported-by-youtube-dl
>

IMO it's a bad idea to use the generic parser even though it has its 
benefits, those
mentioned points in the readme might make sense if explicitly requested 
by the user
but for a case like VLC where every URL will be passed to it, it seems 
quite
wasteful to make a request to each URL just because it might be 
handleable by the
default extractor…

So while not officially supported, we could detect if a URL is supported 
by
doing:

import sys
import youtube_dl


dl = youtube_dl.YoutubeDL()

ie = [ie for ie in youtube_dl.list_extractors(99)
         if ie.suitable(url) and ie.__class__.__name__ != 'GenericIE']

if len(ie) == 0:
     print("Error: Unhandled URL", file=sys.stderr)
     sys.exit(1)

and fail fast this way.

> -- 
> Rémi Denis-Courmont
> http://www.remlab.net/
>
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list