pgatour.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from .brightcove import BrightcoveNewIE
  2. from .common import InfoExtractor
  3. class PGATourIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?pgatour\.com/video/[\w-]+/(?P<tc>T)?(?P<id>\d+)'
  5. _TESTS = [{
  6. 'url': 'https://www.pgatour.com/video/competition/T6322447785112/adam-hadwin-2023-the-players-round-4-18th-hole-shot-1',
  7. 'info_dict': {
  8. 'id': '6322447785112',
  9. 'ext': 'mp4',
  10. 'title': 'Adam Hadwin | 2023 THE PLAYERS | Round 4 | 18th hole | Shot 1',
  11. 'uploader_id': '6116716431001',
  12. 'upload_date': '20230312',
  13. 'timestamp': 1678653136,
  14. 'duration': 20.011,
  15. 'thumbnail': r're:^https://.+\.jpg',
  16. 'tags': 'count:7',
  17. },
  18. 'params': {'skip_download': 'm3u8'},
  19. }, {
  20. 'url': 'https://www.pgatour.com/video/features/6322506425112/follow-the-players-trophy-on-championship-sunday',
  21. 'info_dict': {
  22. 'id': '6322506425112',
  23. 'ext': 'mp4',
  24. 'title': 'Follow THE PLAYERS trophy on Championship Sunday',
  25. 'description': 'md5:4d29e4bdfa03694a0ebfd08950398568',
  26. 'uploader_id': '6082840763001',
  27. 'upload_date': '20230313',
  28. 'timestamp': 1678739835,
  29. 'duration': 123.435,
  30. 'thumbnail': r're:^https://.+\.jpg',
  31. 'tags': 'count:8',
  32. },
  33. 'params': {'skip_download': 'm3u8'},
  34. }]
  35. def _real_extract(self, url):
  36. video_id, is_tourcast = self._match_valid_url(url).group('id', 'tc')
  37. # From https://www.pgatour.com/_next/static/chunks/pages/_app-8bcf849560daf38d.js
  38. account_id = '6116716431001' if is_tourcast else '6082840763001'
  39. player_id = 'Vsd5Umu8r' if is_tourcast else 'FWIBYMBPj'
  40. return self.url_result(
  41. f'https://players.brightcove.net/{account_id}/{player_id}_default/index.html?videoId={video_id}',
  42. BrightcoveNewIE)