diff options
author | Ismaël Mejía <iemejia@gmail.com> | 2013-11-05 12:00:13 +0100 |
---|---|---|
committer | Ismaël Mejía <iemejia@gmail.com> | 2013-11-05 12:00:13 +0100 |
commit | 4ed3e51080dea651b3db8889b0c8f2e40d261075 (patch) | |
tree | b11a60728cd1c1138e081fe1c4be62866e8f5230 /youtube_dl/extractor | |
parent | 38fcd4597aac71c20583c7869479727b6065a9bb (diff) |
[ted] fixed error in case of no subtitles present
I created a test, but I leave it commented since TED videos get
new subtitles frequently.
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/ted.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/youtube_dl/extractor/ted.py b/youtube_dl/extractor/ted.py index 239e2a448..1b006bc9b 100644 --- a/youtube_dl/extractor/ted.py +++ b/youtube_dl/extractor/ted.py @@ -3,6 +3,11 @@ import re from .subtitles import SubtitlesInfoExtractor +from ..utils import ( + compat_str, + RegexNotFoundError, +) + class TEDIE(SubtitlesInfoExtractor): _VALID_URL=r'''http://www\.ted\.com/ ( @@ -105,12 +110,15 @@ class TEDIE(SubtitlesInfoExtractor): return info def _get_available_subtitles(self, video_id, webpage): - options = self._search_regex(r'(?:<select name="subtitles_language_select" id="subtitles_language_select">)(.*?)(?:</select>)', webpage, 'subtitles_language_select', flags=re.DOTALL) - languages = re.findall(r'(?:<option value=")(\S+)"', options) - if languages: - sub_lang_list = {} - for l in languages: - url = 'http://www.ted.com/talks/subtitles/id/%s/lang/%s/format/srt' % (video_id, l) - sub_lang_list[l] = url - return sub_lang_list + try: + options = self._search_regex(r'(?:<select name="subtitles_language_select" id="subtitles_language_select">)(.*?)(?:</select>)', webpage, 'subtitles_language_select', flags=re.DOTALL) + languages = re.findall(r'(?:<option value=")(\S+)"', options) + if languages: + sub_lang_list = {} + for l in languages: + url = 'http://www.ted.com/talks/subtitles/id/%s/lang/%s/format/srt' % (video_id, l) + sub_lang_list[l] = url + return sub_lang_list + except RegexNotFoundError as err: + self._downloader.report_warning(u'video doesn\'t have subtitles') return {} |