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.

47 lines
1.6 KiB

10 years ago
10 years ago
11 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. remove_end,
  5. parse_duration,
  6. )
  7. class NBAIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:watch\.|www\.)?nba\.com/(?:nba/)?video(?P<id>/[^?]*?)/?(?:/index\.html)?(?:\?.*)?$'
  9. _TESTS = [{
  10. 'url': 'http://www.nba.com/video/games/nets/2012/12/04/0021200253-okc-bkn-recap.nba/index.html',
  11. 'md5': 'c0edcfc37607344e2ff8f13c378c88a4',
  12. 'info_dict': {
  13. 'id': '0021200253-okc-bkn-recap.nba',
  14. 'ext': 'mp4',
  15. 'title': 'Thunder vs. Nets',
  16. 'description': 'Kevin Durant scores 32 points and dishes out six assists as the Thunder beat the Nets in Brooklyn.',
  17. 'duration': 181,
  18. },
  19. }, {
  20. 'url': 'http://www.nba.com/video/games/hornets/2014/12/05/0021400276-nyk-cha-play5.nba/',
  21. 'only_matching': True,
  22. }]
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. webpage = self._download_webpage(url, video_id)
  26. video_url = 'http://ht-mobile.cdn.turner.com/nba/big' + video_id + '_nba_1280x720.mp4'
  27. shortened_video_id = video_id.rpartition('/')[2]
  28. title = remove_end(
  29. self._og_search_title(webpage, default=shortened_video_id), ' : NBA.com')
  30. description = self._og_search_description(webpage)
  31. duration = parse_duration(
  32. self._html_search_meta('duration', webpage, 'duration'))
  33. return {
  34. 'id': shortened_video_id,
  35. 'url': video_url,
  36. 'title': title,
  37. 'description': description,
  38. 'duration': duration,
  39. }