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