- formats = []
- for vid in playinfo['result'].get('videos', {}).get('list', []):
- formats.append({
- 'url': vid['source'],
- 'ext': 'mp4',
- 'abr': vid.get('bitrate', {}).get('audio'),
- 'vbr': vid.get('bitrate', {}).get('video'),
- 'format_id': vid['encodingOption']['name'],
- 'height': vid.get('height'),
- 'width': vid.get('width'),
- })
+ formats = [{
+ 'url': vid['source'],
+ 'format_id': vid.get('encodingOption', {}).get('name'),
+ 'abr': float_or_none(vid.get('bitrate', {}).get('audio')),
+ 'vbr': float_or_none(vid.get('bitrate', {}).get('video')),
+ 'width': int_or_none(vid.get('encodingOption', {}).get('width')),
+ 'height': int_or_none(vid.get('encodingOption', {}).get('height')),
+ 'filesize': int_or_none(vid.get('size')),
+ } for vid in playinfo.get('videos', {}).get('list', []) if vid.get('source')]