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

Code before:
                'uploader_id': 'maheshchookolingo',
                'uploader_url': 'http://www.youtube.com/user/maheshchookolingo',
                'channel': 'Mahesh Chookolingo',
                'channel_id': 'UCox6YeMSY1PQInbCtTaZj_w',
                'channel_url': 'https://www.youtube.com/channel/UCox6YeMSY1PQInbCtTaZj_w',
                'categories': ['Entertainment'],
                'tags': list,
                'availability': 'public',
                'live_status': 'not_live',
                'view_count': int,
                'comment_count': int,
                'like_count': int,
                'channel_follower_count': int,
                'age_limit': 0,
                'playable_in_embed': True,
            },
        },
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._download_json(
            'https://api.parler.com/v0/public/parleys/%s' % video_id, video_id)['data']

        if data.get('link'):
            return self.url_result(data.get('link'), YoutubeIE)

        return {
            'id': video_id,
            **traverse_obj(data, {
                'url': ('video', 'videoSrc'),
                'thumbnail': ('video', 'thumbnailUrl'),
                'title': ('title', {strip_or_none}),
                'description': ('body', {clean_html}, {lambda x: x if x else None}),
                'timestamp': ('date_created', {unified_timestamp}),
                'uploader': ('user', 'name', {strip_or_none}),
                'uploader_id': ('user', 'username', {str}),
                'uploader_url': ('user', 'username', {lambda x: urljoin('https://parler.com/', x)}),
                'view_count': ('views', {int_or_none}),
                'comment_count': ('total_comments', {int_or_none}),
                'repost_count': ('echos', {int_or_none}),
            })
        }


Review comment (suggestion):
```suggestion
            return self.url_result(data['link'], YoutubeIE)
```

Code after:
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        data = self._download_json(f'https://api.parler.com/v0/public/parleys/{video_id}',
                                   video_id)['data']
        if data.get('link'):
            return self.url_result(data['link'], YoutubeIE)

        return {
            'id': video_id,
            'title': strip_or_none(data.get('title')) or '',
            **traverse_obj(data, {
                'url': ('video', 'videoSrc'),
                'thumbnail': ('video', 'thumbnailUrl'),
                'description': ('body', {clean_html}),
                'timestamp': ('date_created', {unified_timestamp}),
                'uploader': ('user', 'name', {strip_or_none}),
                'uploader_id': ('user', 'username', {str}),
                'uploader_url': ('user', 'username', {functools.partial(urljoin, 'https://parler.com/')}),
                'view_count': ('views', {int_or_none}),
                'comment_count': ('total_comments', {int_or_none}),
                'repost_count': ('echos', {int_or_none}),
            })
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (suggestion):
```suggestion
                formats.append({'url': media_url})
```

Code after:
            else:
                self.report_warning(f'Unknown format {media_ext!r}')

        return formats, subtitles

    @staticmethod
    def _extract_base_info(data):
        return {
            'id': data['crn'],
            **traverse_obj(data, {
                'title': 'title',
                'description': 'description',
                'duration': ('duration', {partial(int_or_none, scale=1000)}),
                'timestamp': ('schedulingStart', {parse_iso8601}),
                'season_number': 'seasonNumber',
                'episode_number': 'episodeNumber',
                'view_count': 'viewCount',
                'like_count': 'likeCount',
            }),
            'thumbnails': orderedSet(traverse_obj(data, ('images', ..., {
                'url': ('url', {url_or_none}),
            }))),
        }

    def _extract_url_info(self, data):
        return {
            '_type': 'url',
            'url': format_field(data, 'slug', 'https://www.bibeltv.de/mediathek/videos/%s'),
            **self._extract_base_info(data),
        }

    def _extract_video_info(self, data):
        crn_id = data['crn']

        if data.get('drm'):
            self.report_drm(crn_id)

        json_data = self._download_json(
            format_field(data, 'id', f'{self.API_URL}/video/%s'), crn_id,
            headers={'Authorization': self.AUTH_TOKEN}, fatal=False,
            errnote='No formats available') or {}

        formats, subtitles = self._extract_formats_and_subtitles(
            traverse_obj(json_data, ('video', 'videoUrls', ...)), crn_id)

        return {
            '_type': 'video',
            **self._extract_base_info(data),
            'formats': formats,
            'subtitles': subtitles,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (suggestion):
use `traverse_obj` here instead:
```suggestion
            traverse_obj(json_data, ('video', 'videoUrls', ..., {url_or_none})), crn_id)
```

Code after:
        if data.get('drm'):
            self.report_drm(crn_id)

        json_data = self._download_json(
            format_field(data, 'id', f'{self.API_URL}/video/%s'), crn_id,
            headers={'Authorization': self.AUTH_TOKEN}, fatal=False,
            errnote='No formats available') or {}

        formats, subtitles = self._extract_formats_and_subtitles(
            traverse_obj(json_data, ('video', 'videoUrls', ...)), crn_id)

        return {
            '_type': 'video',
            **self._extract_base_info(data),
            'formats': formats,
            'subtitles': subtitles,
        }


class BibelTVVideoIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV single video'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?P<id>\d+)[\w-]+'
    IE_NAME = 'bibeltv:video'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/344436-alte-wege',
        'md5': 'ec1c07efe54353780512e8a4103b612e',
        'info_dict': {
            'id': '344436',
            'ext': 'mp4',
            'title': 'Alte Wege',
            'description': 'md5:2f4eb7294c9797a47b8fd13cccca22e9',
            'timestamp': 1677877071,
            'duration': 150.0,
            'upload_date': '20230303',
            'thumbnail': r're:https://bibeltv\.imgix\.net/[\w-]+\.jpg',
            'episode': 'Episode 1',
            'episode_number': 1,
            'view_count': int,
            'like_count': int,
        },
        'params': {
            'format': '6',
        },
    }]

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        video_data = traverse_obj(
            self._search_nextjs_data(self._download_webpage(url, crn_id), crn_id),
            ('props', 'pageProps', 'videoPageData', 'videos', 0, {dict}))
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (suggestion):
```suggestion
        video_data = traverse_obj(
             self._search_nextjs_data(self._download_webpage(url, crn_id), crn_id),
             ('props', 'pageProps', 'videoPageData', 'videos', 0, {dict}))
```

