wimbledon.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. parse_duration,
  4. traverse_obj,
  5. )
  6. class WimbledonIE(InfoExtractor):
  7. _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+)\.html'
  8. _TESTS = [{
  9. 'url': 'https://www.wimbledon.com/en_GB/video/media/6330247525112.html',
  10. 'info_dict': {
  11. 'id': '6330247525112',
  12. 'ext': 'mp4',
  13. 'timestamp': 1687972186,
  14. 'description': '',
  15. 'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
  16. 'upload_date': '20230628',
  17. 'title': 'Coco Gauff | My Wimbledon Inspiration',
  18. 'tags': ['features', 'trending', 'homepage'],
  19. 'uploader_id': '3506358525001',
  20. 'duration': 163072.0,
  21. },
  22. }, {
  23. 'url': 'https://www.wimbledon.com/en_GB/video/media/6308703111112.html',
  24. 'info_dict': {
  25. 'id': '6308703111112',
  26. 'ext': 'mp4',
  27. 'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
  28. 'description': 'null',
  29. 'upload_date': '20220629',
  30. 'uploader_id': '3506358525001',
  31. 'title': 'Roblox | WimbleWorld ',
  32. 'duration': 101440.0,
  33. 'tags': ['features', 'kids'],
  34. 'timestamp': 1656500867,
  35. },
  36. }, {
  37. 'url': 'https://www.wimbledon.com/en_US/video/media/6309327106112.html',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'https://www.wimbledon.com/es_Es/video/media/6308377909112.html',
  41. 'only_matching': True,
  42. }]
  43. def _real_extract(self, url):
  44. video_id = self._match_id(url)
  45. metadata = self._download_json(
  46. f'https://www.wimbledon.com/relatedcontent/rest/v2/wim_v1/en/content/wim_v1_{video_id}_en', video_id)
  47. return {
  48. '_type': 'url_transparent',
  49. 'url': f'http://players.brightcove.net/3506358525001/default_default/index.html?videoId={video_id}',
  50. 'ie_key': 'BrightcoveNew',
  51. 'id': video_id,
  52. **traverse_obj(metadata, {
  53. 'title': 'title',
  54. 'description': 'description',
  55. 'duration': ('metadata', 'duration', {parse_duration}),
  56. }),
  57. }