-
- def compatible_formats(formats):
- # TODO: some formats actually allow this (mkv, webm, ogg, mp4), but not all of them.
- video_formats = [format for format in formats if format.get('vcodec') != 'none']
- audio_formats = [format for format in formats if format.get('acodec') != 'none']
- if len(video_formats) > 2 or len(audio_formats) > 2:
- return False
-
- # Check extension
- exts = {format.get('ext') for format in formats}
- COMPATIBLE_EXTS = (
- {'mp3', 'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v', 'ismv', 'isma'},
- {'webm'},
- )
- for ext_sets in COMPATIBLE_EXTS:
- if ext_sets.issuperset(exts):
- return True
- # TODO: Check acodec/vcodec
- return False
-