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