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.

39 lines
1.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class NBAIE(InfoExtractor):
  5. _VALID_URL = r'^(?:https?://)?(?:watch\.|www\.)?nba\.com/(?:nba/)?video(/[^?]*?)(?:/index\.html)?(?:\?.*)?$'
  6. _TEST = {
  7. 'url': 'http://www.nba.com/video/games/nets/2012/12/04/0021200253-okc-bkn-recap.nba/index.html',
  8. 'file': u'0021200253-okc-bkn-recap.nba.mp4',
  9. 'md5': u'c0edcfc37607344e2ff8f13c378c88a4',
  10. 'info_dict': {
  11. 'description': 'Kevin Durant scores 32 points and dishes out six assists as the Thunder beat the Nets in Brooklyn.',
  12. 'title': 'Thunder vs. Nets',
  13. },
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. video_id = mobj.group(1)
  18. webpage = self._download_webpage(url, video_id)
  19. video_url = 'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4'
  20. shortened_video_id = video_id.rpartition('/')[2]
  21. title = self._og_search_title(webpage, default=shortened_video_id).replace('NBA.com: ', '')
  22. description = self._html_search_regex(r'<meta name="description" (?:content|value)="(.*?)" />', webpage, 'description', fatal=False)
  23. return {
  24. 'id': shortened_video_id,
  25. 'url': video_url,
  26. 'ext': 'mp4',
  27. 'title': title,
  28. 'description': description,
  29. }