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

Code before:
from .common import InfoExtractor

class TheHighWireIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?thehighwire\.com/ark-videos/(?P<id>[^/?#]+)'
    _EMBED_URL = 'https://app.arkengine.com/embed/{id}'
    _TESTS = [{
        'url': 'https://thehighwire.com/ark-videos/the-deposition-of-stanley-plotkin/',
        'info_dict': {
            'id': 'clllgcra301z4ik01x8cwhfu2',
            'title': 'THE DEPOSITION OF STANLEY PLOTKIN',
            'ext': 'mp4',
        },
        'params': {'skip_download': True},
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)

        iframe_url = self._search_regex(
            r'<iframe[^>]+src=["\'](https?://app\.arkengine\.com/embed/[^"\']+)',
            webpage, 'iframe URL')
        video_id = self._search_regex(
            r'embed/([a-zA-Z0-9]+)', iframe_url, 'video ID')

        player_page = self._download_webpage(

Review comment (refactor):
```suggestion
from .common import InfoExtractor
from ..utils import (
    clean_html,
    extract_attributes,
    url_or_none,
)
from ..utils.traversal import (
    find_element,
    require,
    traverse_obj,
)

```

Code after:
from .common import InfoExtractor
from ..utils import (
    clean_html,
    extract_attributes,
    url_or_none,
)
from ..utils.traversal import (
    find_element,
    require,
    traverse_obj,
)


class TheHighWireIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?thehighwire\.com/ark-videos/(?P<id>[^/?#]+)'
    _TESTS = [{
        'url': 'https://thehighwire.com/ark-videos/the-deposition-of-stanley-plotkin/',
        'info_dict': {
            'id': 'the-deposition-of-stanley-plotkin',
            'ext': 'mp4',
            'title': 'THE DEPOSITION OF STANLEY PLOTKIN',
            'description': 'md5:6d0be4f1181daaa10430fd8b945a5e54',
            'thumbnail': r're:https?://static\.arkengine\.com/video/.+\.jpg',
        },
    }]
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/thehighwire.py (Python)

Code before:
            'id': 'the-deposition-of-stanley-plotkin',
            'ext': 'mp4',
            'title': 'THE DEPOSITION OF STANLEY PLOTKIN',
            'description': 'md5:6d0be4f1181daaa10430fd8b945a5e54',
            'thumbnail': r're:https?://static\.arkengine\.com/video/.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)

        embed_url = traverse_obj(webpage, (
            {find_element(cls='ark-video-embed', html=True)},
            {extract_attributes}, 'src', {url_or_none}, {require('embed URL')}))
        embed_page = self._download_webpage(embed_url, display_id)

        return {
            'id': display_id,
            **traverse_obj(webpage, {
                'title': ({find_element(cls='section-header')}, {clean_html}),
                'description': ({find_element(cls='episode-description__copy')}, {clean_html}),
            }),
            **self._parse_html5_media_entries(embed_url, embed_page, display_id, m3u8_id='hls')[0],
        }



Review comment (suggestion):
sorry, an extra blank line slipped in
```suggestion

```

Code after:
            'id': 'the-deposition-of-stanley-plotkin',
            'ext': 'mp4',
            'title': 'THE DEPOSITION OF STANLEY PLOTKIN',
            'description': 'md5:6d0be4f1181daaa10430fd8b945a5e54',
            'thumbnail': r're:https?://static\.arkengine\.com/video/.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)

        embed_url = traverse_obj(webpage, (
            {find_element(cls='ark-video-embed', html=True)},
            {extract_attributes}, 'src', {url_or_none}, {require('embed URL')}))
        embed_page = self._download_webpage(embed_url, display_id)

        return {
            'id': display_id,
            **traverse_obj(webpage, {
                'title': ({find_element(cls='section-header')}, {clean_html}),
                'description': ({find_element(cls='episode-description__copy')}, {clean_html}),
            }),
            **self._parse_html5_media_entries(embed_url, embed_page, display_id, m3u8_id='hls')[0],
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/unitednations.py (Python)

Code before:
from .common import InfoExtractor
from .kaltura import KalturaIE


class UnitedNationsWebTvIE(InfoExtractor):
    _VALID_URL = r'https?://webtv.un.org/(ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p',
        'md5': 'b2f8b3030063298ae841b4b7ddc01477',
        'info_dict': {
            'id': '1_o7stmi6p',
            'ext': 'mp4',
            'title': 'António Guterres (Secretary-General) on Israel and Iran - Security Council, 9939th meeting',
            'thumbnail': 'http://cfvod.kaltura.com/p/2503451/sp/250345100/thumbnail/entry_id/1_o7stmi6p/version/100021',
            'uploader_id': 'evgeniia.alisova@un.org',
            'upload_date': '20250620',
            'timestamp': 1750430976,
            'duration': 234,
            'view_count': int,
        },
    }]

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

        partner_id = self._html_search_regex(
            r'partnerId:\s*(\d+)', webpage, 'partner_id')
        entry_id = self._html_search_regex(
            r'const\s+kentryID\s*=\s*["\'](\w+)["\']', webpage, 'kentry_id')


Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://webtv.un.org/(?:ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
```

Code after:
from .common import InfoExtractor
from .kaltura import KalturaIE


class UnitedNationsWebTvIE(InfoExtractor):
    _VALID_URL = r'https?://webtv\.un\.org/(?:ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p',
        'md5': 'b2f8b3030063298ae841b4b7ddc01477',
        'info_dict': {
            'id': '1_o7stmi6p',
            'ext': 'mp4',
            'title': 'António Guterres (Secretary-General) on Israel and Iran - Security Council, 9939th meeting',
            'thumbnail': 'http://cfvod.kaltura.com/p/2503451/sp/250345100/thumbnail/entry_id/1_o7stmi6p/version/100021',
            'uploader_id': 'evgeniia.alisova@un.org',
            'upload_date': '20250620',
            'timestamp': 1750430976,
            'duration': 234,
            'view_count': int,
        },
    }]

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

        partner_id = self._html_search_regex(
            r'partnerId:\s*(\d+)', webpage, 'partner_id')
        entry_id = self._html_search_regex(
            r'const\s+kentryID\s*=\s*["\'](\w+)["\']', webpage, 'kentry_id')
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/unitednations.py (Python)

Code before:
from .common import InfoExtractor
from .kaltura import KalturaIE


class UnitedNationsWebTvIE(InfoExtractor):
    _VALID_URL = r'https?://webtv.un.org/(?:ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p',
        'md5': 'b2f8b3030063298ae841b4b7ddc01477',
        'info_dict': {
            'id': '1_o7stmi6p',
            'ext': 'mp4',
            'title': 'António Guterres (Secretary-General) on Israel and Iran - Security Council, 9939th meeting',
            'thumbnail': 'http://cfvod.kaltura.com/p/2503451/sp/250345100/thumbnail/entry_id/1_o7stmi6p/version/100021',
            'uploader_id': 'evgeniia.alisova@un.org',
            'upload_date': '20250620',
            'timestamp': 1750430976,
            'duration': 234,
            'view_count': int,
        },
    }]

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

        partner_id = self._html_search_regex(
            r'partnerId:\s*(\d+)', webpage, 'partner_id')
        entry_id = self._html_search_regex(
            r'const\s+kentryID\s*=\s*["\'](\w+)["\']', webpage, 'kentry_id')


Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://webtv\.un\.org/(?:ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
```

Code after:
from .common import InfoExtractor
from .kaltura import KalturaIE


class UnitedNationsWebTvIE(InfoExtractor):
    _VALID_URL = r'https?://webtv\.un\.org/(?:ar|zh|en|fr|ru|es)/asset/\w+/(?P<id>\w+)'
    _TESTS = [{
        'url': 'https://webtv.un.org/en/asset/k1o/k1o7stmi6p',
        'md5': 'b2f8b3030063298ae841b4b7ddc01477',
        'info_dict': {
            'id': '1_o7stmi6p',
            'ext': 'mp4',
            'title': 'António Guterres (Secretary-General) on Israel and Iran - Security Council, 9939th meeting',
            'thumbnail': 'http://cfvod.kaltura.com/p/2503451/sp/250345100/thumbnail/entry_id/1_o7stmi6p/version/100021',
            'uploader_id': 'evgeniia.alisova@un.org',
            'upload_date': '20250620',
            'timestamp': 1750430976,
            'duration': 234,
            'view_count': int,
        },
    }]

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

        partner_id = self._html_search_regex(
            r'partnerId:\s*(\d+)', webpage, 'partner_id')
        entry_id = self._html_search_regex(
            r'const\s+kentryID\s*=\s*["\'](\w+)["\']', webpage, 'kentry_id')
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/btvplus.py (Python)

Code before:
from .common import InfoExtractor


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/predavaniya/(?P<id>\d+)/.*'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/60119/sezon-1/ostrovat-na-100-te-grivni-sezon-1-epizod-11-02-10-2024',
        'info_dict': {
            'id': '6011911111',
            'title': 'Островът на 100-те гривни Сезон 1, епизод 11',
            'formats': 'count:1',
        },
    }]

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

        product_url = self._search_regex(
            r"var videoUrl\s*=\s*['\"]([^'\"]+)['\"];",
            webpage, 'product player URL')

        product_url = 'https://btvplus.bg' + product_url

        player_data = self._download_json(product_url, video_id)

        m3u8_url = self._search_regex(
            r'(https?://[^"]+\.m3u8)',
            player_data['config'], 'M3U8 URL')


Review comment (suggestion):
Don't need the trailing part of the regex and might as well match the other sections
```suggestion
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/(?:predavaniya|seriali|novini)/(?P<id>\d+)'
```

Code after:
from .common import InfoExtractor
from ..utils import (
    bug_reports_message,
    clean_html,
    get_element_by_class,
    js_to_json,
    mimetype2ext,
    strip_or_none,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/(?:predavaniya|seriali|novini)/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/67271/btv-reporterite/btv-reporterite-12-07-2025-g',
        'info_dict': {
            'ext': 'mp4',
            'id': '67271',
            'title': 'bTV Репортерите - 12.07.2025 г.',
            'thumbnail': 'https://cdn.btv.bg/media/images/940x529/Jul2025/2113606319.jpg',
        },
    }, {
        'url': 'https://btvplus.bg/produkt/seriali/66942/sezon-2/plen-sezon-2-epizod-55',
        'info_dict': {
            'ext': 'mp4',
            'id': '66942',
            'title': 'Плен - сезон 2, епизод 55',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/btvplus.py (Python)

Code before:
from .common import InfoExtractor


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/predavaniya/(?P<id>\d+)/.*'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/60119/sezon-1/ostrovat-na-100-te-grivni-sezon-1-epizod-11-02-10-2024',
        'info_dict': {
            'id': '6011911111',
            'title': 'Островът на 100-те гривни Сезон 1, епизод 11',
            'formats': 'count:1',
        },
    }]

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

        product_url = self._search_regex(
            r"var videoUrl\s*=\s*['\"]([^'\"]+)['\"];",
            webpage, 'product player URL')

        product_url = 'https://btvplus.bg' + product_url

        player_data = self._download_json(product_url, video_id)


Review comment (bug):
```suggestion
from .common import InfoExtractor
from ..utils import (
    bug_reports_message,
    clean_html,
    get_element_by_class,
    js_to_json,
    strip_or_none,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj
```

Code after:
from .common import InfoExtractor
from ..utils import (
    bug_reports_message,
    clean_html,
    get_element_by_class,
    js_to_json,
    mimetype2ext,
    strip_or_none,
    url_or_none,
    urljoin,
)
from ..utils.traversal import traverse_obj


class BTVPlusIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?btvplus\.bg/produkt/(?:predavaniya|seriali|novini)/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://btvplus.bg/produkt/predavaniya/67271/btv-reporterite/btv-reporterite-12-07-2025-g',
        'info_dict': {
            'ext': 'mp4',
            'id': '67271',
            'title': 'bTV Репортерите - 12.07.2025 г.',
            'thumbnail': 'https://cdn.btv.bg/media/images/940x529/Jul2025/2113606319.jpg',
        },
    }, {
        'url': 'https://btvplus.bg/produkt/seriali/66942/sezon-2/plen-sezon-2-epizod-55',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/btvplus.py (Python)

Code before:

        player_config = self._download_json(
            urljoin('https://btvplus.bg', player_url), video_id)['config']

        videojs_data = self._search_json(
            r'videojs\(["\'][^"\']+["\'],', player_config, 'videojs data',
            video_id, transform_source=js_to_json)
        formats = []
        subtitles = {}
        for src in traverse_obj(videojs_data, ('sources', lambda _, v: url_or_none(v['src']))):
            ext = mimetype2ext(src.get('type'))
            if ext == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(
                    src['src'], video_id, 'mp4', m3u8_id='hls', fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                self.report_warning(f'Unknown format type {ext}{bug_reports_message()}')

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            'title': strip_or_none(
                self._og_search_title(webpage, default=None)
                or clean_html(get_element_by_class('product-title', webpage))),
            'thumbnail': self._og_search_thumbnail(webpage, default=None),
            'description': self._og_search_description(webpage, default=None),
        }


Review comment (suggestion):
`clean_html` already strips IIRC, but this doesn't really matter I guess
```suggestion
            'title': (
                strip_or_none(self._og_search_title(webpage, default=None))
                or clean_html(get_element_by_class('product-title', webpage))),
```

Code after:

        player_config = self._download_json(
            urljoin('https://btvplus.bg', player_url), video_id)['config']

        videojs_data = self._search_json(
            r'videojs\(["\'][^"\']+["\'],', player_config, 'videojs data',
            video_id, transform_source=js_to_json)
        formats = []
        subtitles = {}
        for src in traverse_obj(videojs_data, ('sources', lambda _, v: url_or_none(v['src']))):
            ext = mimetype2ext(src.get('type'))
            if ext == 'm3u8':
                fmts, subs = self._extract_m3u8_formats_and_subtitles(
                    src['src'], video_id, 'mp4', m3u8_id='hls', fatal=False)
                formats.extend(fmts)
                self._merge_subtitles(subs, target=subtitles)
            else:
                self.report_warning(f'Unknown format type {ext}{bug_reports_message()}')

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            'title': (
                strip_or_none(self._og_search_title(webpage, default=None))
                or clean_html(get_element_by_class('product-title', webpage))),
            'thumbnail': self._og_search_thumbnail(webpage, default=None),
            'description': self._og_search_description(webpage, default=None),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/kick.py (Python)

Code before:

from urllib import parse

from .common import InfoExtractor
from ..networking import HEADRequest
from ..utils import (
    UserNotLive,
    determine_ext,
    float_or_none,
    int_or_none,
    merge_dicts,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    unified_timestamp,
    url_or_none,
)


class KickBaseIE(InfoExtractor):
    def _real_initialize(self):
        self._request_webpage(
            HEADRequest('https://kick.com/'), None, 'Setting up session', fatal=False, impersonate=True)
        session_token = self._get_cookies('https://kick.com/').get('session_token')
        if not session_token:
            self.write_debug('kick.com did not set session_token cookie')
        KickBaseIE._API_HEADERS = {

Review comment (suggestion):
`from` imports go against the project's coding conventions
```suggestion
import urllib.parse
```

Code after:
import functools
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    UserNotLive,
    determine_ext,
    float_or_none,
    int_or_none,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    unified_timestamp,
    url_or_none,
)


class KickBaseIE(InfoExtractor):
    @functools.cached_property
    def _api_headers(self):
        token = traverse_obj(
            self._get_cookies('https://kick.com/'),
            ('session_token', 'value', {urllib.parse.unquote}))
        return {'Authorization': f'Bearer {token}'} if token else {}

    def _call_api(self, path, display_id, note='Downloading API JSON', headers={}, **kwargs):
        return self._download_json(
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/kick.py (Python)

Code before:

import functools
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    UserNotLive,
    determine_ext,
    float_or_none,
    int_or_none,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    unified_timestamp,
    url_or_none,
)


class KickBaseIE(InfoExtractor):
    @functools.cached_property
    def _api_headers(self):
        token = traverse_obj(
            self._get_cookies('https://kick.com/'),
            ('session_token', 'value', {urllib.parse.unquote}))
        return {'Authorization': f'Bearer {token}'} if token else {}

    def _call_api(self, path, display_id, note='Downloading API JSON', headers={}, **kwargs):
        return self._download_json(

Review comment (suggestion):
```suggestion
import functools
import urllib.parse
```

Code after:
import functools
import urllib.parse

from .common import InfoExtractor
from ..utils import (
    UserNotLive,
    determine_ext,
    float_or_none,
    int_or_none,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    unified_timestamp,
    url_or_none,
)


class KickBaseIE(InfoExtractor):
    @functools.cached_property
    def _api_headers(self):
        token = traverse_obj(
            self._get_cookies('https://kick.com/'),
            ('session_token', 'value', {urllib.parse.unquote}))
        return {'Authorization': f'Bearer {token}'} if token else {}

    def _call_api(self, path, display_id, note='Downloading API JSON', headers={}, **kwargs):
        return self._download_json(
            f'https://kick.com/api/{path}', display_id, note=note,
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/_extractors.py (Python)

Code before:
    MindsChannelIE,
    MindsGroupIE,
    MindsIE,
)
from .minoto import MinotoIE
from .mirrativ import (
    MirrativIE,
    MirrativUserIE,
)
from .mirrorcouk import MirrorCoUKIE
from .mit import (
    OCWMITIE,
    TechTVMITIE,
)
from .mitele import MiTeleIE
from .mixch import (
    MixchArchiveIE,
    MixchIE,
    MixchMovieIE,
)
from .mixcloud import (
    MixcloudIE,
    MixcloudPlaylistIE,
    MixcloudUserIE,
)
from .mixlr import MixlrIE
from .mlb import (
    MLBIE,
    MLBTVIE,
    MLBArticleIE,
    MLBVideoIE,
)
from .mlssoccer import MLSSoccerIE
from .mocha import MochaVideoIE
from .mojevideo import MojevideoIE
from .mojvideo import MojvideoIE
from .monstercat import MonstercatIE
from .motherless import (
    MotherlessGalleryIE,
    MotherlessGroupIE,
    MotherlessIE,
    MotherlessUploaderIE,
)
from .motorsport import MotorsportIE
from .moviepilot import MoviepilotIE
from .moview import MoviewPlayIE
from .moviezine import MoviezineIE
from .movingimage import MovingImageIE
from .msn import MSNIE
from .mtv import (
    MTVDEIE,

Review comment (suggestion):
```suggestion
from .mixlr import (
    MixlrIE,
    MixlrRecoringIE,
)
```

Code after:
    MindsChannelIE,
    MindsGroupIE,
    MindsIE,
)
from .minoto import MinotoIE
from .mirrativ import (
    MirrativIE,
    MirrativUserIE,
)
from .mirrorcouk import MirrorCoUKIE
from .mit import (
    OCWMITIE,
    TechTVMITIE,
)
from .mitele import MiTeleIE
from .mixch import (
    MixchArchiveIE,
    MixchIE,
    MixchMovieIE,
)
from .mixcloud import (
    MixcloudIE,
    MixcloudPlaylistIE,
    MixcloudUserIE,
)
from .mixlr import (
    MixlrIE,
    MixlrRecoringIE,
)
from .mlb import (
    MLBIE,
    MLBTVIE,
    MLBArticleIE,
    MLBVideoIE,
)
from .mlssoccer import MLSSoccerIE
from .mocha import MochaVideoIE
from .mojevideo import MojevideoIE
from .mojvideo import MojvideoIE
from .monstercat import MonstercatIE
from .motherless import (
    MotherlessGalleryIE,
    MotherlessGroupIE,
    MotherlessIE,
    MotherlessUploaderIE,
)
from .motorsport import MotorsportIE
from .moviepilot import MoviepilotIE
from .moview import MoviewPlayIE
from .moviezine import MoviezineIE
from .movingimage import MovingImageIE