]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/__init__.py
[skip travis] renaming
[yt-dlp.git] / youtube_dlc / extractor / __init__.py
CommitLineData
dcddc10a
PH
1from __future__ import unicode_literals
2
779822d9
JMF
3try:
4 from .lazy_extractors import *
5 from .lazy_extractors import _ALL_CLASSES
e0986e31 6 _LAZY_LOADER = True
779822d9 7except ImportError:
e0986e31 8 _LAZY_LOADER = False
779822d9
JMF
9 from .extractors import *
10
11 _ALL_CLASSES = [
12 klass
13 for name, klass in globals().items()
14 if name.endswith('IE') and name != 'GenericIE'
15 ]
16 _ALL_CLASSES.append(GenericIE)
f9c6cbf0 17
9460db83 18
e52d7f85
JMF
19def gen_extractor_classes():
20 """ Return a list of supported extractors.
21 The order does matter; the first extractor matched is the one handling the URL.
22 """
23 return _ALL_CLASSES
24
25
f9c6cbf0
PH
26def gen_extractors():
27 """ Return a list of an instance of every supported extractor.
28 The order does matter; the first extractor matched is the one handling the URL.
29 """
e52d7f85 30 return [klass() for klass in gen_extractor_classes()]
f9c6cbf0 31
9460db83 32
05900629
PH
33def list_extractors(age_limit):
34 """
35 Return a list of extractors that are suitable for the given age,
36 sorted by extractor ID.
37 """
38
39 return sorted(
40 filter(lambda ie: ie.is_suitable(age_limit), gen_extractors()),
41 key=lambda ie: ie.IE_NAME.lower())
42
43
f9c6cbf0
PH
44def get_info_extractor(ie_name):
45 """Returns the info extractor class with the given ie_name"""
8bcc8756 46 return globals()[ie_name + 'IE']