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

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