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

Code before:
            })

        thumbnails = []
        for thumbnail in video_data.get('thumbnails', {}).get('thumbnail', []):
            thumbnail_url = thumbnail.get('value')
            if not thumbnail_url:
                continue
            thumbnails.append({
                'url': thumbnail_url,
                'width': int_or_none(thumbnail.get('width')),
                'height': int_or_none(thumbnail.get('height')),
            })

        return {
            'id': video_id,
            'title': title,
            'description': video_data.get('longdescription') or video_data.get('description'),
            'duration': int_or_none(video_data.get('duration', {}).get('value'), 1000),
            'age_limit': parse_age_limit(video_data.get('tvrating', {}).get('rating')),
            'episode_number': int_or_none(video_data.get('episodenumber')),
            'series': video_data.get('show', {}).get('title'),
            'season_number': int_or_none(video_data.get('season', {}).get('num')),
            'thumbnails': thumbnails,
            'formats': formats,
            'subtitles': subtitles,
            'timestamp': timeconvert(video_data.get('airdates', {}).get('airdate', [None])[0]),
        }


Review comment (suggestion):
```suggestion
            'timestamp': unified_timestamp(traverse_obj(video_data, ('airdates', 'airdate', 0))),
```

Code after:
                formats.append(f)
        self._sort_formats(formats)

        for cc in video_data.get('closedcaption', {}).get('src', []):
            cc_url = cc.get('value')
            if not cc_url:
                continue
            ext = determine_ext(cc_url)
            if ext == 'xml':
                ext = 'ttml'
            subtitles.setdefault(cc.get('lang'), []).append({
                'url': cc_url,
                'ext': ext,
            })

        thumbnails = []
        for thumbnail in video_data.get('thumbnails', {}).get('thumbnail', []):
            thumbnail_url = thumbnail.get('value')
            if not thumbnail_url:
                continue
            thumbnails.append({
                'url': thumbnail_url,
                'width': int_or_none(thumbnail.get('width')),
                'height': int_or_none(thumbnail.get('height')),
            })

        return {
            'id': video_id,
            'title': title,
            'description': video_data.get('longdescription') or video_data.get('description'),
            'duration': int_or_none(video_data.get('duration', {}).get('value'), 1000),
            'age_limit': parse_age_limit(video_data.get('tvrating', {}).get('rating')),
            'episode_number': int_or_none(video_data.get('episodenumber')),
            'series': video_data.get('show', {}).get('title'),
            'season_number': int_or_none(video_data.get('season', {}).get('num')),
            'thumbnails': thumbnails,
            'formats': formats,
            'subtitles': subtitles,
            'timestamp': unified_timestamp(traverse_obj(video_data, ('airdates', 'airdate', 0))),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/startrek.py (Python)

Code before:
from yt_dlp.utils import int_or_none
from .common import InfoExtractor


class StarTrekIE(InfoExtractor):
    _VALID_URL = r'(?P<base>https://(?:intl|www)\.startrek\.com)/videos/(?P<id>[^/]+)'
    _TESTS = [{
        'url': 'https://intl.startrek.com/videos/watch-welcoming-jess-bush-to-the-ready-room',
        'md5': '491df5035c9d4dc7f63c79caaf9c839e',
        'info_dict': {
            'id': 'watch-welcoming-jess-bush-to-the-ready-room',
            'ext': 'mp4',
            'title': 'WATCH: Welcoming Jess Bush to The Ready Room',
            'duration': 1888,
            'timestamp': 1655388000,
            'upload_date': '20220616',
            'description': 'md5:1ffee884e3920afbdd6dd04e926a1221',
            # Thumbnail seems to have some tracking parameters added, ignore those.
            'thumbnail': r're:https://intl\.startrek\.com/sites/default/files/styles/video_1920x1080/public/images/2022-06/pp_14794_rr_thumb_107_yt_16x9.jpg(?:\?.+)?',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        urlbase = self._match_valid_url(url).group('base')


Review comment (refactor):
```suggestion
from .common import InfoExtractor
from ..utils import int_or_none
```

Code after:
from .common import InfoExtractor
from ..utils import int_or_none, urljoin


class StarTrekIE(InfoExtractor):
    _VALID_URL = r'(?P<base>https?://(?:intl|www)\.startrek\.com)/videos/(?P<id>[^/]+)'
    _TESTS = [{
        'url': 'https://intl.startrek.com/videos/watch-welcoming-jess-bush-to-the-ready-room',
        'md5': '491df5035c9d4dc7f63c79caaf9c839e',
        'info_dict': {
            'id': 'watch-welcoming-jess-bush-to-the-ready-room',
            'ext': 'mp4',
            'title': 'WATCH: Welcoming Jess Bush to The Ready Room',
            'duration': 1888,
            'timestamp': 1655388000,
            'upload_date': '20220616',
            'description': 'md5:1ffee884e3920afbdd6dd04e926a1221',
            'thumbnail': r're:https://(?:intl|www)\.startrek\.com/sites/default/files/styles/video_1920x1080/public/images/2022-06/pp_14794_rr_thumb_107_yt_16x9\.jpg(?:\?.+)?',
            'subtitles': {'en-US': [{
                'url': r're:https://(?:intl|www)\.startrek\.com/sites/default/files/video/captions/2022-06/TRR_SNW_107_v4\.vtt',
            }, {
                'url': 'https://media.startrek.com/2022/06/16/2043801155561/1069981_hls/trr_snw_107_v4-c4bfc25d/stream_vtt.m3u8',
            }]},
        }
    }, {
        'url': 'https://www.startrek.com/videos/watch-ethan-peck-and-gia-sandhu-beam-down-to-the-ready-room',
        'md5': 'f5ad74fbb86e91e0882fc0a333178d1d',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/_extractors.py (Python)

Code before:
)
from .limelight import (
    LimelightMediaIE,
    LimelightChannelIE,
    LimelightChannelListIE,
)
from .line import (
    LineLiveIE,
    LineLiveChannelIE,
)
from .linkedin import (
    LinkedInIE,
    LinkedInLearningIE,
    LinkedInLearningCourseIE,
)
from .linuxacademy import LinuxAcademyIE
from .litv import LiTVIE
from .livejournal import LiveJournalIE
from .livestream import (
    LivestreamIE,
    LivestreamOriginalIE,
    LivestreamShortenerIE,
)
from .lnkgo import (
    LnkGoIE,
    LnkIE,
)
from .localnews8 import LocalNews8IE
from .lovehomeporn import LoveHomePornIE
from .lrt import (
    LRTVODIE,
    LRTStreamIE
)
from .lynda import (
    LyndaIE,
    LyndaCourseIE
)
from .m6 import M6IE
from .magentamusik360 import MagentaMusik360IE
from .mailru import (
    MailRuIE,
    MailRuMusicIE,
    MailRuMusicSearchIE,
)
from .mainstreaming import MainStreamingIE
from .malltv import MallTVIE
from .mangomolo import (
    MangomoloVideoIE,
    MangomoloLiveIE,
)
from .manoto import (

Review comment (bug):
```suggestion
from .livestreamfails import LivestreamfailsIE
```

Code after:
)
from .limelight import (
    LimelightMediaIE,
    LimelightChannelIE,
    LimelightChannelListIE,
)
from .line import (
    LineLiveIE,
    LineLiveChannelIE,
)
from .linkedin import (
    LinkedInIE,
    LinkedInLearningIE,
    LinkedInLearningCourseIE,
)
from .linuxacademy import LinuxAcademyIE
from .litv import LiTVIE
from .livejournal import LiveJournalIE
from .livestream import (
    LivestreamIE,
    LivestreamOriginalIE,
    LivestreamShortenerIE,
)
from .livestreamfails import LivestreamfailsIE
from .lnkgo import (
    LnkGoIE,
    LnkIE,
)
from .localnews8 import LocalNews8IE
from .lovehomeporn import LoveHomePornIE
from .lrt import (
    LRTVODIE,
    LRTStreamIE
)
from .lynda import (
    LyndaIE,
    LyndaCourseIE
)
from .m6 import M6IE
from .magentamusik360 import MagentaMusik360IE
from .mailru import (
    MailRuIE,
    MailRuMusicIE,
    MailRuMusicSearchIE,
)
from .mainstreaming import MainStreamingIE
from .malltv import MallTVIE
from .mangomolo import (
    MangomoloVideoIE,
    MangomoloLiveIE,
)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/livestreamfails.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import (
    traverse_obj,
    unified_timestamp,
)


class LivestreamfailsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?livestreamfails\.com/clip/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://livestreamfails.com/clip/139200',
        'md5': '8a03aea1a46e94a05af6410337463102',
        'info_dict': {
            'id': '139200',
            'ext': 'mp4',
            'display_id': 'ConcernedLitigiousSalmonPeteZaroll-O8yo9W2L8OZEKhV2',
            'title': 'Streamer jumps off a trampoline at full speed',
            'creator': 'paradeev1ch',
            'thumbnail': r're:^https?://.+',
            'timestamp': 1656271785,
            'upload_date': '20220626',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        api_response = self._download_json(f'https://api.livestreamfails.com/clip/{video_id}', video_id)

        return {
            'id': video_id,

Review comment (suggestion):
```suggestion
from ..utils import traverse_obj, unified_timestamp
```

Code after:
from .common import InfoExtractor
from ..utils import format_field, traverse_obj, unified_timestamp


class LivestreamfailsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?livestreamfails\.com/clip/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://livestreamfails.com/clip/139200',
        'md5': '8a03aea1a46e94a05af6410337463102',
        'info_dict': {
            'id': '139200',
            'ext': 'mp4',
            'display_id': 'ConcernedLitigiousSalmonPeteZaroll-O8yo9W2L8OZEKhV2',
            'title': 'Streamer jumps off a trampoline at full speed',
            'creator': 'paradeev1ch',
            'thumbnail': r're:^https?://.+',
            'timestamp': 1656271785,
            'upload_date': '20220626',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        api_response = self._download_json(f'https://api.livestreamfails.com/clip/{video_id}', video_id)

        return {
            'id': video_id,
            'display_id': api_response.get('sourceId'),
            'timestamp': unified_timestamp(api_response.get('createdAt')),
            'url': f'https://livestreamfails-video-prod.b-cdn.net/video/{api_response["videoId"]}',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/livestreamfails.py (Python)

Code before:
        'url': 'https://livestreamfails.com/clip/139200',
        'md5': '8a03aea1a46e94a05af6410337463102',
        'info_dict': {
            'id': '139200',
            'ext': 'mp4',
            'display_id': 'ConcernedLitigiousSalmonPeteZaroll-O8yo9W2L8OZEKhV2',
            'title': 'Streamer jumps off a trampoline at full speed',
            'creator': 'paradeev1ch',
            'thumbnail': r're:^https?://.+',
            'timestamp': 1656271785,
            'upload_date': '20220626',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        api_response = self._download_json(f'https://api.livestreamfails.com/clip/{video_id}', video_id)

        return {
            'id': video_id,
            'display_id': api_response.get('sourceId'),
            'timestamp': unified_timestamp(api_response.get('createdAt')),
            'url': f'https://livestreamfails-video-prod.b-cdn.net/video/{api_response["videoId"]}',
            'title': api_response.get('label'),
            'creator': traverse_obj(api_response, ('streamer', 'label')),
            'thumbnail': format_field(api_response.get('imageId'), None, "https://livestreamfails-image-prod.b-cdn.net/image/%s")
        }


Review comment (bug):
```suggestion
            'thumbnail': format_field(api_response, 'imageId', 'https://livestreamfails-image-prod.b-cdn.net/image/%s')
```

Code after:
        'url': 'https://livestreamfails.com/clip/139200',
        'md5': '8a03aea1a46e94a05af6410337463102',
        'info_dict': {
            'id': '139200',
            'ext': 'mp4',
            'display_id': 'ConcernedLitigiousSalmonPeteZaroll-O8yo9W2L8OZEKhV2',
            'title': 'Streamer jumps off a trampoline at full speed',
            'creator': 'paradeev1ch',
            'thumbnail': r're:^https?://.+',
            'timestamp': 1656271785,
            'upload_date': '20220626',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        api_response = self._download_json(f'https://api.livestreamfails.com/clip/{video_id}', video_id)

        return {
            'id': video_id,
            'display_id': api_response.get('sourceId'),
            'timestamp': unified_timestamp(api_response.get('createdAt')),
            'url': f'https://livestreamfails-video-prod.b-cdn.net/video/{api_response["videoId"]}',
            'title': api_response.get('label'),
            'creator': traverse_obj(api_response, ('streamer', 'label')),
            'thumbnail': format_field(api_response, 'imageId', 'https://livestreamfails-image-prod.b-cdn.net/image/%s')
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/acfun.py (Python)

Code before:

from .common import InfoExtractor
from ..utils import (
    bug_reports_message,
    ExtractorError,
    float_or_none,
    format_field,
    int_or_none,
    traverse_obj,
    parse_codecs,
    parse_qs,
)


class AcFunVideoBaseIE(InfoExtractor):
    def parse_format_and_subtitle(self, video_id, video_info):
        if 'ksPlayJson' not in video_info:
            raise ExtractorError(f'Unknown webpage json schema{bug_reports_message()}')
        playjson = self._parse_json(video_info['ksPlayJson'], video_id)

        formats, subtitles = [], {}
        for video in traverse_obj(playjson, ('adaptationSet', 0, 'representation')):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(video['url'], video_id, 'mp4', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
            for f in fmts:
                f.update({

Review comment (refactor):
```suggestion
from .common import InfoExtractor
```

Code after:
from .common import InfoExtractor
from ..utils import (
    float_or_none,
    format_field,
    int_or_none,
    traverse_obj,
    parse_codecs,
    parse_qs,
)


class AcFunVideoBaseIE(InfoExtractor):
    def _extract_metadata(self, video_id, video_info):
        playjson = self._parse_json(video_info['ksPlayJson'], video_id)

        formats, subtitles = [], {}
        for video in traverse_obj(playjson, ('adaptationSet', 0, 'representation')):
            fmts, subs = self._extract_m3u8_formats_and_subtitles(video['url'], video_id, 'mp4', fatal=False)
            formats.extend(fmts)
            self._merge_subtitles(subs, target=subtitles)
            for f in fmts:
                f.update({
                    'fps': float_or_none(video.get('frameRate')),
                    'width': int_or_none(video.get('width')),
                    'height': int_or_none(video.get('height')),
                    'tbr': float_or_none(video.get('avgBitrate')),
                    **parse_codecs(video.get('codecs', ''))
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/syvdk.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import try_get


class SYVDKIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?24syv\.dk/episode/(?P<id>[a-zA-Z0-9-]+)'

    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)["props"]["pageProps"]["episodeDetails"][0]

        return {
            'id': str(info_data['id']),
            'display_id': video_id,
            'title': try_get(info_data, lambda x: x['title']['rendered']),
            'description': try_get(info_data, lambda x: x['details']['post_title']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure']
        }


Review comment (suggestion):
```suggestion
        info_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['episodeDetails'][0]
```

Code after:
from .common import InfoExtractor
from ..utils import traverse_obj


class SYVDKIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?24syv\.dk/episode/(?P<id>[\w-]+)'

    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['episodeDetails'][0]

        return {
            'id': str(info_data['id']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure'],
            'display_id': video_id,
            'title': traverse_obj(info_data, ('title', 'rendered')),
            'description': traverse_obj(info_data, ('details', 'post_title')),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/syvdk.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import try_get


class SYVDKIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?24syv\.dk/episode/(?P<id>[a-zA-Z0-9-]+)'

    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)["props"]["pageProps"]["episodeDetails"][0]

        return {
            'id': str(info_data['id']),
            'display_id': video_id,
            'title': try_get(info_data, lambda x: x['title']['rendered']),
            'description': try_get(info_data, lambda x: x['details']['post_title']),
            'vcodec': 'none',
            'ext': 'mp3',

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?24syv\.dk/episode/(?P<id>[\w-]+)'
```

Code after:
from .common import InfoExtractor
from ..utils import traverse_obj


class SYVDKIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?24syv\.dk/episode/(?P<id>[\w-]+)'

    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['episodeDetails'][0]

        return {
            'id': str(info_data['id']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure'],
            'display_id': video_id,
            'title': traverse_obj(info_data, ('title', 'rendered')),
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/syvdk.py (Python)

Code before:
    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)["props"]["pageProps"]["episodeDetails"][0]

        return {
            'id': str(info_data['id']),
            'display_id': video_id,
            'title': try_get(info_data, lambda x: x['title']['rendered']),
            'description': try_get(info_data, lambda x: x['details']['post_title']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure']
        }


Review comment (suggestion):
```suggestion
        return {
            'id': str(info_data['id']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure'],
            'display_id': video_id,
            'title': traverse_obj(info_data, ('title', 'rendered')),
            'description': traverse_obj(info_data, ('details', 'post_title')),
        }
```

Code after:
    _TESTS = [{
        'url': 'https://24syv.dk/episode/isabella-arendt-stiller-op-for-de-konservative-2',
        'md5': '429ce5a423dd4b1e1d0bf3a569558089',
        'info_dict': {
            'id': '12215',
            'display_id': 'isabella-arendt-stiller-op-for-de-konservative-2',
            'ext': 'mp3',
            'title': 'Isabella Arendt stiller op for De Konservative',
            'description': 'md5:f5fa6a431813bf37284f3412ad7c6c06'
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        info_data = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['episodeDetails'][0]

        return {
            'id': str(info_data['id']),
            'vcodec': 'none',
            'ext': 'mp3',
            'url': info_data['details']['enclosure'],
            'display_id': video_id,
            'title': traverse_obj(info_data, ('title', 'rendered')),
            'description': traverse_obj(info_data, ('details', 'post_title')),
        }