- 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_html = get_element_by_attribute('class', 'Content Copy', webpage)
- 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:
+ formats.append({
+ 'url': encoding_url,
+ 'format_id': code.lower(),
+ 'quality': pref,
+ 'tbr': int_or_none(xpath_text(encoding, 'AVERAGEBITRATE')),
+ })
+ self._sort_formats(formats)
+
+ return {