]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/nba.py
3 from .common
import InfoExtractor
9 class NBAIE(InfoExtractor
):
10 _VALID_URL
= r
'^(?:https?://)?(?:watch\.|www\.)?nba\.com/(?:nba/)?video(/[^?]*?)(?:/index\.html)?(?:\?.*)?$'
12 def _real_extract(self
, url
):
13 mobj
= re
.match(self
._VALID
_URL
, url
)
15 raise ExtractorError(u
'Invalid URL: %s' % url
)
17 video_id
= mobj
.group(1)
19 webpage
= self
._download
_webpage
(url
, video_id
)
21 video_url
= u
'http://ht-mobile.cdn.turner.com/nba/big' + video_id
+ '_nba_1280x720.mp4'
23 shortened_video_id
= video_id
.rpartition('/')[2]
24 title
= self
._html
_search
_regex
(r
'<meta property="og:title" content="(.*?)"',
25 webpage
, 'title', default
=shortened_video_id
).replace('NBA.com: ', '')
27 # It isn't there in the HTML it returns to us
28 # uploader_date = self._html_search_regex(r'<b>Date:</b> (.*?)</div>', webpage, 'upload_date', fatal=False)
30 description
= self
._html
_search
_regex
(r
'<meta name="description" (?:content|value)="(.*?)" />', webpage
, 'description', fatal
=False)
33 'id': shortened_video_id
,
37 # 'uploader_date': uploader_date,
38 'description': description
,