]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/__init__.py
[extractor] Use classmethod/property where possible
[yt-dlp.git] / yt_dlp / __init__.py
index 924604631aa2e6f9b3719e1ff39a138faee266f7..0a8bf37b6501f23308652c9b85ac21f966a73029 100644 (file)
@@ -11,7 +11,7 @@
 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',