Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/zdf.py (Python)

Code before:
                            continue
                        seen_urls.add(format_url)
                        ext = determine_ext(format_url)
                        if ext == 'm3u8':
                            fmts = self._extract_m3u8_formats(
                                format_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
                        elif ext in ('mp4', 'webm'):
                            height = int_or_none(quality.get('highestVerticalResolution'))
                            width = round(aspect_ratio * height) if aspect_ratio and height else None
                            fmts = [{
                                'url': format_url,
                                **parse_codecs(quality.get('mimeCodec')),
                                'height': height,
                                'width': width,
                                'format_id': join_nonempty('http', stream.get('type')),
                                'tbr': int_or_none(self._search_regex(r'_(\d+)k_', format_url, 'tbr', default=None)),
                            }]
                        else:
                            self.write_debug(f'Unsupported extension {ext} ({format_url}).')
                            fmts = []

                        f_class = variant.get('class')
                        for f in fmts:
                            f_lang = ISO639Utils.short2long(
                                (f.get('language') or variant.get('language') or '').lower())
                            has_video = (f.get('vcodec') or 'none') != 'none'
                            formats.append({
                                **f,
                                'format_id': join_nonempty(f['format_id'], is_dgs and 'dgs'),
                                'format_note': join_nonempty(
                                    has_video and f_class,
                                    is_dgs and 'German Sign Language',
                                    f.get('format_note'), delim=', '),
                                'preference': -2 if is_dgs else -1,
                                'language': f_lang,
                                'language_preference': (
                                    -10 if ((not has_video and f.get('format_note') == 'Audiodeskription')
                                            or (has_video and f_class == 'ad'))
                                    else 10 if f_lang == 'deu' and f_class == 'main'
                                    else 5 if f_lang == 'deu'
                                    else 1 if f_class == 'main'
                                    else -1),
                            })

        return {
            'id': content_id or video_id,
            'duration': duration,
            'formats': formats,
            'subtitles': self._extract_subtitles(src_captions),
        }


Review comment (suggestion):
wouldn't `has_audio` be more to the point? I don't like defaulting to `'none'`
```suggestion
                            has_audio = f.get('acodec') != 'none'
```

Code after:
                            continue
                        seen_urls.add(format_url)
                        ext = determine_ext(format_url)
                        if ext == 'm3u8':
                            fmts = self._extract_m3u8_formats(
                                format_url, video_id, 'mp4', m3u8_id='hls', fatal=False)
                        elif ext in ('mp4', 'webm'):
                            height = int_or_none(quality.get('highestVerticalResolution'))
                            width = round(aspect_ratio * height) if aspect_ratio and height else None
                            fmts = [{
                                'url': format_url,
                                **parse_codecs(quality.get('mimeCodec')),
                                'height': height,
                                'width': width,
                                'format_id': join_nonempty('http', stream.get('type')),
                                'tbr': int_or_none(self._search_regex(r'_(\d+)k_', format_url, 'tbr', default=None)),
                            }]
                        else:
                            self.report_warning(f'Skipping unsupported extension "{ext}"', video_id=video_id)
                            fmts = []

                        f_class = variant.get('class')
                        for f in fmts:
                            f_lang = ISO639Utils.short2long(
                                (f.get('language') or variant.get('language') or '').lower())
                            is_audio_only = f.get('vcodec') == 'none'
                            formats.append({
                                **f,
                                'format_id': join_nonempty(f['format_id'], is_dgs and 'dgs'),
                                'format_note': join_nonempty(
                                    not is_audio_only and f_class,
                                    is_dgs and 'German Sign Language',
                                    f.get('format_note'), delim=', '),
                                'preference': -2 if is_dgs else -1,
                                'language': f_lang,
                                'language_preference': (
                                    -10 if ((is_audio_only and f.get('format_note') == 'Audiodeskription')
                                            or (not is_audio_only and f_class == 'ad'))
                                    else 10 if f_lang == 'deu' and f_class == 'main'
                                    else 5 if f_lang == 'deu'
                                    else 1 if f_class == 'main'
                                    else -1),
                            })

        return {
            'id': content_id or video_id,
            'duration': duration,
            'formats': formats,
            'subtitles': self._extract_subtitles(src_captions),
        }