ronantakizawa/codereview-bench huggingface dataset:
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/gettr.py (Python)

Code before:
        video_info = self._download_json('https://api.gettr.com/u/live/join/%s' % video_id, video_id, data={})['result']

        live_info = video_info['broadcast']
        live_url = url_or_none(live_info.get('url'))

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            live_url, video_id, ext='mp4',
            entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) if live_url else []

        thumbnails = []
        for thumbnail in try_get(video_info, lambda x: x['postData']['imgs']) or []:
            thumbnails.append({
                'url': urljoin(self._MEDIA_BASE_URL, thumbnail),
            })

        return {
            'id': video_id,
            'title': try_get(video_info, lambda x: x['postData']['ttl']),
            'description': try_get(video_info, lambda x: x['postData']['dsc']),
            'formats': formats,
            'subtitles': subtitles,
            'thumbnails': thumbnails,
            'uploader': try_get(video_info, lambda x: x['liveHostInfo']['nickname']),
            'uploader_id': try_get(video_info, lambda x: x['liveHostInfo']['_id']),
            'view_count': int_or_none(live_info.get('viewsCount')),
            'timestamp': int_or_none(live_info.get('startAt')),
            'duration': int_or_none(live_info.get('duration')),
            'is_live': bool_or_none(live_info.get('isLive')),
        }


Review comment (suggestion):
```suggestion
            'timestamp': float_or_none(live_info.get('startAt'), scale=1000),
```
Same as duration

Code after:
            'timestamp': 1643976662.858,
            'upload_date': '20220204',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_info = self._call_api('live/join/%s' % video_id, video_id, data={})

        live_info = video_info['broadcast']
        live_url = url_or_none(live_info.get('url'))

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            live_url, video_id, ext='mp4',
            entry_protocol='m3u8_native', m3u8_id='hls', fatal=False) if live_url else ([], {})

        thumbnails = [{
            'url': urljoin(self._MEDIA_BASE_URL, thumbnail),
        } for thumbnail in try_get(video_info, lambda x: x['postData']['imgs']) or []]

        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': try_get(video_info, lambda x: x['postData']['ttl']),
            'description': try_get(video_info, lambda x: x['postData']['dsc']),
            'formats': formats,
            'subtitles': subtitles,
            'thumbnails': thumbnails,
            'uploader': try_get(video_info, lambda x: x['liveHostInfo']['nickname']),
            'uploader_id': try_get(video_info, lambda x: x['liveHostInfo']['_id']),
            'view_count': int_or_none(live_info.get('viewsCount')),
            'timestamp': float_or_none(live_info.get('startAt'), scale=1000),
            'duration': float_or_none(live_info.get('duration'), scale=1000),
            'is_live': bool_or_none(live_info.get('isLive')),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/zoom.py (Python)

Code before:
                'height': int_or_none(data.get('shareResolvtionsHeight')),
                'format_id': str_or_none(data.get('shareVideoId')),
                'ext': 'mp4',
            })

        formats.append({
            'format_note': 'Camera stream',
            'url': str_or_none(data.get('viewMp4Url')),
            'width': int_or_none(data.get('viewResolvtionsWidth')),
            'height': int_or_none(data.get('viewResolvtionsHeight')),
            'format_id': str_or_none(data.get('recordingId')),
            'ext': 'mp4',
            'filesize_approx': parse_filesize(data.get('fileSize')),
        })

        return {
            'id': play_id,
            'title': data.get('topic'),
            'url': data.get('viewMp4Url'),
            'subtitles': subtitles,
            'formats': formats,
            'http_headers': {
                'Referer': base_url,
            },
        }


Review comment (suggestion):
`self._sort_formats` before returning. Add `preference` to the dicts (with comment explaining why) if you want to maintain a specific order

