[ytdl] set domain as subcategory when using Generic extractor (#6582)

https://github.com/mikf/gallery-dl/issues/6582#issuecomment-2959879730
This commit is contained in:
Mike Fährmann
2025-06-10 20:48:16 +02:00
parent 4cfddc144a
commit 8e698d1a64
4 changed files with 28 additions and 3 deletions

View File

@@ -5707,12 +5707,24 @@ Type
Default
``true``
Description
Enables the use of |ytdl's| ``generic`` extractor.
Enables the use of |ytdl's| ``Generic`` extractor.
Set this option to ``"force"`` for the same effect as
``--force-generic-extractor``.
extractor.ytdl.generic-category
-------------------------------
Type
``bool``
Default
``true``
Description
When using |ytdl's| ``Generic`` extractor,
change `category` to ``"ytdl-generic"`` and
set `subcategory` to the input URL's domain.
extractor.ytdl.logging
----------------------
Type

View File

@@ -808,6 +808,7 @@
"enabled" : false,
"format" : null,
"generic" : true,
"generic-category": true,
"logging" : true,
"module" : null,
"raw-options" : null

View File

@@ -42,8 +42,14 @@ class YoutubeDLExtractor(Extractor):
raise exception.NoExtractorError()
self.force_generic_extractor = False
# set subcategory to youtube_dl extractor's key
self.subcategory = self.ytdl_ie_key
if self.ytdl_ie_key == "Generic" and config.interpolate(
("extractor", "ytdl"), "generic-category", True):
# set subcategory to URL domain
self.category = "ytdl-generic"
self.subcategory = url[url.rfind("/", None, 8)+1:url.find("/", 8)]
else:
# set subcategory to youtube_dl extractor's key
self.subcategory = self.ytdl_ie_key
Extractor.__init__(self, match)
def items(self):

View File

@@ -14,4 +14,10 @@ __tests__ = (
"#class" : ytdl.YoutubeDLExtractor,
},
{
"#url" : "ytdl:http://media.w3.org/2010/05/sintel/trailer.mp4",
"#category": ("", "ytdl-generic", "media.w3.org"),
"#class" : ytdl.YoutubeDLExtractor,
},
)