]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/__init__.py
[ie/youtube] Suppress "Unavailable videos are hidden" warning (#10159)
[yt-dlp.git] / yt_dlp / extractor / __init__.py
1 from ..compat.compat_utils import passthrough_module
2
3 passthrough_module(__name__, '.extractors')
4 del passthrough_module
5
6
7 def gen_extractor_classes():
8 """ Return a list of supported extractors.
9 The order does matter; the first extractor matched is the one handling the URL.
10 """
11 from .extractors import _ALL_CLASSES
12
13 return _ALL_CLASSES
14
15
16 def gen_extractors():
17 """ Return a list of an instance of every supported extractor.
18 The order does matter; the first extractor matched is the one handling the URL.
19 """
20 return [klass() for klass in gen_extractor_classes()]
21
22
23 def list_extractor_classes(age_limit=None):
24 """Return a list of extractors that are suitable for the given age, sorted by extractor name"""
25 from .generic import GenericIE
26
27 yield from sorted(filter(
28 lambda ie: ie.is_suitable(age_limit) and ie != GenericIE,
29 gen_extractor_classes()), key=lambda ie: ie.IE_NAME.lower())
30 yield GenericIE
31
32
33 def list_extractors(age_limit=None):
34 """Return a list of extractor instances that are suitable for the given age, sorted by extractor name"""
35 return [ie() for ie in list_extractor_classes(age_limit)]
36
37
38 def get_info_extractor(ie_name):
39 """Returns the info extractor class with the given ie_name"""
40 from . import extractors
41
42 return getattr(extractors, f'{ie_name}IE')