]>
Commit | Line | Data |
---|---|---|
560738f3 | 1 | from ..compat.compat_utils import passthrough_module |
dcddc10a | 2 | |
560738f3 | 3 | passthrough_module(__name__, '.extractors') |
4 | del passthrough_module | |
2f567473 | 5 | |
9460db83 | 6 | |
e52d7f85 JMF |
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 | """ | |
560738f3 | 11 | from .extractors import _ALL_CLASSES |
12 | ||
e52d7f85 JMF |
13 | return _ALL_CLASSES |
14 | ||
15 | ||
f9c6cbf0 PH |
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 | """ | |
e52d7f85 | 20 | return [klass() for klass in gen_extractor_classes()] |
f9c6cbf0 | 21 | |
9460db83 | 22 | |
82d02080 | 23 | def list_extractor_classes(age_limit=None): |
8dcce6a8 | 24 | """Return a list of extractors that are suitable for the given age, sorted by extractor name""" |
560738f3 | 25 | from .generic import GenericIE |
26 | ||
82d02080 | 27 | yield from sorted(filter( |
560738f3 | 28 | lambda ie: ie.is_suitable(age_limit) and ie != GenericIE, |
82d02080 | 29 | gen_extractor_classes()), key=lambda ie: ie.IE_NAME.lower()) |
560738f3 | 30 | yield GenericIE |
82d02080 | 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)] | |
05900629 PH |
36 | |
37 | ||
f9c6cbf0 PH |
38 | def get_info_extractor(ie_name): |
39 | """Returns the info extractor class with the given ie_name""" | |
560738f3 | 40 | from . import extractors |
41 | ||
42 | return getattr(extractors, f'{ie_name}IE') |