]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/__init__.py
debian/copyright: Update my copyright years.
[youtubedl] / youtube_dl / extractor / __init__.py
1 from __future__ import unicode_literals
2
3 try:
4 from .lazy_extractors import *
5 from .lazy_extractors import _ALL_CLASSES
6 _LAZY_LOADER = True
7 except ImportError:
8 _LAZY_LOADER = False
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)
17
18
19 def 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
26 def 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 """
30 return [klass() for klass in gen_extractor_classes()]
31
32
33 def 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
44 def get_info_extractor(ie_name):
45 """Returns the info extractor class with the given ie_name"""
46 return globals()[ie_name + 'IE']