[ie/wistia] Support password-protected videos (#11100)
[yt-dlp3.git] / yt_dlp / extractor / euscreen.py
blobf08938fc9b9b350f6f70488cb7d6e49bc00af93c
1 from .common import InfoExtractor
2 from ..utils import (
3 js_to_json,
4 parse_duration,
8 class EUScreenIE(InfoExtractor):
9 _VALID_URL = r'https?://(?:www\.)?euscreen\.eu/item.html\?id=(?P<id>[^&?$/]+)'
11 _TESTS = [{
12 'url': 'https://euscreen.eu/item.html?id=EUS_0EBCBF356BFC4E12A014023BA41BD98C',
13 'info_dict': {
14 'id': 'EUS_0EBCBF356BFC4E12A014023BA41BD98C',
15 'ext': 'mp4',
16 'title': "L'effondrement du stade du Heysel",
17 'alt_title': 'Collapse of the Heysel Stadium',
18 'duration': 318.0,
19 'description': 'md5:f0ffffdfce6821139357a1b8359d6152',
20 'series': 'JA2 DERNIERE',
21 'episode': '-',
22 'uploader': 'INA / France',
23 'thumbnail': 'http://images3.noterik.com/domain/euscreenxl/user/eu_ina/video/EUS_0EBCBF356BFC4E12A014023BA41BD98C/image.jpg',
25 'params': {'skip_download': True},
28 _payload = b'<fsxml><screen><properties><screenId>-1</screenId></properties><capabilities id="1"><properties><platform>Win32</platform><appcodename>Mozilla</appcodename><appname>Netscape</appname><appversion>5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36</appversion><useragent>Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36</useragent><cookiesenabled>true</cookiesenabled><screenwidth>784</screenwidth><screenheight>758</screenheight><orientation>undefined</orientation><smt_browserid>Sat, 07 Oct 2021 08:56:50 GMT</smt_browserid><smt_sessionid>1633769810758</smt_sessionid></properties></capabilities></screen></fsxml>'
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 args_for_js_request = self._download_webpage(
33 'https://euscreen.eu/lou/LouServlet/domain/euscreenxl/html5application/euscreenxlitem',
34 video_id, data=self._payload, query={'actionlist': 'itempage', 'id': video_id})
35 info_js = self._download_webpage(
36 'https://euscreen.eu/lou/LouServlet/domain/euscreenxl/html5application/euscreenxlitem',
37 video_id, data=args_for_js_request.replace('screenid', 'screenId').encode())
38 video_json = self._parse_json(
39 self._search_regex(r'setVideo\(({.+})\)\(\$end\$\)put', info_js, 'Video JSON'),
40 video_id, transform_source=js_to_json)
41 meta_json = self._parse_json(
42 self._search_regex(r'setData\(({.+})\)\(\$end\$\)', info_js, 'Metadata JSON'),
43 video_id, transform_source=js_to_json)
44 formats = [{
45 'url': source['src'],
46 } for source in video_json.get('sources', [])]
48 return {
49 'id': video_id,
50 'title': meta_json.get('originalTitle'),
51 'alt_title': meta_json.get('title'),
52 'duration': parse_duration(meta_json.get('duration')),
53 'description': '{}\n{}'.format(meta_json.get('summaryOriginal', ''), meta_json.get('summaryEnglish', '')),
54 'series': meta_json.get('series') or meta_json.get('seriesEnglish'),
55 'episode': meta_json.get('episodeNumber'),
56 'uploader': meta_json.get('provider'),
57 'thumbnail': meta_json.get('screenshot') or video_json.get('screenshot'),
58 'formats': formats,