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

Code before:
        format_types = defaultdict(lambda: defaultdict(int))
        for format_info in format_infos:
            formats.extend(self._extract_formats(format_info, format_types))

        self._guess_formats(formats, format_types, id)
        self._sort_formats(formats)

        return {
            "_type": "video",
            "id": id,
            "title": title,
            "creator": creator,
            "duration": duration,
            "series": series_title,
            "episode": episode_title,
            "formats": formats
        }

    def _extract_formats(self, format_info, format_types):
        PREFERRED_TYPE = "presentation"

        url = try_get(format_info, lambda x: x["url"])
        type = try_get(format_info, lambda x: x["type"]) or "unknown"
        transport = try_get(format_info, lambda x: x["transport"]) or "https"
        audio_bitrate = try_get(format_info, lambda x: x["audio"]["bitrate"])
        video_bitrate = try_get(format_info, lambda x: x["video"]["bitrate"])
        framerate = try_get(format_info, lambda x: x["video"]["framerate"])
        resolution = try_get(format_info, lambda x: x["video"]["resolution"])

        type = str(type).replace("/delivery", "")
        transport = str(transport).lower()

        if isinstance(audio_bitrate, int):
            audio_bitrate = audio_bitrate / 1000
        if isinstance(video_bitrate, int):
            video_bitrate = video_bitrate / 1000
        if isinstance(audio_bitrate, int) and isinstance(video_bitrate, int):
            bitrate = audio_bitrate + video_bitrate
        else:
            bitrate = None

        if type == PREFERRED_TYPE:
            preference = -1
        else:
            preference = -2

        if transport == "https":
            formats = [{
                "url": url,
                "tbr": bitrate,
                "abr": audio_bitrate,

Review comment (suggestion):
```suggestion
        audio_bitrate = try_get(format_info, lambda x: x["audio"]["bitrate"] / 1000)
        video_bitrate = try_get(format_info, lambda x: x["video"]["bitrate"] / 1000)
```

Code after:
                    'creator': 'Neuhold R',
                    'duration': 5566404,
                }
            },
            {
                'info_dict': {
                    'id': '75e4c71c-d99d-4e56-b0e6-4f2bcdf11f29',
                    'series_id': '0e6351b7-c372-491e-8a49-2c9b7e21c5a6',
                    'ext': 'mp4',
                    'title': '#1 Variantenstudium',
                    'episode': '#1 Variantenstudium',
                    'series': '[209351] Strassenwesen',
                    'creator': 'Neuhold R',
                    'duration': 5420200,
                }
            }
        ],
        'min_playlist_count': 4
    }]

    def _real_extract(self, url):
        id = self._match_id(url)
        episodes_data = self._download_json(self._API_EPISODE, id, query={'sid': id}, note='Downloading episode list')
        series_data = self._download_json(
            'https://tube.tugraz.at/series/series.json', id, fatal=False,
            note='downloading series metadata', errnote='failed to download series metadata',
            query={
                'seriesId': id,
                'count': 1,
                'sort': 'TITLE'
            })

        return self.playlist_result(
            map(self._extract_episode, episodes_data['search-results']['result']), id,
            traverse_obj(series_data, ('catalogs', 0, 'http://purl.org/dc/terms/', 'title', 0, 'value')))