- def _extract_metadata(self, webpage, video_id):
- program_id = self._search_regex(r'var\s+programId\s*=\s*(\d+);', webpage, 'program id')
- metadata = self._download_json(
- 'http://smbsolr.cdnak.neulion.com/solr_nbav6/nba/nba/mlt/?wt=json&fl=name,description,image,runtime,releaseDate&q=sequence%3A' + program_id, video_id)['match']['docs'][0]
+ def _real_extract(self, url):
+ path, video_id = re.match(self._VALID_URL, url).groups()
+ video_info = self._download_xml('http://www.nba.com/%s.xml' % path, video_id)
+ video_id = xpath_text(video_info, 'slug')
+ title = xpath_text(video_info, 'headline')
+ description = xpath_text(video_info, 'description')
+ duration = parse_duration(xpath_text(video_info, 'length'))
+ timestamp = int_or_none(xpath_attr(video_info, 'dateCreated', 'uts'))
+
+ thumbnails = []
+ for image in video_info.find('images'):
+ thumbnails.append({
+ 'id': image.attrib.get('cut'),
+ 'url': image.text,
+ 'width': int_or_none(image.attrib.get('width')),
+ 'height': int_or_none(image.attrib.get('height')),
+ })
+
+ formats = []
+ for video_file in video_info.find('files').iter('file'):
+ video_url = video_file.text
+ if video_url.startswith('/'):
+ continue
+ if video_url.endswith('.m3u8'):
+ formats.extend(self._extract_m3u8_formats(video_url, video_id, m3u8_id='hls'))
+ elif video_url.endswith('.f4m'):
+ formats.extend(self._extract_f4m_formats(video_url + '?hdcore=3.4.1.1', video_id, f4m_id='hds'))
+ else:
+ key = video_file.attrib.get('bitrate')
+ width, height, bitrate = re.search(r'(\d+)x(\d+)(?:_(\d+))?', key).groups()
+ formats.append({
+ 'format_id': key,
+ 'url': video_url,
+ 'width': int_or_none(width),
+ 'height': int_or_none(height),
+ 'tbr': int_or_none(bitrate),
+ })
+ self._sort_formats(formats)
+