[extractor/common] Add method for extracting form hidden input fields as dict
authorSergey M․ <dstftw@gmail.com>
Fri, 10 Jul 2015 15:49:09 +0000 (21:49 +0600)
committerSergey M․ <dstftw@gmail.com>
Fri, 10 Jul 2015 15:49:09 +0000 (21:49 +0600)
youtube_dl/extractor/common.py

index d859aea5285f331c43e44b95b41a12aee0f41f87..82f5de2d898c4238839b8ada7c43aea6b166fd5f 100644 (file)
@@ -705,6 +705,12 @@ class InfoExtractor(object):
         return self._html_search_meta('twitter:player', html,
                                       'twitter card player')
 
+    @staticmethod
+    def _form_hidden_inputs(html):
+        return dict(re.findall(
+            r'<input\s+type="hidden"\s+name="([^"]+)"\s+(?:id="[^"]+"\s+)?value="([^"]*)"',
+            html))
+
     def _sort_formats(self, formats, field_preference=None):
         if not formats:
             raise ExtractorError('No video formats found')