]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/discoverygo.py
adb68b96c4033a3ef5cf8dcf3357fa64ed73acb8
1 from __future__
import unicode_literals
3 from .common
import InfoExtractor
4 from ..compat
import compat_str
13 class DiscoveryGoIE(InfoExtractor
):
14 _VALID_URL
= r
'https?://(?:www\.)?discoverygo\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'
16 'url': 'https://www.discoverygo.com/love-at-first-kiss/kiss-first-ask-questions-later/',
18 'id': '57a33c536b66d1cd0345eeb1',
20 'title': 'Kiss First, Ask Questions Later!',
21 'description': 'md5:fe923ba34050eae468bffae10831cb22',
23 'series': 'Love at First Kiss',
30 def _real_extract(self
, url
):
31 display_id
= self
._match
_id
(url
)
33 webpage
= self
._download
_webpage
(url
, display_id
)
35 container
= extract_attributes(
37 r
'(<div[^>]+class=["\']video
-player
-container
[^
>]+>)',
38 webpage, 'video container
'))
40 video = self._parse_json(
41 unescapeHTML(container.get('data
-video
') or container.get('data
-json
')),
46 stream = video['stream
']
47 STREAM_URL_SUFFIX = 'streamUrl
'
49 for stream_kind in ('', 'hds
'):
50 suffix = STREAM_URL_SUFFIX.capitalize() if stream_kind else STREAM_URL_SUFFIX
51 stream_url = stream.get('%s%s' % (stream_kind, suffix))
55 formats.extend(self._extract_m3u8_formats(
56 stream_url, display_id, 'mp4
', entry_protocol='m3u8_native
',
57 m3u8_id='hls
', fatal=False))
58 elif stream_kind == 'hds
':
59 formats.extend(self._extract_f4m_formats(
60 stream_url, display_id, f4m_id=stream_kind, fatal=False))
61 self._sort_formats(formats)
63 video_id = video.get('id') or display_id
64 description = video.get('description
', {}).get('detailed
')
65 duration = int_or_none(video.get('duration
'))
67 series = video.get('show
', {}).get('name
')
68 season_number = int_or_none(video.get('season
', {}).get('number
'))
69 episode_number = int_or_none(video.get('episodeNumber
'))
71 tags = video.get('tags
')
72 age_limit = parse_age_limit(video.get('parental
', {}).get('rating
'))
75 captions = stream.get('captions
')
76 if isinstance(captions, list):
77 for caption in captions:
78 subtitle_url = caption.get('fileUrl
')
79 if (not subtitle_url or not isinstance(subtitle_url, compat_str) or
80 not subtitle_url.startswith('http
')):
82 lang = caption.get('fileLang
', 'en
')
83 subtitles.setdefault(lang, []).append({'url
': subtitle_url})
87 'display_id
': display_id,
89 'description
': description,
92 'season_number
': season_number,
93 'episode_number
': episode_number,
95 'age_limit
': age_limit,
97 'subtitles
': subtitles,