Code after:
        if data.get('viewMp4Url'):
            formats.append({
                'format_note': 'Camera stream',
                'url': str_or_none(data.get('viewMp4Url')),
                'width': int_or_none(data.get('viewResolvtionsWidth')),
                'height': int_or_none(data.get('viewResolvtionsHeight')),
                'format_id': str_or_none(data.get('recordingId')),
                'ext': 'mp4',
                'filesize_approx': parse_filesize(data.get('fileSize')),
                'preference': 0
            })

        if data.get('shareMp4Url'):
            formats.append({
                'format_note': 'Screen share stream',
                'url': str_or_none(data.get('shareMp4Url')),
                'width': int_or_none(data.get('shareResolvtionsWidth')),
                'height': int_or_none(data.get('shareResolvtionsHeight')),
                'format_id': str_or_none(data.get('shareVideoId')),
                'ext': 'mp4',
                'preference': -1
            })

        self._sort_formats(formats)

        return {
            'id': play_id,
            'title': data.get('topic'),
            'subtitles': subtitles,
            'formats': formats,
            'http_headers': {
                'Referer': base_url,
            },
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/zoom.py (Python)

Code before:
                'url': str_or_none(data.get('viewMp4Url')),
                'width': int_or_none(data.get('viewResolvtionsWidth')),
                'height': int_or_none(data.get('viewResolvtionsHeight')),
                'format_id': str_or_none(data.get('recordingId')),
                'ext': 'mp4',
                'filesize_approx': parse_filesize(data.get('fileSize')),
                'preference': 0
            })

        if data.get('shareMp4Url'):
            formats.append({
                'format_note': 'Screen share stream',
                'url': str_or_none(data.get('shareMp4Url')),
                'width': int_or_none(data.get('shareResolvtionsWidth')),
                'height': int_or_none(data.get('shareResolvtionsHeight')),
                'format_id': str_or_none(data.get('shareVideoId')),
                'ext': 'mp4',
                'preference': -1
            })

        self._sort_formats(formats)

        return {
            'id': play_id,
            'title': data.get('topic'),
            'url': data.get('viewMp4Url'),
            'subtitles': subtitles,
            'formats': formats,
            'http_headers': {
                'Referer': base_url,
            },
        }


Review comment (suggestion):
```suggestion
```
Dont set url when setting formats

