[ytdl] add 'generic' option (#1680)

pull/1700/head
Mike Fährmann 3 years ago
parent d3da96142a
commit dff0da60f9
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1977,6 +1977,19 @@ Description
directly passed to youtube-dl.
extractor.ytdl.generic
----------------------
Type
``bool``
Default
``true``
Description
Controls the use of youtube-dl's generic extractor.
Set this option to ``"force"`` for the same effect as youtube-dl's
``--force-generic-extractor``.
extractor.ytdl.logging
----------------------
Type

@ -291,6 +291,7 @@
{
"enabled": false,
"format": null,
"generic": true,
"logging": true,
"module": "youtube_dl",
"raw-options": null

@ -9,7 +9,7 @@
"""Extractors for sites supported by youtube-dl"""
from .common import Extractor, Message
from .. import config
from .. import config, exception
class YoutubeDLExtractor(Extractor):
@ -31,10 +31,18 @@ class YoutubeDLExtractor(Extractor):
# find suitable youtube_dl extractor
self.ytdl_url = url = match.group(1)
for ie in module.extractor.gen_extractor_classes():
if ie.suitable(url):
self.ytdl_ie = ie
break
generic = config.interpolate(("extractor", "ytdl"), "generic", True)
if generic == "force":
self.ytdl_ie = ie = module.extractor.GenericIE
self.force_generic_extractor = True
else:
for ie in module.extractor.gen_extractor_classes():
if ie.suitable(url):
self.ytdl_ie = ie
break
if not generic and ie == module.extractor.GenericIE:
raise exception.NoExtractorError()
self.force_generic_extractor = False
# set subcategory to youtube_dl extractor's key
self.subcategory = ie.ie_key()
@ -47,6 +55,7 @@ class YoutubeDLExtractor(Extractor):
"socket_timeout": self._timeout,
"nocheckcertificate": not self._verify,
"proxy": self.session.proxies.get("http"),
"force_generic_extractor": self.force_generic_extractor,
}
raw_options = self.config("raw-options")

Loading…
Cancel
Save