X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fted.py;h=10b3b706a9c82ef8398d408a948e72b6c52b31c3;hb=ecd1936695e73ba850d0618828b4a40d7d16c091;hp=8550380779168a80b95e526f8921059e2eddf8f4;hpb=0b201a3134e9b343e2791f2686f1a34f737007a4;p=youtube-dl diff --git a/youtube_dl/extractor/ted.py b/youtube_dl/extractor/ted.py index 855038077..10b3b706a 100644 --- a/youtube_dl/extractor/ted.py +++ b/youtube_dl/extractor/ted.py @@ -5,7 +5,7 @@ import re from .subtitles import SubtitlesInfoExtractor -from ..utils import ( +from ..compat import ( compat_str, ) @@ -13,7 +13,7 @@ from ..utils import ( class TEDIE(SubtitlesInfoExtractor): _VALID_URL = r'''(?x) (?Phttps?://) - (?Pwww|embed)(?P\.ted\.com/ + (?Pwww|embed(?:-ssl)?)(?P\.ted\.com/ ( (?Pplaylists(?:/\d+)?) # We have a playlist | @@ -33,9 +33,9 @@ class TEDIE(SubtitlesInfoExtractor): 'ext': 'mp4', 'title': 'The illusion of consciousness', 'description': ('Philosopher Dan Dennett makes a compelling ' - 'argument that not only don\'t we understand our own ' - 'consciousness, but that half the time our brains are ' - 'actively fooling us.'), + 'argument that not only don\'t we understand our own ' + 'consciousness, but that half the time our brains are ' + 'actively fooling us.'), 'uploader': 'Dan Dennett', 'width': 854, 'duration': 1308, @@ -93,12 +93,12 @@ class TEDIE(SubtitlesInfoExtractor): def _extract_info(self, webpage): info_json = self._search_regex(r'q\("\w+.init",({.+})\)', - webpage, 'info json') + webpage, 'info json') return json.loads(info_json) def _real_extract(self, url): m = re.match(self._VALID_URL, url, re.VERBOSE) - if m.group('type') == 'embed': + if m.group('type').startswith('embed'): desktop_url = m.group('proto') + 'www' + m.group('urlmain') return self.url_result(desktop_url, 'TED') name = m.group('name') @@ -113,7 +113,7 @@ class TEDIE(SubtitlesInfoExtractor): '''Returns the videos of the playlist''' webpage = self._download_webpage(url, name, - 'Downloading playlist webpage') + 'Downloading playlist webpage') info = self._extract_info(webpage) playlist_info = info['playlist'] @@ -199,8 +199,9 @@ class TEDIE(SubtitlesInfoExtractor): webpage = self._download_webpage(url, name) config_json = self._html_search_regex( - r"data-config='([^']+)", webpage, 'config') - config = json.loads(config_json) + r'"pages\.jwplayer"\s*,\s*({.+?})\s*\)\s*', + webpage, 'config') + config = json.loads(config_json)['config'] video_url = config['video']['url'] thumbnail = config.get('image', {}).get('url')