2022-06-15 06:30:34 -06:00
|
|
|
from ..compat.compat_utils import passthrough_module
|
2014-11-26 12:01:20 -07:00
|
|
|
|
2022-06-15 06:30:34 -06:00
|
|
|
passthrough_module(__name__, '.extractors')
|
|
|
|
del passthrough_module
|
2021-05-08 09:15:14 -06:00
|
|
|
|
2013-08-24 13:10:03 -06:00
|
|
|
|
2016-02-10 05:16:18 -07:00
|
|
|
def gen_extractor_classes():
|
|
|
|
""" Return a list of supported extractors.
|
|
|
|
The order does matter; the first extractor matched is the one handling the URL.
|
|
|
|
"""
|
2022-06-15 06:30:34 -06:00
|
|
|
from .extractors import _ALL_CLASSES
|
|
|
|
|
2016-02-10 05:16:18 -07:00
|
|
|
return _ALL_CLASSES
|
|
|
|
|
|
|
|
|
2013-06-23 14:36:24 -06:00
|
|
|
def gen_extractors():
|
|
|
|
""" Return a list of an instance of every supported extractor.
|
|
|
|
The order does matter; the first extractor matched is the one handling the URL.
|
|
|
|
"""
|
2016-02-10 05:16:18 -07:00
|
|
|
return [klass() for klass in gen_extractor_classes()]
|
2013-06-23 14:36:24 -06:00
|
|
|
|
2013-08-24 13:10:03 -06:00
|
|
|
|
2022-05-11 09:54:44 -06:00
|
|
|
def list_extractor_classes(age_limit=None):
|
2022-05-08 22:32:17 -06:00
|
|
|
"""Return a list of extractors that are suitable for the given age, sorted by extractor name"""
|
2022-06-15 06:30:34 -06:00
|
|
|
from .generic import GenericIE
|
|
|
|
|
2022-05-11 09:54:44 -06:00
|
|
|
yield from sorted(filter(
|
2022-06-15 06:30:34 -06:00
|
|
|
lambda ie: ie.is_suitable(age_limit) and ie != GenericIE,
|
2022-05-11 09:54:44 -06:00
|
|
|
gen_extractor_classes()), key=lambda ie: ie.IE_NAME.lower())
|
2022-06-15 06:30:34 -06:00
|
|
|
yield GenericIE
|
2022-05-11 09:54:44 -06:00
|
|
|
|
|
|
|
|
|
|
|
def list_extractors(age_limit=None):
|
|
|
|
"""Return a list of extractor instances that are suitable for the given age, sorted by extractor name"""
|
|
|
|
return [ie() for ie in list_extractor_classes(age_limit)]
|
2015-01-06 23:20:20 -07:00
|
|
|
|
|
|
|
|
2013-06-23 14:36:24 -06:00
|
|
|
def get_info_extractor(ie_name):
|
|
|
|
"""Returns the info extractor class with the given ie_name"""
|
2022-06-15 06:30:34 -06:00
|
|
|
from . import extractors
|
|
|
|
|
|
|
|
return getattr(extractors, f'{ie_name}IE')
|