ettutv.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. from .common import InfoExtractor
  2. from ..utils import bool_or_none, traverse_obj, unified_timestamp, url_or_none
  3. class EttuTvIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?ettu\.tv/[^?#]+/playerpage/(?P<id>[0-9]+)'
  5. _TESTS = [{
  6. 'url': 'https://www.ettu.tv/en-int/playerpage/1573849',
  7. 'md5': '5874b7639a2aa866d1f6c3a4037c7c09',
  8. 'info_dict': {
  9. 'id': '1573849',
  10. 'title': 'Ni Xia Lian - Shao Jieni',
  11. 'description': 'ITTF Europe Top 16 Cup',
  12. 'timestamp': 1677348600,
  13. 'upload_date': '20230225',
  14. 'thumbnail': r're:^https?://.*\.(?:jpg|png)',
  15. 'ext': 'mp4',
  16. },
  17. }, {
  18. 'url': 'https://www.ettu.tv/en-int/playerpage/1573753',
  19. 'md5': '1fc094bf96cf2d5ec0f434d3a6dec9aa',
  20. 'info_dict': {
  21. 'id': '1573753',
  22. 'title': 'Qiu Dang - Jorgic Darko',
  23. 'description': 'ITTF Europe Top 16 Cup',
  24. 'timestamp': 1677423600,
  25. 'upload_date': '20230226',
  26. 'thumbnail': r're:^https?://.*\.(?:jpg|png)',
  27. 'ext': 'mp4',
  28. },
  29. }]
  30. def _real_extract(self, url):
  31. video_id = self._match_id(url)
  32. player_settings = self._download_json(
  33. f'https://www.ettu.tv/api/v3/contents/{video_id}/player-settings', video_id, query={
  34. 'language': 'en',
  35. 'showTitle': 'true',
  36. 'device': 'desktop',
  37. })
  38. stream_response = self._download_json(player_settings['streamAccess'], video_id, data=b'')
  39. formats, subtitles = self._extract_m3u8_formats_and_subtitles(
  40. stream_response['data']['stream'], video_id, 'mp4')
  41. return {
  42. 'id': video_id,
  43. 'formats': formats,
  44. 'subtitles': subtitles,
  45. **traverse_obj(player_settings, {
  46. 'title': 'title',
  47. 'description': ('metaInformation', 'competition'),
  48. 'thumbnail': ('image', {url_or_none}),
  49. 'timestamp': ('date', {unified_timestamp}),
  50. 'is_live': ('isLivestream', {bool_or_none}),
  51. }),
  52. }