From: Ismael Mejia Date: Fri, 6 Sep 2013 21:23:23 +0000 (+0200) Subject: Merge branch 'master' into subtitles_rework X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=72836fcee453386f4f16325c5b8fa4c1ba1bb442;p=youtube-dl Merge branch 'master' into subtitles_rework --- 72836fcee453386f4f16325c5b8fa4c1ba1bb442 diff --cc youtube_dl/extractor/dailymotion.py index 003b1d8c3,3c616e089..f7dffd4cc --- a/youtube_dl/extractor/dailymotion.py +++ b/youtube_dl/extractor/dailymotion.py @@@ -17,27 -11,10 +17,27 @@@ from ..utils import ExtractorError, ) -class DailymotionIE(InfoExtractor): + +class DailyMotionSubtitlesIE(NoAutoSubtitlesIE): + + def _get_available_subtitles(self, video_id): + request = compat_urllib_request.Request('https://api.dailymotion.com/video/%s/subtitles?fields=id,language,url' % video_id) + try: + sub_list = compat_urllib_request.urlopen(request).read().decode('utf-8') + except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: + self._downloader.report_warning(u'unable to download video subtitles: %s' % compat_str(err)) + return {} + info = json.loads(sub_list) + if (info['total'] > 0): + sub_lang_list = dict((l['language'], l['url']) for l in info['list']) + return sub_lang_list + self._downloader.report_warning(u'video doesn\'t have subtitles') + return {} + +class DailymotionIE(DailyMotionSubtitlesIE, InfoExtractor): """Information Extractor for Dailymotion""" - _VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/video/([^/]+)' + _VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/(?:embed/)?video/([^/]+)' IE_NAME = u'dailymotion' _TEST = { u'url': u'http://www.dailymotion.com/video/x33vw9_tutoriel-de-youtubeur-dl-des-video_tech',