[generic] Support YouTube swf embed (Fixes #2010)
[youtube-dl] / youtube_dl / extractor / generic.py
index 209f68204ef7fd342edf8200e148f249a5d99266..75cb96eb713852f736716d462fd279d7cf669b20 100644 (file)
@@ -17,6 +17,7 @@ from ..utils import (
     url_basename,
 )
 from .brightcove import BrightcoveIE
+from .ooyala import OoyalaIE
 
 
 class GenericIE(InfoExtractor):
@@ -83,7 +84,17 @@ class GenericIE(InfoExtractor):
                 u'title': u'trailer',
                 u'upload_date': u'20100513',
             }
-        }
+        },
+        # ooyala video
+        {
+            u'url': u'http://www.rollingstone.com/music/videos/norwegian-dj-cashmere-cat-goes-spartan-on-with-me-premiere-20131219',
+            u'md5': u'5644c6ca5d5782c1d0d350dad9bd840c',
+            u'info_dict': {
+                u'id': u'BwY2RxaTrTkslxOfcan0UCf0YqyvWysJ',
+                u'ext': u'mp4',
+                u'title': u'2cc213299525360.mov', #that's what we get
+            },
+        },
     ]
 
     def report_download_webpage(self, video_id):
@@ -164,18 +175,18 @@ class GenericIE(InfoExtractor):
 
             # Check for direct link to a video
             content_type = response.headers.get('Content-Type', '')
-            m = re.match(r'^(?:audio|video)/(?P<format_id>.+)$', content_type)
+            m = re.match(r'^(?P<type>audio|video|application(?=/ogg$))/(?P<format_id>.+)$', content_type)
             if m:
                 upload_date = response.headers.get('Last-Modified')
                 if upload_date:
                     upload_date = unified_strdate(upload_date)
-                assert (url_basename(url) == 'trailer.mp4')
                 return {
                     'id': video_id,
                     'title': os.path.splitext(url_basename(url))[0],
                     'formats': [{
                         'format_id': m.group('format_id'),
                         'url': url,
+                        'vcodec': u'none' if m.group('type') == 'audio' else None
                     }],
                     'upload_date': upload_date,
                 }
@@ -222,8 +233,11 @@ class GenericIE(InfoExtractor):
             return self.url_result(surl, 'Vimeo')
 
         # Look for embedded YouTube player
-        matches = re.findall(
-            r'<iframe[^>]+?src=(["\'])(?P<url>(?:https?:)?//(?:www\.)?youtube\.com/embed/.+?)\1', webpage)
+        matches = re.findall(r'''(?x)
+            (?:<iframe[^>]+?src=|embedSWF\(\s*)
+            (["\'])(?P<url>(?:https?:)?//(?:www\.)?youtube\.com/
+                (?:embed|v)/.+?)
+            \1''', webpage)
         if matches:
             urlrs = [self.url_result(unescapeHTML(tuppl[1]), 'Youtube')
                      for tuppl in matches]
@@ -277,6 +291,11 @@ class GenericIE(InfoExtractor):
         if mobj is not None:
             return self.url_result(mobj.group('url'))
 
+        # Look for Ooyala videos
+        mobj = re.search(r'player.ooyala.com/[^"?]+\?[^"]*?(?:embedCode|ec)=([^"&]+)', webpage)
+        if mobj is not None:
+            return OoyalaIE._build_url_result(mobj.group(1))
+
         # Start with something easy: JW Player in SWFObject
         mobj = re.search(r'flashvars: [\'"](?:.*&)?file=(http[^\'"&]*)', webpage)
         if mobj is None: