logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

eurosport.py (9286B)


  1. from .common import InfoExtractor
  2. from ..utils import traverse_obj
  3. class EurosportIE(InfoExtractor):
  4. _VALID_URL = r'''(?x)
  5. https?://(?:
  6. (?:(?:www|espanol)\.)?eurosport\.(?:com(?:\.tr)?|de|dk|es|fr|hu|it|nl|no|ro)|
  7. eurosport\.tvn24\.pl
  8. )/[\w-]+/(?:[\w-]+/[\d-]+/)?[\w.-]+_(?P<id>vid\d+)
  9. '''
  10. _TESTS = [{
  11. 'url': 'https://www.eurosport.com/tennis/roland-garros/2022/highlights-rafael-nadal-brushes-aside-caper-ruud-to-win-record-extending-14th-french-open-title_vid1694147/video.shtml',
  12. 'info_dict': {
  13. 'id': '2480939',
  14. 'ext': 'mp4',
  15. 'title': 'Highlights: Rafael Nadal brushes aside Caper Ruud to win record-extending 14th French Open title',
  16. 'description': 'md5:b564db73ecfe4b14ebbd8e62a3692c76',
  17. 'thumbnail': 'https://imgresizer.eurosport.com/unsafe/1280x960/smart/filters:format(jpeg)/origin-imgresizer.eurosport.com/2022/06/05/3388285-69245968-2560-1440.png',
  18. 'duration': 195.0,
  19. 'display_id': 'vid1694147',
  20. 'timestamp': 1654446698,
  21. 'upload_date': '20220605',
  22. },
  23. }, {
  24. 'url': 'https://www.eurosport.com/tennis/roland-garros/2022/watch-the-top-five-shots-from-men-s-final-as-rafael-nadal-beats-casper-ruud-to-seal-14th-french-open_vid1694283/video.shtml',
  25. 'info_dict': {
  26. 'id': '2481254',
  27. 'ext': 'mp4',
  28. 'title': 'md5:149dcc5dfb38ab7352acc008cc9fb071',
  29. 'duration': 130.0,
  30. 'thumbnail': 'https://imgresizer.eurosport.com/unsafe/1280x960/smart/filters:format(jpeg)/origin-imgresizer.eurosport.com/2022/06/05/3388422-69248708-2560-1440.png',
  31. 'description': 'md5:a0c8a7f6b285e48ae8ddbe7aa85cfee6',
  32. 'display_id': 'vid1694283',
  33. 'timestamp': 1654456090,
  34. 'upload_date': '20220605',
  35. },
  36. }, {
  37. # geo-fence but can bypassed by xff
  38. 'url': 'https://www.eurosport.com/cycling/tour-de-france-femmes/2022/incredible-ride-marlen-reusser-storms-to-stage-4-win-at-tour-de-france-femmes_vid1722221/video.shtml',
  39. 'info_dict': {
  40. 'id': '2582552',
  41. 'ext': 'mp4',
  42. 'title': '‘Incredible ride!’ - Marlen Reusser storms to Stage 4 win at Tour de France Femmes',
  43. 'duration': 188.0,
  44. 'display_id': 'vid1722221',
  45. 'timestamp': 1658936167,
  46. 'thumbnail': 'https://imgresizer.eurosport.com/unsafe/1280x960/smart/filters:format(jpeg)/origin-imgresizer.eurosport.com/2022/07/27/3423347-69852108-2560-1440.jpg',
  47. 'description': 'md5:32bbe3a773ac132c57fb1e8cca4b7c71',
  48. 'upload_date': '20220727',
  49. },
  50. }, {
  51. 'url': 'https://www.eurosport.com/football/champions-league/2022-2023/pep-guardiola-emotionally-destroyed-after-manchester-city-win-over-bayern-munich-in-champions-league_vid1896254/video.shtml',
  52. 'info_dict': {
  53. 'id': '3096477',
  54. 'ext': 'mp4',
  55. 'title': 'md5:82edc17370124c7a19b3cf518517583b',
  56. 'duration': 84.0,
  57. 'description': 'md5:b3f44ef7f5b5b95b24a273b163083feb',
  58. 'thumbnail': 'https://imgresizer.eurosport.com/unsafe/1280x960/smart/filters:format(jpeg)/origin-imgresizer.eurosport.com/2023/04/12/3682873-74947393-2560-1440.jpg',
  59. 'timestamp': 1681292028,
  60. 'upload_date': '20230412',
  61. 'display_id': 'vid1896254',
  62. },
  63. }, {
  64. 'url': 'https://www.eurosport.com/football/last-year-s-semi-final-pain-was-still-there-pep-guardiola-after-man-city-reach-cl-final_vid1914115/video.shtml',
  65. 'info_dict': {
  66. 'id': '3149108',
  67. 'ext': 'mp4',
  68. 'title': '\'Last year\'s semi-final pain was still there\' - Pep Guardiola after Man City reach CL final',
  69. 'description': 'md5:89ef142fe0170a66abab77fac2955d8e',
  70. 'display_id': 'vid1914115',
  71. 'timestamp': 1684403618,
  72. 'thumbnail': 'https://imgresizer.eurosport.com/unsafe/1280x960/smart/filters:format(jpeg)/origin-imgresizer.eurosport.com/2023/05/18/3707254-75435008-2560-1440.jpg',
  73. 'duration': 105.0,
  74. 'upload_date': '20230518',
  75. },
  76. }, {
  77. 'url': 'https://www.eurosport.de/radsport/vuelta-a-espana/2024/vuelta-a-espana-2024-wout-van-aert-und-co.-verzweifeln-an-mcnulty-zeitfahr-krimi-in-lissabon_vid2219478/video.shtml',
  78. 'only_matching': True,
  79. }, {
  80. 'url': 'https://www.eurosport.dk/speedway/mikkel-michelsen-misser-finalen-i-cardiff-se-danskeren-i-semifinalen-her_vid2219363/video.shtml',
  81. 'only_matching': True,
  82. }, {
  83. 'url': 'https://www.eurosport.nl/mixed-martial-arts/ufc/2022/ufc-305-respect-tussen-adesanya-en-du-plessis_vid2219650/video.shtml',
  84. 'only_matching': True,
  85. }, {
  86. 'url': 'https://www.eurosport.es/ciclismo/la-vuelta-2024-carlos-rodriguez-olvida-la-crono-y-ya-espera-que-llegue-la-montana-no-me-encontre-nada-comodo_vid2219682/video.shtml',
  87. 'only_matching': True,
  88. }, {
  89. 'url': 'https://www.eurosport.fr/football/supercoupe-d-europe/2024-2025/kylian-mbappe-vinicius-junior-eduardo-camavinga-touche.-extraits-de-l-entrainement-du-real-madrid-en-video_vid2216993/video.shtml',
  90. 'only_matching': True,
  91. }, {
  92. 'url': 'https://www.eurosport.it/calcio/serie-a/2024-2025/samardzic-a-bergamo-per-le-visite-mediche-con-l-atalanta_vid2219680/video.shtml',
  93. 'only_matching': True,
  94. }, {
  95. 'url': 'https://www.eurosport.hu/kerekpar/vuelta-a-espana/2024/dramai-harc-a-masodpercekert-meglepetesgyoztes-a-vuelta-nyitoszakaszan_vid2219481/video.shtml',
  96. 'only_matching': True,
  97. }, {
  98. 'url': 'https://www.eurosport.no/golf/fedex-st-jude-championship/2024/ligger-pa-andreplass-sa-skjer-dette-drama_vid30000618/video.shtml',
  99. 'only_matching': True,
  100. }, {
  101. 'url': 'https://www.eurosport.no/golf/fedex-st-jude-championship/2024/ligger-pa-andreplass-sa-skjer-dette-drama_vid2219531/video.shtml',
  102. 'only_matching': True,
  103. }, {
  104. 'url': 'https://www.eurosport.ro/tenis/western-southern-open-2/2024/rezumatul-partidei-dintre-zverev-si-shelton-de-la-cincinnati_vid2219657/video.shtml',
  105. 'only_matching': True,
  106. }, {
  107. 'url': 'https://www.eurosport.com.tr/hentbol/olympic-games-paris-2024/2024/paris-2024-denmark-ile-germany-olimpiyatlarin-onemli-anlari_vid2215836/video.shtml',
  108. 'only_matching': True,
  109. }, {
  110. 'url': 'https://eurosport.tvn24.pl/kolarstwo/tour-de-france-kobiet/2024/kasia-niewiadoma-przed-ostatnim-8.-etapem-tour-de-france-kobiet_vid2219765/video.shtml',
  111. 'only_matching': True,
  112. }]
  113. _TOKEN = None
  114. # actually defined in https://netsport.eurosport.io/?variables={"databaseId":<databaseId>,"playoutType":"VDP"}&extensions={"persistedQuery":{"version":1 ..
  115. # but this method require to get sha256 hash
  116. _GEO_COUNTRIES = ['DE', 'NL', 'EU', 'IT', 'FR'] # Not complete list but it should work
  117. _GEO_BYPASS = False
  118. def _real_initialize(self):
  119. if EurosportIE._TOKEN is None:
  120. EurosportIE._TOKEN = self._download_json(
  121. 'https://eu3-prod-direct.eurosport.com/token?realm=eurosport', None,
  122. 'Trying to get token')['data']['attributes']['token']
  123. def _real_extract(self, url):
  124. display_id = self._match_id(url)
  125. webpage = self._download_webpage(url, display_id)
  126. json_data = self._download_json(
  127. f'https://eu3-prod-direct.eurosport.com/playback/v2/videoPlaybackInfo/sourceSystemId/eurosport-{display_id}',
  128. display_id, query={'usePreAuth': True}, headers={'Authorization': f'Bearer {EurosportIE._TOKEN}'})['data']
  129. json_ld_data = self._search_json_ld(webpage, display_id)
  130. formats, subtitles = [], {}
  131. for stream_type in json_data['attributes']['streaming']:
  132. if stream_type == 'hls':
  133. fmts, subs = self._extract_m3u8_formats_and_subtitles(
  134. traverse_obj(json_data, ('attributes', 'streaming', stream_type, 'url')), display_id, ext='mp4', fatal=False)
  135. elif stream_type == 'dash':
  136. fmts, subs = self._extract_mpd_formats_and_subtitles(
  137. traverse_obj(json_data, ('attributes', 'streaming', stream_type, 'url')), display_id, fatal=False)
  138. elif stream_type == 'mss':
  139. fmts, subs = self._extract_ism_formats_and_subtitles(
  140. traverse_obj(json_data, ('attributes', 'streaming', stream_type, 'url')), display_id, fatal=False)
  141. formats.extend(fmts)
  142. self._merge_subtitles(subs, target=subtitles)
  143. return {
  144. 'id': json_data['id'],
  145. 'title': json_ld_data.get('title') or self._og_search_title(webpage),
  146. 'display_id': display_id,
  147. 'formats': formats,
  148. 'subtitles': subtitles,
  149. 'thumbnails': json_ld_data.get('thumbnails'),
  150. 'description': (json_ld_data.get('description')
  151. or self._html_search_meta(['og:description', 'description'], webpage)),
  152. 'duration': json_ld_data.get('duration'),
  153. 'timestamp': json_ld_data.get('timestamp'),
  154. }