You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.7 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import remove_end
  4. class ESPNIE(InfoExtractor):
  5. _VALID_URL = r'https?://espn\.go\.com/(?:[^/]+/)*(?P<id>[^/]+)'
  6. _TESTS = [{
  7. 'url': 'http://espn.go.com/video/clip?id=10365079',
  8. 'info_dict': {
  9. 'id': 'FkYWtmazr6Ed8xmvILvKLWjd4QvYZpzG',
  10. 'ext': 'mp4',
  11. 'title': '30 for 30 Shorts: Judging Jewell',
  12. 'description': None,
  13. },
  14. 'params': {
  15. # m3u8 download
  16. 'skip_download': True,
  17. },
  18. }, {
  19. # intl video, from http://www.espnfc.us/video/mls-highlights/150/video/2743663/must-see-moments-best-of-the-mls-season
  20. 'url': 'http://espn.go.com/video/clip?id=2743663',
  21. 'info_dict': {
  22. 'id': '50NDFkeTqRHB0nXBOK-RGdSG5YQPuxHg',
  23. 'ext': 'mp4',
  24. 'title': 'Must-See Moments: Best of the MLS season',
  25. },
  26. 'params': {
  27. # m3u8 download
  28. 'skip_download': True,
  29. },
  30. }, {
  31. 'url': 'https://espn.go.com/video/iframe/twitter/?cms=espn&id=10365079',
  32. 'only_matching': True,
  33. }, {
  34. 'url': 'http://espn.go.com/nba/recap?gameId=400793786',
  35. 'only_matching': True,
  36. }, {
  37. 'url': 'http://espn.go.com/blog/golden-state-warriors/post/_/id/593/how-warriors-rapidly-regained-a-winning-edge',
  38. 'only_matching': True,
  39. }, {
  40. 'url': 'http://espn.go.com/sports/endurance/story/_/id/12893522/dzhokhar-tsarnaev-sentenced-role-boston-marathon-bombings',
  41. 'only_matching': True,
  42. }, {
  43. 'url': 'http://espn.go.com/nba/playoffs/2015/story/_/id/12887571/john-wall-washington-wizards-no-swelling-left-hand-wrist-game-5-return',
  44. 'only_matching': True,
  45. }]
  46. def _real_extract(self, url):
  47. video_id = self._match_id(url)
  48. webpage = self._download_webpage(url, video_id)
  49. video_id = self._search_regex(
  50. r'class=(["\']).*?video-play-button.*?\1[^>]+data-id=["\'](?P<id>\d+)',
  51. webpage, 'video id', group='id')
  52. cms = 'espn'
  53. if 'data-source="intl"' in webpage:
  54. cms = 'intl'
  55. player_url = 'https://espn.go.com/video/iframe/twitter/?id=%s&cms=%s' % (video_id, cms)
  56. player = self._download_webpage(
  57. player_url, video_id)
  58. pcode = self._search_regex(
  59. r'["\']pcode=([^"\']+)["\']', player, 'pcode')
  60. title = remove_end(
  61. self._og_search_title(webpage),
  62. '- ESPN Video').strip()
  63. return {
  64. '_type': 'url_transparent',
  65. 'url': 'ooyalaexternal:%s:%s:%s' % (cms, video_id, pcode),
  66. 'ie_key': 'OoyalaExternal',
  67. 'title': title,
  68. }