a0a53445a5b32563f6ade427d8a3ae0ee74d43aa
[youtube-dl] / youtube_dl / extractor / __init__.py
1 from __future__ import unicode_literals
2
3 from .extractors import *
4
5 _ALL_CLASSES = [
6     klass
7     for name, klass in globals().items()
8     if name.endswith('IE') and name != 'GenericIE'
9 ]
10 _ALL_CLASSES.append(GenericIE)
11
12
13 def gen_extractor_classes():
14     """ Return a list of supported extractors.
15     The order does matter; the first extractor matched is the one handling the URL.
16     """
17     return _ALL_CLASSES
18
19
20 def gen_extractors():
21     """ Return a list of an instance of every supported extractor.
22     The order does matter; the first extractor matched is the one handling the URL.
23     """
24     return [klass() for klass in gen_extractor_classes()]
25
26
27 def list_extractors(age_limit):
28     """
29     Return a list of extractors that are suitable for the given age,
30     sorted by extractor ID.
31     """
32
33     return sorted(
34         filter(lambda ie: ie.is_suitable(age_limit), gen_extractors()),
35         key=lambda ie: ie.IE_NAME.lower())
36
37
38 def get_info_extractor(ie_name):
39     """Returns the info extractor class with the given ie_name"""
40     return globals()[ie_name + 'IE']