+ fmts = {}
+ for fmt in ('mp4', 'flv'):
+ fmt_list = self._parse_json(self._search_regex(
+ r'var %sjson\s*=\s*(\[.*?\]);' % fmt, webpage, '%s formats' % fmt), video_id)
+ for f in fmt_list:
+ fmts[f['fname']] = _decode(f['sUrl'])
+
+ qualities = self._parse_json(self._search_regex(
+ r'var player_btns\s*=\s*(.*?);\n', webpage, 'quality info'), video_id)
+
+ formats = []
+ for fname, url in fmts.items():
+ f = {
+ 'url': url,
+ }
+ if fname in qualities:
+ qual = qualities[fname]
+ f.update({
+ 'format_id': '%s_%sp' % (determine_ext(url), qual['h']),
+ 'width': qual['w'],
+ 'height': qual['h'],
+ 'tbr': qual['br'],
+ })
+ formats.append(f)
+
+ self._sort_formats(formats)