- for code in ['LOW', 'HIGH', 'HQ']:
- encoding = encodings.find(code)
- if encoding is None:
- continue
- encoding_url = encoding.find('FILENAME').text
- formats.append({
- 'url': encoding_url,
- 'ext': determine_ext(encoding_url),
- 'format_id': code.lower(),
- })
-
- descr = self._html_search_regex(r'<p class="Content Copy">(.*?)</p>', webpage, u'description')
- info = {
+ for pref, code in enumerate(['LOW', 'HIGH', 'HQ']):
+ encoding = xpath_element(encodings, code)
+ if encoding is not None:
+ encoding_url = xpath_text(encoding, 'FILENAME')
+ if encoding_url:
+ tbr = xpath_text(encoding, 'AVERAGEBITRATE', 1000)
+ if tbr:
+ tbr = int_or_none(tbr.replace(',', '.'))
+ f = {
+ 'url': encoding_url,
+ 'format_id': code.lower(),
+ 'quality': pref,
+ 'tbr': tbr,
+ 'vcodec': xpath_text(encoding, 'CODEC'),
+ }
+ mobj = re.search(r'(\d+)x(\d+)_(\d+)\.mp4', encoding_url)
+ if mobj:
+ f.update({
+ 'width': int(mobj.group(1)),
+ 'height': int(mobj.group(2)),
+ 'tbr': tbr or int(mobj.group(3)),
+ })
+ formats.append(f)
+ self._sort_formats(formats)
+
+ return {