Merge pull request #5961 from dstftw/force-generic-extractor
authorSergey M. <dstftw@gmail.com>
Wed, 24 Jun 2015 14:10:45 +0000 (19:10 +0500)
committerSergey M. <dstftw@gmail.com>
Wed, 24 Jun 2015 14:10:45 +0000 (19:10 +0500)
Add --force-generic-extractor

youtube_dl/YoutubeDL.py
youtube_dl/__init__.py
youtube_dl/extractor/generic.py
youtube_dl/options.py

index 6e4b6f56664f67a796b21f10b8d005f2f6e5b68d..ef0f71bad45d6057dc99c1ce968629a0e357e57b 100755 (executable)
@@ -139,6 +139,7 @@ class YoutubeDL(object):
     outtmpl:           Template for output names.
     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
     nooverwrites:      Prevent overwriting files.
     playliststart:     Playlist item to start at.
     playlistend:       Playlist item to end at.
@@ -626,13 +627,16 @@ class YoutubeDL(object):
             info_dict.setdefault(key, value)
 
     def extract_info(self, url, download=True, ie_key=None, extra_info={},
-                     process=True):
+                     process=True, force_generic_extractor=False):
         '''
         Returns a list with a dictionary for each video we find.
         If 'download', also downloads the videos.
         extra_info is a dict containing the extra values to add to each result
         '''
 
+        if not ie_key and force_generic_extractor:
+            ie_key = 'Generic'
+
         if ie_key:
             ies = [self.get_info_extractor(ie_key)]
         else:
@@ -1493,7 +1497,8 @@ class YoutubeDL(object):
         for url in url_list:
             try:
                 # It also downloads the videos
-                res = self.extract_info(url)
+                res = self.extract_info(
+                    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
             except UnavailableVideoError:
                 self.report_error('unable to download video')
             except MaxDownloadsReached:
index ace17857c8cb28320ba1fab2988e56c020583af7..215b616de710705d3df73d0cb7dbf14d5dc08848 100644 (file)
@@ -293,6 +293,7 @@ def _real_main(argv=None):
         'autonumber_size': opts.autonumber_size,
         'restrictfilenames': opts.restrictfilenames,
         'ignoreerrors': opts.ignoreerrors,
+        'force_generic_extractor': opts.force_generic_extractor,
         'ratelimit': opts.ratelimit,
         'nooverwrites': opts.nooverwrites,
         'retries': opts_retries,
index 5c03fddc6a2ee548a6617a3aea9ba161f6b3777d..7769ffc5c5f425ce04dc92147c77803291f0fdd5 100644 (file)
@@ -1014,7 +1014,9 @@ class GenericIE(InfoExtractor):
             }
 
         if not self._downloader.params.get('test', False) and not is_intentional:
-            self._downloader.report_warning('Falling back on generic information extractor.')
+            force = self._downloader.params.get('force_generic_extractor', False)
+            self._downloader.report_warning(
+                '%s on generic information extractor.' % ('Forcing' if force else 'Falling back'))
 
         if not full_response:
             request = compat_urllib_request.Request(url)
index 740458e51483f45f8d8474d68edaaac48b24941e..6aeca61ee5e099e80a5d98a893afb8adde72e1cd 100644 (file)
@@ -150,6 +150,10 @@ def parseOpts(overrideArguments=None):
         '--extractor-descriptions',
         action='store_true', dest='list_extractor_descriptions', default=False,
         help='Output descriptions of all supported extractors')
+    general.add_option(
+        '--force-generic-extractor',
+        action='store_true', dest='force_generic_extractor', default=False,
+        help='Force extraction to use the generic extractor')
     general.add_option(
         '--default-search',
         dest='default_search', metavar='PREFIX',