euscreen.py 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. js_to_json,
  4. parse_duration,
  5. )
  6. class EUScreenIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?euscreen\.eu/item.html\?id=(?P<id>[^&?$/]+)'
  8. _TESTS = [{
  9. 'url': 'https://euscreen.eu/item.html?id=EUS_0EBCBF356BFC4E12A014023BA41BD98C',
  10. 'info_dict': {
  11. 'id': 'EUS_0EBCBF356BFC4E12A014023BA41BD98C',
  12. 'ext': 'mp4',
  13. 'title': "L'effondrement du stade du Heysel",
  14. 'alt_title': 'Collapse of the Heysel Stadium',
  15. 'duration': 318.0,
  16. 'description': 'md5:f0ffffdfce6821139357a1b8359d6152',
  17. 'series': 'JA2 DERNIERE',
  18. 'episode': '-',
  19. 'uploader': 'INA / France',
  20. 'thumbnail': 'http://images3.noterik.com/domain/euscreenxl/user/eu_ina/video/EUS_0EBCBF356BFC4E12A014023BA41BD98C/image.jpg',
  21. },
  22. 'params': {'skip_download': True},
  23. }]
  24. _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>'
  25. def _real_extract(self, url):
  26. video_id = self._match_id(url)
  27. args_for_js_request = self._download_webpage(
  28. 'https://euscreen.eu/lou/LouServlet/domain/euscreenxl/html5application/euscreenxlitem',
  29. video_id, data=self._payload, query={'actionlist': 'itempage', 'id': video_id})
  30. info_js = self._download_webpage(
  31. 'https://euscreen.eu/lou/LouServlet/domain/euscreenxl/html5application/euscreenxlitem',
  32. video_id, data=args_for_js_request.replace('screenid', 'screenId').encode())
  33. video_json = self._parse_json(
  34. self._search_regex(r'setVideo\(({.+})\)\(\$end\$\)put', info_js, 'Video JSON'),
  35. video_id, transform_source=js_to_json)
  36. meta_json = self._parse_json(
  37. self._search_regex(r'setData\(({.+})\)\(\$end\$\)', info_js, 'Metadata JSON'),
  38. video_id, transform_source=js_to_json)
  39. formats = [{
  40. 'url': source['src'],
  41. } for source in video_json.get('sources', [])]
  42. return {
  43. 'id': video_id,
  44. 'title': meta_json.get('originalTitle'),
  45. 'alt_title': meta_json.get('title'),
  46. 'duration': parse_duration(meta_json.get('duration')),
  47. 'description': '{}\n{}'.format(meta_json.get('summaryOriginal', ''), meta_json.get('summaryEnglish', '')),
  48. 'series': meta_json.get('series') or meta_json.get('seriesEnglish'),
  49. 'episode': meta_json.get('episodeNumber'),
  50. 'uploader': meta_json.get('provider'),
  51. 'thumbnail': meta_json.get('screenshot') or video_json.get('screenshot'),
  52. 'formats': formats,
  53. }