- url_id = self._match_id(url)
-
- webpage = self._download_webpage(url, url_id if url_id else "")
-
- if url_id:
- info = json.loads(self._html_search_regex(r'({.*?' + url_id + '.*})', webpage, 'json'))
- else:
- # Just fetch the first video on that page
- info = json.loads(self._html_search_regex(r'bonanzaFunctions.newPlaylist\(({.*})\)', webpage, 'json'))
-
- asset_id = str(info['AssetId'])
- title = info['Title'].rstrip(' \'\"-,.:;!?')
- duration = info['Duration']
- timestamp = parse_iso8601(re.sub(r'\.\d+$', '', info['Created'])) # First published online. "FirstPublished" contains the date for original airing.
-
- def parse_filename_info(url):
- match = re.search(r'/\d+_(?P<width>\d+)x(?P<height>\d+)x(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url)
- if match:
- return {'width': int(match.group(1)), 'height': int(match.group(2)), 'bitrate': int(match.group(3)), 'ext': match.group(4)}
- match = re.search(r'/\d+_(?P<bitrate>\d+)K\.(?P<ext>\w+)$', url)
- if match:
- return {'bitrate': int(match.group(1)), 'ext': match.group(2)}
- return {'width': None, 'height': None, 'bitrate': None, 'ext': None}
-
- video_types = ['VideoHigh', 'VideoMid', 'VideoLow']
- preferencemap = {
- 'VideoHigh': -1,
- 'VideoMid': -2,
- 'VideoLow': -3,
- 'Audio': -4,
- }
-
- formats = []
- for file in info['Files']:
- if info['Type'] == "Video":
- if file['Type'] in video_types:
- fileinfo = parse_filename_info(file['Location'])
- formats.append({
- 'url': file['Location'],
- 'format_id': file['Type'].replace('Video', ''),
- 'preference': preferencemap.get(file['Type'], -10),
- 'width': fileinfo['width'],
- 'height': fileinfo['height'],
- 'vbr': fileinfo['bitrate'],
- 'ext': fileinfo['ext'],
- })
- elif file['Type'] == "Thumb":
- thumbnail = file['Location']
- elif info['Type'] == "Audio":
- if file['Type'] == "Audio":
- fileinfo = parse_filename_info(file['Location'])
- formats.append({
- 'url': file['Location'],
- 'format_id': file['Type'],
- 'abr': fileinfo['bitrate'],
- 'ext': fileinfo['ext'],
- 'vcodec': 'none',
- })
- elif file['Type'] == "Thumb":
- thumbnail = file['Location']
-
- description = "{}\n{}\n{}\n".format(info['Description'], info['Actors'], info['Colophon'])
+ mobj = re.match(self._VALID_URL, url)
+ video_id, display_id = mobj.group('id', 'display_id')
+
+ webpage = self._download_webpage(url, display_id)
+
+ info = self._parse_html5_media_entries(
+ url, webpage, display_id, m3u8_id='hls',
+ m3u8_entry_protocol='m3u8_native')[0]
+ self._sort_formats(info['formats'])
+
+ asset = self._parse_json(
+ self._search_regex(
+ r'(?s)currentAsset\s*=\s*({.+?})\s*</script', webpage, 'asset'),
+ display_id, transform_source=js_to_json)
+
+ title = unescapeHTML(asset['AssetTitle']).strip()
+
+ def extract(field):
+ return self._search_regex(
+ r'<div[^>]+>\s*<p>%s:<p>\s*</div>\s*<div[^>]+>\s*<p>([^<]+)</p>' % field,
+ webpage, field, default=None)