Code after:
    IE_NAME = 'bibeltv:video'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/344436-alte-wege',
        'md5': 'ec1c07efe54353780512e8a4103b612e',
        'info_dict': {
            'id': '344436',
            'ext': 'mp4',
            'title': 'Alte Wege',
            'description': 'md5:2f4eb7294c9797a47b8fd13cccca22e9',
            'timestamp': 1677877071,
            'duration': 150.0,
            'upload_date': '20230303',
            'thumbnail': r're:https://bibeltv\.imgix\.net/[\w-]+\.jpg',
            'episode': 'Episode 1',
            'episode_number': 1,
            'view_count': int,
            'like_count': int,
        },
        'params': {
            'format': '6',
        },
    }]

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        video_data = traverse_obj(
            self._search_nextjs_data(self._download_webpage(url, crn_id), crn_id),
            ('props', 'pageProps', 'videoPageData', 'videos', 0, {dict}))
        if not video_data:
            raise ExtractorError('Missing video data.')

        return self._extract_video_info(video_data)


class BibelTVSeriesIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV series playlist'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/serien/(?P<id>\d+)[\w-]+'
    IE_NAME = 'bibeltv:series'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/serien/333485-ein-wunder-fuer-jeden-tag',
        'playlist_mincount': 400,
        'info_dict': {
            'id': '333485',
            'title': 'Ein Wunder für jeden Tag',
            'description': 'Tägliche Kurzandacht mit Déborah Rosenkranz.',
        },
    }]

    def _real_extract(self, url):
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (suggestion):
```suggestion
        video_data = traverse_obj(serie_data, ('videos', ..., {dict}))
```

Code after:


class BibelTVSeriesIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV series playlist'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/serien/(?P<id>\d+)[\w-]+'
    IE_NAME = 'bibeltv:series'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/serien/333485-ein-wunder-fuer-jeden-tag',
        'playlist_mincount': 400,
        'info_dict': {
            'id': '333485',
            'title': 'Ein Wunder für jeden Tag',
            'description': 'Tägliche Kurzandacht mit Déborah Rosenkranz.',
        },
    }]

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        webpage = self._download_webpage(url, crn_id)
        nextjs_data = self._search_nextjs_data(webpage, crn_id)
        series_data = traverse_obj(nextjs_data, ('props', 'pageProps', 'seriePageData', {dict}))
        if not series_data:
            raise ExtractorError('Missing series data.')

        return self.playlist_result(
            traverse_obj(series_data, ('videos', ..., {dict}, {self._extract_url_info})),
            crn_id, series_data.get('title'), clean_html(series_data.get('description')))


class BibelTVLiveIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV live program'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/livestreams/(?P<id>[\w-]+)'
    IE_NAME = 'bibeltv:live'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/livestreams/bibeltv/',
        'info_dict': {
            'id': 'bibeltv',
            'ext': 'mp4',
            'title': 're:Bibel TV',
            'live_status': 'is_live',
            'thumbnail': 'https://streampreview.bibeltv.de/bibeltv.webp',
        },
        'params': {'skip_download': 'm3u8'},
    }, {
        'url': 'https://www.bibeltv.de/livestreams/impuls/',
        'only_matching': True,
    }]

    def _real_extract(self, url):
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (suggestion):
Maybe `format_field` makes more sense here? That will result in a falsy value instead of an invalid url...
```suggestion
            'url': format_field(data, 'slug', 'https://www.bibeltv.de/mediathek/videos/%s'),
```

