mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-10-03 23:43:21 -04:00
[extractor] Use classmethod/property where possible
and refactor lazy extractors accordingly. This reduces the need to create extractor instances
This commit is contained in:
@@ -11,7 +11,7 @@ import sys
|
||||
from .compat import compat_getpass, compat_os_name, compat_shlex_quote
|
||||
from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS
|
||||
from .downloader import FileDownloader
|
||||
from .extractor import list_extractors
|
||||
from .extractor import GenericIE, list_extractor_classes
|
||||
from .extractor.adobepass import MSO_INFO
|
||||
from .extractor.common import InfoExtractor
|
||||
from .options import parseOpts
|
||||
@@ -76,14 +76,20 @@ def get_urls(urls, batchfile, verbose):
|
||||
def print_extractor_information(opts, urls):
|
||||
out = ''
|
||||
if opts.list_extractors:
|
||||
for ie in list_extractors(opts.age_limit):
|
||||
urls = dict.fromkeys(urls, False)
|
||||
for ie in list_extractor_classes(opts.age_limit):
|
||||
out += ie.IE_NAME + (' (CURRENTLY BROKEN)' if not ie.working() else '') + '\n'
|
||||
out += ''.join(f' {url}\n' for url in filter(ie.suitable, urls))
|
||||
if ie == GenericIE:
|
||||
matched_urls = [url for url, matched in urls.items() if not matched]
|
||||
else:
|
||||
matched_urls = tuple(filter(ie.suitable, urls.keys()))
|
||||
urls.update(dict.fromkeys(matched_urls, True))
|
||||
out += ''.join(f' {url}\n' for url in matched_urls)
|
||||
elif opts.list_extractor_descriptions:
|
||||
_SEARCHES = ('cute kittens', 'slithering pythons', 'falling cat', 'angry poodle', 'purple fish', 'running tortoise', 'sleeping bunny', 'burping cow')
|
||||
out = '\n'.join(
|
||||
ie.description(markdown=False, search_examples=_SEARCHES)
|
||||
for ie in list_extractors(opts.age_limit) if ie.working() and ie.IE_DESC is not False) + '\n'
|
||||
for ie in list_extractor_classes(opts.age_limit) if ie.working() and ie.IE_DESC is not False)
|
||||
elif opts.ap_list_mso:
|
||||
out = 'Supported TV Providers:\n%s\n' % render_table(
|
||||
['mso', 'mso name'],
|
||||
@@ -862,7 +868,7 @@ def main(argv=None):
|
||||
sys.exit(f'\nERROR: {e}')
|
||||
|
||||
|
||||
from .extractor import gen_extractors
|
||||
from .extractor import gen_extractors, list_extractors
|
||||
__all__ = [
|
||||
'main',
|
||||
'YoutubeDL',
|
||||
|
Reference in New Issue
Block a user