From 33a4446c892128076a3102c0b24d500867100fef Mon Sep 17 00:00:00 2001 From: jbuzzard Date: Fri, 13 May 2016 16:08:26 -0700 Subject: [PATCH] add "--no-generic-extractor" flag which excludes usage of the generic extractor when processing a url. --- youtube_dl/YoutubeDL.py | 9 +++++++-- youtube_dl/__init__.py | 1 + youtube_dl/options.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 03a6a1890..5611aacd3 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -150,6 +150,7 @@ class YoutubeDL(object): restrictfilenames: Do not allow "&" and spaces in file names ignoreerrors: Do not stop on download errors. force_generic_extractor: Force downloader to use the generic extractor + no_generic_extractor: Prevent usage of the generic extractor nooverwrites: Prevent overwriting files. playliststart: Playlist item to start at. playlistend: Playlist item to end at. @@ -648,7 +649,7 @@ class YoutubeDL(object): info_dict.setdefault(key, value) def extract_info(self, url, download=True, ie_key=None, extra_info={}, - process=True, force_generic_extractor=False): + process=True, force_generic_extractor=False, no_generic_extractor=False): ''' Returns a list with a dictionary for each video we find. If 'download', also downloads the videos. @@ -664,6 +665,8 @@ class YoutubeDL(object): ies = self._ies for ie in ies: + if(ie.ie_key() == "Generic" and no_generic_extractor): + continue if not ie.suitable(url): continue @@ -1733,7 +1736,9 @@ class YoutubeDL(object): try: # It also downloads the videos res = self.extract_info( - url, force_generic_extractor=self.params.get('force_generic_extractor', False)) + url, + force_generic_extractor=self.params.get('force_generic_extractor', False), + no_generic_extractor=self.params.get('no_generic_extractor', False)) except UnavailableVideoError: self.report_error('unable to download video') except MaxDownloadsReached: diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 5df965191..135356e0a 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -305,6 +305,7 @@ def _real_main(argv=None): 'restrictfilenames': opts.restrictfilenames, 'ignoreerrors': opts.ignoreerrors, 'force_generic_extractor': opts.force_generic_extractor, + 'no_generic_extractor': opts.no_generic_extractor, 'ratelimit': opts.ratelimit, 'nooverwrites': opts.nooverwrites, 'retries': opts.retries, diff --git a/youtube_dl/options.py b/youtube_dl/options.py index 38efd292d..c6378cb22 100644 --- a/youtube_dl/options.py +++ b/youtube_dl/options.py @@ -154,6 +154,10 @@ def parseOpts(overrideArguments=None): '--force-generic-extractor', action='store_true', dest='force_generic_extractor', default=False, help='Force extraction to use the generic extractor') + general.add_option( + '--no-generic-extractor', + action='store_true', dest='no_generic_extractor', default=False, + help='prevent extraction from using the generic extractor') general.add_option( '--default-search', dest='default_search', metavar='PREFIX',