Code after:
                'width': int_or_none(data.get('viewResolvtionsWidth')),
                'height': int_or_none(data.get('viewResolvtionsHeight')),
                'format_id': str_or_none(data.get('recordingId')),
                'ext': 'mp4',
                'filesize_approx': parse_filesize(data.get('fileSize')),
                'preference': 0
            })

        if data.get('shareMp4Url'):
            formats.append({
                'format_note': 'Screen share stream',
                'url': str_or_none(data.get('shareMp4Url')),
                'width': int_or_none(data.get('shareResolvtionsWidth')),
                'height': int_or_none(data.get('shareResolvtionsHeight')),
                'format_id': str_or_none(data.get('shareVideoId')),
                'ext': 'mp4',
                'preference': -1
            })

        self._sort_formats(formats)

        return {
            'id': play_id,
            'title': data.get('topic'),
            'subtitles': subtitles,
            'formats': formats,
            'http_headers': {
                'Referer': base_url,
            },
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/biqle.py (Python)

Code before:
# coding: utf-8
from __future__ import unicode_literals

import re

from .common import InfoExtractor
from .vk import VKIE
from ..compat import compat_b64decode

from ..utils import (
    int_or_none,
    js_to_json,
    traverse_obj,
    unified_timestamp,
)


class BIQLEIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watch/(?P<id>-?\d+_\d+)'
    _TESTS = [{
        'url': 'https://biqle.ru/watch/-2000421746_85421746',
        'md5': 'ae6ef4f04d19ac84e4658046d02c151c',
        'info_dict': {
            'id': '-2000421746_85421746',
            'ext': 'mp4',
            'title': 'Forsaken By Hope Studio Clip',
            'description': 'Forsaken By Hope Studio Clip — Смотреть онлайн',
            'upload_date': '19700101',
            'timestamp': 0,
            'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
        },
    }, {
        'url': 'http://biqle.org/watch/-44781847_168547604',
        'md5': '7f24e72af1db0edf7c1aaba513174f97',
        'info_dict': {

Review comment (suggestion):
```suggestion
from ..compat import compat_b64decode
from ..utils import (
```

Code after:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from .vk import VKIE
from ..compat import compat_b64decode
from ..utils import (
    int_or_none,
    js_to_json,
    traverse_obj,
    unified_timestamp,
)


class BIQLEIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?biqle\.(?:com|org|ru)/watch/(?P<id>-?\d+_\d+)'
    _TESTS = [{
        'url': 'https://biqle.ru/watch/-2000421746_85421746',
        'md5': 'ae6ef4f04d19ac84e4658046d02c151c',
        'info_dict': {
            'id': '-2000421746_85421746',
            'ext': 'mp4',
            'title': 'Forsaken By Hope Studio Clip',
            'description': 'Forsaken By Hope Studio Clip — Смотреть онлайн',
            'upload_date': '19700101',
            'thumbnail': r're:https://[^/]+/impf/7vN3ACwSTgChP96OdOfzFjUCzFR6ZglDQgWsIw/KPaACiVJJxM\.jpg\?size=800x450&quality=96&keep_aspect_ratio=1&background=000000&sign=b48ea459c4d33dbcba5e26d63574b1cb&type=video_thumb',
            'timestamp': 0,
        },
    }, {
        'url': 'http://biqle.org/watch/-44781847_168547604',
        'md5': '7f24e72af1db0edf7c1aaba513174f97',
        'info_dict': {
            'id': '-44781847_168547604',
            'ext': 'mp4',
            'title': 'Ребенок в шоке от автоматической мойки',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/videocampus_sachsen.py (Python)

Code before:
# coding: utf-8
from .common import InfoExtractor


class VideocampusSachsenIE(InfoExtractor):
    _VALID_URL = r'https?://videocampus\.sachsen\.de/(?:(?:m/(?P<tmp_id>[0-9a-f]+))|(?:(?P<c>category/)?video/(?P<display_id>[A-Za-z0-9-]+)/(?P<id>[0-9a-f]{32}))(?(c)/[0-9]+))'

    _TESTS = [
        {
            'url': 'https://videocampus.sachsen.de/m/e0d6c8ce6e394c188f1342f1ab7c50ed6fc4490b808699801def5cb2e46d76ca7367f622a9f516c542ffb805b24d6b643bd7c81f385acaac4c59081b87a2767b',
            'info_dict': {
                'id': 'e6b9349905c1628631f175712250f2a1',
                'title': 'Konstruktiver Entwicklungsprozess Vorlesung 7',
                'ext': 'mp4',
            },
        },
        {
            'url': 'https://videocampus.sachsen.de/video/Was-ist-selbstgesteuertes-Lernen/fc99c527e4205b121cb7c74433469262',
            'info_dict': {
                'id': 'fc99c527e4205b121cb7c74433469262',
                'title': 'Was ist selbstgesteuertes Lernen?',
                'ext': 'mp4',
            },
        },
        {
            'url': 'https://videocampus.sachsen.de/category/video/Tutorial-zur-Nutzung-von-Adobe-Connect-aus-Veranstalter-Sicht/09d4ed029002eb1bdda610f1103dd54c/100',
            'info_dict': {
                'id': '09d4ed029002eb1bdda610f1103dd54c',
                'title': 'Tutorial zur Nutzung von Adobe Connect aus Veranstalter-Sicht',
                'ext': 'mp4',
            },

Review comment (suggestion):
```suggestion
    _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
        m/(?P<tmp_id>[0-9a-f]+)|
        (?:category/)?video/[\w-]+/(?P<id>[0-9a-f]{32})
    )'''
```
(untested)

Code after:
# coding: utf-8
from .common import InfoExtractor


class VideocampusSachsenIE(InfoExtractor):
    _VALID_URL = r'''(?x)https?://videocampus\.sachsen\.de/(?:
        m/(?P<tmp_id>[0-9a-f]+)|
        (?:category/)?video/(?P<display_id>[\w-]+)/(?P<id>[0-9a-f]{32})
    )'''

    _TESTS = [
        {
            'url': 'https://videocampus.sachsen.de/m/e0d6c8ce6e394c188f1342f1ab7c50ed6fc4490b808699801def5cb2e46d76ca7367f622a9f516c542ffb805b24d6b643bd7c81f385acaac4c59081b87a2767b',
            'info_dict': {
                'id': 'e6b9349905c1628631f175712250f2a1',
                'title': 'Konstruktiver Entwicklungsprozess Vorlesung 7',
                'ext': 'mp4',
            },
        },
        {
            'url': 'https://videocampus.sachsen.de/video/Was-ist-selbstgesteuertes-Lernen/fc99c527e4205b121cb7c74433469262',
            'info_dict': {
                'id': 'fc99c527e4205b121cb7c74433469262',
                'title': 'Was ist selbstgesteuertes Lernen?',
                'display_id': 'Was-ist-selbstgesteuertes-Lernen',
                'ext': 'mp4',
            },
        },
        {
            'url': 'https://videocampus.sachsen.de/category/video/Tutorial-zur-Nutzung-von-Adobe-Connect-aus-Veranstalter-Sicht/09d4ed029002eb1bdda610f1103dd54c/100',
            'info_dict': {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/videocampus_sachsen.py (Python)

Code before:
            'title': title,
            'display_id': display_id,
            'formats': formats,
            'subtitles': subtitles
        }


class VideocampusSachsenEmbedIE(InfoExtractor):
    _VALID_URL = r'https?://videocampus.sachsen.de/media/embed\?key=(?P<id>[0-9a-f]+)'

    _TESTS = [
        {
            'url': 'https://videocampus.sachsen.de/media/embed?key=fc99c527e4205b121cb7c74433469262',
            'info_dict': {
                'id': 'fc99c527e4205b121cb7c74433469262',
                'title': 'Was ist selbstgesteuertes Lernen?',
                'ext': 'mp4',
            },
        }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(url, video_id)
        title = self._html_search_regex(r'<img[^>]*title="([^"<]+)"', webpage, 'title')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            f'https://videocampus.sachsen.de/media/hlsMedium/key/{video_id}/format/auto/ext/mp4/learning/0/path/m3u8',
            video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'subtitles': subtitles,
        }


Review comment (suggestion):
```suggestion
        title = self._html_search_regex(r'<img[^>]*title="([^"<]+)"', webpage, 'title', fatal=False)
```

Code after:
            'title': title,
            'display_id': display_id,
            'formats': formats,
            'subtitles': subtitles
        }


class VideocampusSachsenEmbedIE(InfoExtractor):
    _VALID_URL = r'https?://videocampus.sachsen.de/media/embed\?key=(?P<id>[0-9a-f]+)'

    _TESTS = [
        {
            'url': 'https://videocampus.sachsen.de/media/embed?key=fc99c527e4205b121cb7c74433469262',
            'info_dict': {
                'id': 'fc99c527e4205b121cb7c74433469262',
                'title': 'Was ist selbstgesteuertes Lernen?',
                'ext': 'mp4',
            },
        }
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)

        webpage = self._download_webpage(url, video_id)
        title = self._html_search_regex(r'<img[^>]*title="([^"<]+)"', webpage, 'title', fatal=False)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            f'https://videocampus.sachsen.de/media/hlsMedium/key/{video_id}/format/auto/ext/mp4/learning/0/path/m3u8',
            video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'subtitles': subtitles,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/rtvs.py (Python)

Code before:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor

from ..utils import (
    int_or_none,
    parse_duration,
    traverse_obj,
    unified_timestamp,
)


class RTVSIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv/?.*/(?P<id>\d+)\??.*'
    _TESTS = [{
        # radio archive
        'url': 'http://www.rtvs.sk/radio/archiv/11224/414872',
        'md5': '134d5d6debdeddf8a5d761cbc9edacb8',
        'info_dict': {
            'id': '414872',
            'ext': 'mp3',
            'title': 'Ostrov pokladov 1 časť.mp3',
            'duration': 2854,
            'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0000/b1R8.rtvs.jpg',
            'display_id': '135331',
        }
    }, {
        # tv archive
        'url': 'http://www.rtvs.sk/televizia/archiv/8249/63118',
        'info_dict': {
            'id': '63118',
            'ext': 'mp4',
            'title': 'Amaro Džives - Náš deň',
            'description': 'Galavečer pri príležitosti Medzinárodného dňa Rómov.',
            'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0031/L7Qm.amaro_dzives_png.jpg',
            'timestamp': 1428555900,
            'upload_date': '20150409',
            'duration': 4986,
        }

Review comment (suggestion):
did u mean this?
```suggestion
    _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv(?:/\d+)?/(?P<id>\d+)/?(?:[#?]|$)'
```

Code after:
# coding: utf-8
from __future__ import unicode_literals

import re

from .common import InfoExtractor

from ..utils import (
    parse_duration,
    traverse_obj,
    unified_timestamp,
)


class RTVSIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?rtvs\.sk/(?:radio|televizia)/archiv(?:/\d+)?/(?P<id>\d+)/?(?:[#?]|$)'
    _TESTS = [{
        # radio archive
        'url': 'http://www.rtvs.sk/radio/archiv/11224/414872',
        'md5': '134d5d6debdeddf8a5d761cbc9edacb8',
        'info_dict': {
            'id': '414872',
            'ext': 'mp3',
            'title': 'Ostrov pokladov 1 časť.mp3',
            'duration': 2854,
            'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0000/b1R8.rtvs.jpg',
            'display_id': '135331',
        }
    }, {
        # tv archive
        'url': 'http://www.rtvs.sk/televizia/archiv/8249/63118',
        'info_dict': {
            'id': '63118',
            'ext': 'mp4',
            'title': 'Amaro Džives - Náš deň',
            'description': 'Galavečer pri príležitosti Medzinárodného dňa Rómov.',
            'thumbnail': 'https://www.rtvs.sk/media/a501/image/file/2/0031/L7Qm.amaro_dzives_png.jpg',
            'timestamp': 1428555900,
            'upload_date': '20150409',
            'duration': 4986,
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/tubitv.py (Python)

Code before:
            infodict['season_number'] = int(episode_match.group(1))
            infodict['episode_number'] = int(episode_match.group(2))
            infodict['episode_title'] = episode_match.group(3)

        return infodict


class TubiTvShowIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
    _TESTS = [{
        'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
        'playlist_mincount': 390,
        'info_dict': {
            'id': 'the-joy-of-painting-with-bob-ross',
        }
    }]

    def _entries(self, show_url, show_name):
        show_webpage = self._download_webpage(show_url, show_name)

        raw_json = self._search_regex(
            r"window\.__data\s*=\s*({[^<]+});\s*</script>",
            show_webpage, 'data')

        show_json = self._parse_json(raw_json, show_name, transform_source=js_to_json)['video']

        for episode_id in show_json['fullContentById'].keys():
            yield self.url_result(
                'tubitv:%s' % episode_id,
                ie=TubiTvIE.ie_key(), video_id=episode_id)

    def _real_extract(self, url):
        show_name = self._match_valid_url(url).group('show_name')
        return self.playlist_result(self._entries(url, show_name), playlist_id=show_name)


Review comment (suggestion):
unnecessary changes. Only the regex needs to be changed
```suggestion
        show_json = self._parse_json(self._search_regex(
            r'window\.__data\s*=\s*({[^<]+});\s*</script>',
            show_webpage, 'data'), show_name, transform_source=js_to_json)['video']
```

Code after:
            'episode_title': episode_title
        }


class TubiTvShowIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?tubitv\.com/series/[0-9]+/(?P<show_name>[^/?#]+)'
    _TESTS = [{
        'url': 'https://tubitv.com/series/3936/the-joy-of-painting-with-bob-ross?start=true',
        'playlist_mincount': 390,
        'info_dict': {
            'id': 'the-joy-of-painting-with-bob-ross',
        }
    }]

    def _entries(self, show_url, show_name):
        show_webpage = self._download_webpage(show_url, show_name)

        show_json = self._parse_json(self._search_regex(
            r'window\.__data\s*=\s*({[^<]+});\s*</script>',
            show_webpage, 'data'), show_name, transform_source=js_to_json)['video']

        for episode_id in show_json['fullContentById'].keys():
            yield self.url_result(
                'tubitv:%s' % episode_id,
                ie=TubiTvIE.ie_key(), video_id=episode_id)

    def _real_extract(self, url):
        show_name = self._match_valid_url(url).group('show_name')
        return self.playlist_result(self._entries(url, show_name), playlist_id=show_name)