[internal] Improved subtitle architecture + (update in
youtube/dailymotion) The structure of subtitles was refined, you only need to implement one method that returns a dictionnary of the available subtitles (lang, url) to support all the subtitle options in a website. I updated the subtitle downloaders for youtube/dailymotion to show how it works.
This commit is contained in:
parent
372297e713
commit
8377574c9c
3 changed files with 73 additions and 144 deletions
|
@ -1,6 +1,5 @@
|
|||
import re
|
||||
import json
|
||||
import itertools
|
||||
import socket
|
||||
|
||||
from .common import InfoExtractor
|
||||
|
@ -34,16 +33,12 @@ class DailyMotionSubtitlesIE(SubtitlesIE):
|
|||
self._downloader.report_warning(u'video doesn\'t have subtitles')
|
||||
return {}
|
||||
|
||||
def _get_subtitle_url(self, sub_lang, sub_name, video_id, format):
|
||||
sub_lang_list = self._get_available_subtitles(video_id)
|
||||
return sub_lang_list[sub_lang]
|
||||
|
||||
def _request_automatic_caption(self, video_id, webpage):
|
||||
self._downloader.report_warning(u'Automatic Captions not supported by dailymotion')
|
||||
self._downloader.report_warning(u'Automatic Captions not supported by this server')
|
||||
return {}
|
||||
|
||||
|
||||
class DailymotionIE(DailyMotionSubtitlesIE): #,InfoExtractor):
|
||||
class DailymotionIE(DailyMotionSubtitlesIE):
|
||||
"""Information Extractor for Dailymotion"""
|
||||
|
||||
_VALID_URL = r'(?i)(?:https?://)?(?:www\.)?dailymotion\.[a-z]{2,3}/video/([^/]+)'
|
||||
|
@ -116,12 +111,6 @@ class DailymotionIE(DailyMotionSubtitlesIE): #,InfoExtractor):
|
|||
self._list_available_subtitles(video_id)
|
||||
return
|
||||
|
||||
if 'length_seconds' not in info:
|
||||
self._downloader.report_warning(u'unable to extract video duration')
|
||||
video_duration = ''
|
||||
else:
|
||||
video_duration = compat_urllib_parse.unquote_plus(video_info['length_seconds'][0])
|
||||
|
||||
return [{
|
||||
'id': video_id,
|
||||
'url': video_url,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue