1 from __future__ import unicode_literals
3 from .common import InfoExtractor
4 from ..compat import compat_str
14 class DiscoveryGoIE(InfoExtractor):
15 _VALID_URL = r'''(?x)https?://(?:www\.)?(?:
17 investigationdiscovery|
25 )go\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'''
27 'url': 'https://www.discoverygo.com/love-at-first-kiss/kiss-first-ask-questions-later/',
29 'id': '57a33c536b66d1cd0345eeb1',
31 'title': 'Kiss First, Ask Questions Later!',
32 'description': 'md5:fe923ba34050eae468bffae10831cb22',
34 'series': 'Love at First Kiss',
41 def _real_extract(self, url):
42 display_id = self._match_id(url)
44 webpage = self._download_webpage(url, display_id)
46 container = extract_attributes(
48 r'(<div[^>]+class=["\']video-player-container[^>]+>)',
49 webpage, 'video container'))
51 video = self._parse_json(
52 unescapeHTML(container.get('data-video') or container.get('data-json')),
57 stream = video.get('stream')
59 if video.get('authenticated') is True:
61 'This video is only available via cable service provider subscription that'
62 ' is not currently supported. You may want to use --cookies.', expected=True)
64 raise ExtractorError('Unable to find stream')
65 STREAM_URL_SUFFIX = 'streamUrl'
67 for stream_kind in ('', 'hds'):
68 suffix = STREAM_URL_SUFFIX.capitalize() if stream_kind else STREAM_URL_SUFFIX
69 stream_url = stream.get('%s%s' % (stream_kind, suffix))
73 formats.extend(self._extract_m3u8_formats(
74 stream_url, display_id, 'mp4', entry_protocol='m3u8_native',
75 m3u8_id='hls', fatal=False))
76 elif stream_kind == 'hds':
77 formats.extend(self._extract_f4m_formats(
78 stream_url, display_id, f4m_id=stream_kind, fatal=False))
79 self._sort_formats(formats)
81 video_id = video.get('id') or display_id
82 description = video.get('description', {}).get('detailed')
83 duration = int_or_none(video.get('duration'))
85 series = video.get('show', {}).get('name')
86 season_number = int_or_none(video.get('season', {}).get('number'))
87 episode_number = int_or_none(video.get('episodeNumber'))
89 tags = video.get('tags')
90 age_limit = parse_age_limit(video.get('parental', {}).get('rating'))
93 captions = stream.get('captions')
94 if isinstance(captions, list):
95 for caption in captions:
96 subtitle_url = caption.get('fileUrl')
97 if (not subtitle_url or not isinstance(subtitle_url, compat_str) or
98 not subtitle_url.startswith('http')):
100 lang = caption.get('fileLang', 'en')
101 subtitles.setdefault(lang, []).append({'url': subtitle_url})
105 'display_id': display_id,
107 'description': description,
108 'duration': duration,
110 'season_number': season_number,
111 'episode_number': episode_number,
113 'age_limit': age_limit,
115 'subtitles': subtitles,