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'''(?x)https?://(?:www\.)?(?:
16 investigationdiscovery|
24 )go\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'''
26 'url': 'https://www.discoverygo.com/love-at-first-kiss/kiss-first-ask-questions-later/',
28 'id': '57a33c536b66d1cd0345eeb1',
30 'title': 'Kiss First, Ask Questions Later!',
31 'description': 'md5:fe923ba34050eae468bffae10831cb22',
33 'series': 'Love at First Kiss',
40 def _real_extract(self, url):
41 display_id = self._match_id(url)
43 webpage = self._download_webpage(url, display_id)
45 container = extract_attributes(
47 r'(<div[^>]+class=["\']video-player-container[^>]+>)',
48 webpage, 'video container'))
50 video = self._parse_json(
51 unescapeHTML(container.get('data-video') or container.get('data-json')),
56 stream = video['stream']
57 STREAM_URL_SUFFIX = 'streamUrl'
59 for stream_kind in ('', 'hds'):
60 suffix = STREAM_URL_SUFFIX.capitalize() if stream_kind else STREAM_URL_SUFFIX
61 stream_url = stream.get('%s%s' % (stream_kind, suffix))
65 formats.extend(self._extract_m3u8_formats(
66 stream_url, display_id, 'mp4', entry_protocol='m3u8_native',
67 m3u8_id='hls', fatal=False))
68 elif stream_kind == 'hds':
69 formats.extend(self._extract_f4m_formats(
70 stream_url, display_id, f4m_id=stream_kind, fatal=False))
71 self._sort_formats(formats)
73 video_id = video.get('id') or display_id
74 description = video.get('description', {}).get('detailed')
75 duration = int_or_none(video.get('duration'))
77 series = video.get('show', {}).get('name')
78 season_number = int_or_none(video.get('season', {}).get('number'))
79 episode_number = int_or_none(video.get('episodeNumber'))
81 tags = video.get('tags')
82 age_limit = parse_age_limit(video.get('parental', {}).get('rating'))
85 captions = stream.get('captions')
86 if isinstance(captions, list):
87 for caption in captions:
88 subtitle_url = caption.get('fileUrl')
89 if (not subtitle_url or not isinstance(subtitle_url, compat_str) or
90 not subtitle_url.startswith('http')):
92 lang = caption.get('fileLang', 'en')
93 subtitles.setdefault(lang, []).append({'url': subtitle_url})
97 'display_id': display_id,
99 'description': description,
100 'duration': duration,
102 'season_number': season_number,
103 'episode_number': episode_number,
105 'age_limit': age_limit,
107 'subtitles': subtitles,