Merge remote-tracking branch 'anovicecodemonkey/TEDIEimprovements'
authorPhilipp Hagemeister <phihag@phihag.de>
Thu, 20 Mar 2014 15:24:34 +0000 (16:24 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Thu, 20 Mar 2014 15:24:34 +0000 (16:24 +0100)
youtube_dl/extractor/generic.py
youtube_dl/extractor/ted.py

index 5a493314699b131febf06e4af25695b3f862cded..273a3e282028081a397b94c5226f89645f248c91 100644 (file)
@@ -487,6 +487,13 @@ class GenericIE(InfoExtractor):
         if mobj is None:
             # Broaden the search a little bit: JWPlayer JS loader
             mobj = re.search(r'[^A-Za-z0-9]?file["\']?:\s*["\'](http(?![^\'"]+\.[0-9]+[\'"])[^\'"]+)["\']', webpage)
+
+        # Look for embedded TED player
+        mobj = re.search(
+            r'<iframe[^>]+?src=(["\'])(?P<url>http://embed\.ted\.com/.+?)\1', webpage)
+        if mobj is not None:
+            return self.url_result(mobj.group('url'), 'TED')
+
         if mobj is None:
             # Try to find twitter cards info
             mobj = re.search(r'<meta (?:property|name)="twitter:player:stream" (?:content|value)="(.+?)"', webpage)
index 3968b718e9ad7a62664c3224452e6d57dce042e0..aab026936bc542b7e333c09e28add575024c2cb1 100644 (file)
@@ -11,7 +11,7 @@ from ..utils import (
 
 
 class TEDIE(SubtitlesInfoExtractor):
-    _VALID_URL = r'''(?x)http://www\.ted\.com/
+    _VALID_URL = r'''(?x)http://(?P<type>www|embed)\.ted\.com/
         (
             (?P<type_playlist>playlists(?:/\d+)?) # We have a playlist
             |
@@ -48,6 +48,9 @@ class TEDIE(SubtitlesInfoExtractor):
 
     def _real_extract(self, url):
         m = re.match(self._VALID_URL, url, re.VERBOSE)
+        if m.group('type') == 'embed': # if the _VALID_URL is an embed 
+            desktop_url = re.sub("embed", "www", url) 
+            return self.url_result(desktop_url, 'TED') # pass the desktop version to the extractor
         name = m.group('name')
         if m.group('type_talk'):
             return self._talk_info(url, name)