2022-06-15 08:30:34 -04:00
|
|
|
from ..compat.compat_utils import passthrough_module
|
2014-11-26 14:01:20 -05:00
|
|
|
|
2022-06-15 08:30:34 -04:00
|
|
|
passthrough_module(__name__, '.extractors')
|
|
|
|
del passthrough_module
|
2021-05-08 11:15:14 -04:00
|
|
|
|
2013-08-24 15:10:03 -04:00
|
|
|
|
2016-02-10 07:16:18 -05: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 08:30:34 -04:00
|
|
|
from .extractors import _ALL_CLASSES
|
|
|
|
|
2016-02-10 07:16:18 -05:00
|
|
|
return _ALL_CLASSES
|
|
|
|
|
|
|
|
|
2013-06-23 16:36:24 -04: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 07:16:18 -05:00
|
|
|
return [klass() for klass in gen_extractor_classes()]
|
2013-06-23 16:36:24 -04:00
|
|
|
|
2013-08-24 15:10:03 -04:00
|
|
|
|
2022-05-11 11:54:44 -04:00
|
|
|
def list_extractor_classes(age_limit=None):
|
2022-05-09 00:32:17 -04:00
|
|
|
"""Return a list of extractors that are suitable for the given age, sorted by extractor name"""
|
2022-06-15 08:30:34 -04:00
|
|
|
from .generic import GenericIE
|
|
|
|
|
2022-05-11 11:54:44 -04:00
|
|
|
yield from sorted(filter(
|
2022-06-15 08:30:34 -04:00
|
|
|
lambda ie: ie.is_suitable(age_limit) and ie != GenericIE,
|
2022-05-11 11:54:44 -04:00
|
|
|
gen_extractor_classes()), key=lambda ie: ie.IE_NAME.lower())
|
2022-06-15 08:30:34 -04:00
|
|
|
yield GenericIE
|
2022-05-11 11:54:44 -04: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-07 01:20:20 -05:00
|
|
|
|
|
|
|
|
2013-06-23 16:36:24 -04:00
|
|
|
def get_info_extractor(ie_name):
|
|
|
|
"""Returns the info extractor class with the given ie_name"""
|
2022-06-15 08:30:34 -04:00
|
|
|
from . import extractors
|
|
|
|
|
|
|
|
return getattr(extractors, f'{ie_name}IE')
|