Code after:
                'timestamp': ('schedulingStart', {parse_iso8601}),
                'season_number': 'seasonNumber',
                'episode_number': 'episodeNumber',
                'view_count': 'viewCount',
                'like_count': 'likeCount',
            }),
            'thumbnails': orderedSet(traverse_obj(data, ('images', ..., {
                'url': ('url', {url_or_none}),
            }))),
        }

    def _extract_url_info(self, data):
        return {
            '_type': 'url',
            'url': format_field(data, 'slug', 'https://www.bibeltv.de/mediathek/videos/%s'),
            **self._extract_base_info(data),
        }

    def _extract_video_info(self, data):
        crn_id = data['crn']

        if data.get('drm'):
            self.report_drm(crn_id)

        json_data = self._download_json(
            format_field(data, 'id', f'{self.API_URL}/video/%s'), crn_id,
            headers={'Authorization': self.AUTH_TOKEN}, fatal=False,
            errnote='No formats available') or {}

        formats, subtitles = self._extract_formats_and_subtitles(
            traverse_obj(json_data, ('video', 'videoUrls', ...)), crn_id)

        return {
            '_type': 'video',
            **self._extract_base_info(data),
            'formats': formats,
            'subtitles': subtitles,
        }


class BibelTVVideoIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV single video'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?P<id>\d+)[\w-]+'
    IE_NAME = 'bibeltv:video'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/344436-alte-wege',
        'md5': 'ec1c07efe54353780512e8a4103b612e',
        'info_dict': {
            'id': '344436',
            'ext': 'mp4',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bibeltv.py (Python)

Code before:
from .common import InfoExtractor


class BibelTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?:crn/)?(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/329703-sprachkurs-in-malaiisch',
        'md5': '252f908192d611de038b8504b08bf97f',
        'info_dict': {
            'id': 'ref:329703',
            'ext': 'mp4',
            'title': 'Sprachkurs in Malaiisch',
            'description': 'md5:3e9f197d29ee164714e67351cf737dfe',
            'timestamp': 1608316701,
            'uploader_id': '5840105145001',
            'upload_date': '20201218',
        }
    }, {
        'url': 'https://www.bibeltv.de/mediathek/videos/crn/326374',
        'only_matching': True,
    }]
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5840105145001/default_default/index.html?videoId=ref:%s'

    def _real_extract(self, url):
        crn_id = self._match_id(url)
        return self.url_result(
            self.BRIGHTCOVE_URL_TEMPLATE % crn_id, 'BrightcoveNew')


Review comment (refactor):
This might be cleaner? Are there direct duplicates?
```suggestion
            'thumbnails': [{'url': url} for url in set(traverse_obj(data, ('images', ..., 'url', {url_or_none})))],
```

Code after:
            }),
            'thumbnails': orderedSet(traverse_obj(data, ('images', ..., {
                'url': ('url', {url_or_none}),
            }))),
        }

    def _extract_url_info(self, data):
        return {
            '_type': 'url',
            'url': format_field(data, 'slug', 'https://www.bibeltv.de/mediathek/videos/%s'),
            **self._extract_base_info(data),
        }

    def _extract_video_info(self, data):
        crn_id = data['crn']

        if data.get('drm'):
            self.report_drm(crn_id)

        json_data = self._download_json(
            format_field(data, 'id', f'{self.API_URL}/video/%s'), crn_id,
            headers={'Authorization': self.AUTH_TOKEN}, fatal=False,
            errnote='No formats available') or {}

        formats, subtitles = self._extract_formats_and_subtitles(
            traverse_obj(json_data, ('video', 'videoUrls', ...)), crn_id)

        return {
            '_type': 'video',
            **self._extract_base_info(data),
            'formats': formats,
            'subtitles': subtitles,
        }


class BibelTVVideoIE(BibelTVBaseIE):
    IE_DESC = 'BibelTV single video'
    _VALID_URL = r'https?://(?:www\.)?bibeltv\.de/mediathek/videos/(?P<id>\d+)[\w-]+'
    IE_NAME = 'bibeltv:video'

    _TESTS = [{
        'url': 'https://www.bibeltv.de/mediathek/videos/344436-alte-wege',
        'md5': 'ec1c07efe54353780512e8a4103b612e',
        'info_dict': {
            'id': '344436',
            'ext': 'mp4',
            'title': 'Alte Wege',
            'description': 'md5:2f4eb7294c9797a47b8fd13cccca22e9',
            'timestamp': 1677877071,
            'duration': 150.0,
            'upload_date': '20230303',