2 from __future__ import unicode_literals
6 from .common import InfoExtractor
7 from ..compat import compat_str
15 class NexxIE(InfoExtractor):
18 https?://api\.nexx(?:\.cloud|cdn\.com)/v3/(?P<domain_id>\d+)/videos/byid/|
19 nexx:(?P<domain_id_s>\d+):
25 'url': 'https://api.nexx.cloud/v3/748/videos/byid/128907',
26 'md5': '828cea195be04e66057b846288295ba1',
30 'title': 'Stiftung Warentest',
31 'alt_title': 'Wie ein Test abläuft',
32 'description': 'md5:d1ddb1ef63de721132abd38639cc2fd2',
34 'creator': 'SPIEGEL TV',
35 'thumbnail': r're:^https?://.*\.jpg$',
37 'timestamp': 1384264416,
38 'upload_date': '20131112',
42 'url': 'https://api.nexx.cloud/v3/741/videos/byid/247858',
46 'title': 'Return of the Golden Child (OV)',
47 'description': 'md5:5d969537509a92b733de21bae249dc63',
49 'thumbnail': r're:^https?://.*\.jpg$',
51 'timestamp': 1495033267,
52 'upload_date': '20170517',
57 'skip_download': True,
60 'url': 'https://api.nexxcdn.com/v3/748/videos/byid/128907',
61 'only_matching': True,
63 'url': 'nexx:748:128907',
64 'only_matching': True,
68 def _extract_domain_id(webpage):
70 r'<script\b[^>]+\bsrc=["\'](?:https?:)?//require\.nexx(?:\.cloud|cdn\.com)/(?P<id>\d+)',
72 return mobj.group('id') if mobj else None
75 def _extract_urls(webpage):
77 # 1. https://nx-s.akamaized.net/files/201510/44.pdf
81 # JavaScript Integration
82 domain_id = NexxIE._extract_domain_id(webpage)
84 for video_id in re.findall(
85 r'(?is)onPLAYReady.+?_play\.init\s*\(.+?\s*,\s*["\']?(\d+)',
88 'https://api.nexx.cloud/v3/%s/videos/byid/%s'
89 % (domain_id, video_id))
91 # TODO: support more embed formats
96 def _extract_url(webpage):
97 return NexxIE._extract_urls(webpage)[0]
99 def _real_extract(self, url):
100 video_id = self._match_id(url)
102 video = self._download_json(
103 'https://arc.nexx.cloud/api/video/%s.json' % video_id,
106 general = video['general']
107 title = general['title']
109 stream_data = video['streamdata']
110 language = general.get('language_raw') or ''
112 # TODO: reverse more cdns
114 cdn = stream_data['cdnType']
115 assert cdn == 'azure'
117 azure_locator = stream_data['azureLocator']
119 AZURE_URL = 'http://nx%s%02d.akamaized.net/'
121 def get_cdn_shield_base(shield_type='', prefix='-p'):
122 for secure in ('', 's'):
123 cdn_shield = stream_data.get('cdnShield%sHTTP%s' % (shield_type, secure.upper()))
125 return 'http%s://%s' % (secure, cdn_shield)
127 return AZURE_URL % (prefix, int(stream_data['azureAccount'].replace('nexxplayplus', '')))
129 azure_stream_base = get_cdn_shield_base()
130 is_ml = ',' in language
131 azure_manifest_url = '%s%s/%s_src%s.ism/Manifest' % (
132 azure_stream_base, azure_locator, video_id, ('_manifest' if is_ml else '')) + '%s'
134 protection_token = try_get(
135 video, lambda x: x['protectiondata']['token'], compat_str)
137 azure_manifest_url += '?hdnts=%s' % protection_token
139 formats = self._extract_m3u8_formats(
140 azure_manifest_url % '(format=m3u8-aapl)',
141 video_id, 'mp4', 'm3u8_native',
142 m3u8_id='%s-hls' % cdn, fatal=False)
143 formats.extend(self._extract_mpd_formats(
144 azure_manifest_url % '(format=mpd-time-csf)',
145 video_id, mpd_id='%s-dash' % cdn, fatal=False))
146 formats.extend(self._extract_ism_formats(
147 azure_manifest_url % '', video_id, ism_id='%s-mss' % cdn, fatal=False))
149 azure_progressive_base = get_cdn_shield_base('Prog', '-d')
150 azure_file_distribution = stream_data.get('azureFileDistribution')
151 if azure_file_distribution:
152 fds = azure_file_distribution.split(',')
157 tbr = int_or_none(ss[0])
160 'url': '%s%s/%s_src_%s_%d.mp4' % (
161 azure_progressive_base, azure_locator, video_id, ss[1], tbr),
162 'format_id': '%s-http-%d' % (cdn, tbr),
165 width_height = ss[1].split('x')
166 if len(width_height) == 2:
168 'width': int_or_none(width_height[0]),
169 'height': int_or_none(width_height[1]),
173 self._sort_formats(formats)
178 'alt_title': general.get('subtitle'),
179 'description': general.get('description'),
180 'release_year': int_or_none(general.get('year')),
181 'creator': general.get('studio') or general.get('studio_adref'),
182 'thumbnail': try_get(
183 video, lambda x: x['imagedata']['thumb'], compat_str),
184 'duration': parse_duration(general.get('runtime')),
185 'timestamp': int_or_none(general.get('uploaded')),
186 'episode_number': int_or_none(try_get(
187 video, lambda x: x['episodedata']['episode'])),
188 'season_number': int_or_none(try_get(
189 video, lambda x: x['episodedata']['season'])),
194 class NexxEmbedIE(InfoExtractor):
195 _VALID_URL = r'https?://embed\.nexx(?:\.cloud|cdn\.com)/\d+/(?P<id>[^/?#&]+)'
197 'url': 'http://embed.nexx.cloud/748/KC1614647Z27Y7T?autoplay=1',
198 'md5': '16746bfc28c42049492385c989b26c4a',
202 'title': 'Nervenkitzel Achterbahn',
203 'alt_title': 'Karussellbauer in Deutschland',
204 'description': 'md5:ffe7b1cc59a01f585e0569949aef73cc',
205 'release_year': 2005,
206 'creator': 'SPIEGEL TV',
207 'thumbnail': r're:^https?://.*\.jpg$',
209 'timestamp': 1394021479,
210 'upload_date': '20140305',
213 'format': 'bestvideo',
214 'skip_download': True,
219 def _extract_urls(webpage):
221 # 1. https://nx-s.akamaized.net/files/201510/44.pdf
223 # iFrame Embed Integration
224 return [mobj.group('url') for mobj in re.finditer(
225 r'<iframe[^>]+\bsrc=(["\'])(?P<url>(?:https?:)?//embed\.nexx(?:\.cloud|cdn\.com)/\d+/(?:(?!\1).)+)\1',
228 def _real_extract(self, url):
229 embed_id = self._match_id(url)
231 webpage = self._download_webpage(url, embed_id)
233 return self.url_result(NexxIE._extract_url(webpage), ie=NexxIE.ie_key())