- for t, rs in config['formats'].items():
- if not rs or not hasattr(rs, 'items'):
- self._warn('formats: {0}: no resolutions', t)
- continue
-
- for res, obj in rs.items():
- format_id = '{0}_{1}'.format(t, res)
-
- if (not obj or not obj.get('url') or
- not isinstance(obj['url'], str)):
- self._warn('formats: {0}: no url', format_id)
- continue
-
- fmt = {
- 'url': obj['url'],
- 'format_id': format_id
- }
- try:
- fmt['height'] = int(res)
- except ValueError as e:
- self._warn('formats: {0}: height: {1}', t, e)
-
- formats.append(fmt)
-
+ for source_node in doc.findall('.//{http://rss.jwpcdn.com/}source'):
+ label = source_node.attrib['label']
+ height = int_or_none(self._search_regex(
+ r'^(.*?_)?([0-9]+)p$', label, 'height', default=None))
+ formats.append({
+ 'url': source_node.attrib['file'],
+ 'format_note': label,
+ 'height': height,
+ })