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

Code before:
            'like_count': int,
            'categories': ['EVE Online'],
            'live_status': 'is_live',
        },
        'skip': 'livestream',
        'params': {'skip_download': True},
    }]

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

        stream_info = self._download_json(
            f'https://api.vkplay.live/v1/blog/{username}/public_video_stream', username, fatal=False)
        if not stream_info:
            stream_info = self._extract_from_initial_state(url, username, ('stream', 'stream', 'data', 'stream'))

        formats = self._extract_formats(stream_info, username)
        if not formats and not traverse_obj(stream_info, ('isOnline', {bool})):
            raise UserNotLive(video_id=username)

        return {
            'formats': formats,
            **self._extract_common_meta(stream_info),
            **traverse_obj(stream_info, {
                'is_live': ('isOnline', {bool}),
            })
        }


Review comment (refactor):
```suggestion
            **self._extract_common_meta(stream_info),
            'formats': formats,
```

Code after:
            'view_count': int,
            'concurrent_view_count': int,
            'like_count': int,
            'categories': ['EVE Online'],
            'live_status': 'is_live',
        },
        'skip': 'livestream',
        'params': {'skip_download': True},
    }]

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

        stream_info = self._download_json(
            f'https://api.vkplay.live/v1/blog/{username}/public_video_stream', username, fatal=False)
        if not stream_info:
            stream_info = self._extract_from_initial_state(url, username, ('stream', 'stream', 'data', 'stream'))

        formats = self._extract_formats(stream_info, username)
        if not formats and not traverse_obj(stream_info, ('isOnline', {bool})):
            raise UserNotLive(video_id=username)

        return {
            **self._extract_common_meta(stream_info),
            'formats': formats,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/pornbox.py (Python)

Code before:
from .common import InfoExtractor
from ..compat import functools
from ..utils import (
    parse_duration,
    traverse_obj,
    str_or_none,
    int_or_none,
    strip_or_none,
    parse_iso8601,
    qualities
)


class PornboxIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?pornbox\.com/application/watch-page/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://pornbox.com/application/watch-page/426095',
        'md5': '0cc35f4d4300bc8e0496aef2a9ec20b9',
        'info_dict': {
            'id': '426095',
            'ext': 'mp4',
            'title': 'md5:96b05922d74be2be939cf247294f26bd',
            'uploader': 'Giorgio Grandi',
            'timestamp': 1686088800,
            'upload_date': '20230606',
            'age_limit': 18,
            'availability': 'needs_auth',
            'duration': 1767,
            'cast': ['Tina Kay', 'Neeo', 'Mr. Anderson', 'Thomas Lee', 'Brian Ragnastone', 'Rycky Optimal'],
            'tags': 'count:37',
            'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$'
        }
    }, {
        'url': 'https://pornbox.com/application/watch-page/216045',
        'info_dict': {

Review comment (suggestion):
```suggestion
    parse_iso8601,
    qualities,
    url_or_none,
```

Code after:
from .common import InfoExtractor
from ..compat import functools
from ..utils import (
    int_or_none,
    parse_duration,
    parse_iso8601,
    qualities,
    str_or_none,
    traverse_obj,
    url_or_none,
)


class PornboxIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?pornbox\.com/application/watch-page/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://pornbox.com/application/watch-page/212108',
        'md5': '3ff6b6e206f263be4c5e987a3162ac6e',
        'info_dict': {
            'id': '212108',
            'ext': 'mp4',
            'title': 'md5:ececc5c6e6c9dd35d290c45fed05fd49',
            'uploader': 'Lily Strong',
            'timestamp': 1665871200,
            'upload_date': '20221015',
            'age_limit': 18,
            'availability': 'needs_auth',
            'duration': 1505,
            'cast': ['Lily Strong', 'John Strong'],
            'tags': 'count:11',
            'description': 'md5:589c7f33e183aa8aa939537300efb859',
            'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$'
        }
    }, {
        'url': 'https://pornbox.com/application/watch-page/216045',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/pornbox.py (Python)

Code before:
from .common import InfoExtractor
from ..compat import functools
from ..utils import (
    parse_duration,
    traverse_obj,
    str_or_none,
    int_or_none,
    parse_iso8601,
    qualities,
    url_or_none,
)


class PornboxIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?pornbox\.com/application/watch-page/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://pornbox.com/application/watch-page/426095',
        'md5': '0cc35f4d4300bc8e0496aef2a9ec20b9',
        'info_dict': {
            'id': '426095',
            'ext': 'mp4',
            'title': 'md5:96b05922d74be2be939cf247294f26bd',
            'uploader': 'Giorgio Grandi',
            'timestamp': 1686088800,
            'upload_date': '20230606',
            'age_limit': 18,
            'availability': 'needs_auth',
            'duration': 1767,
            'cast': ['Tina Kay', 'Neeo', 'Mr. Anderson', 'Thomas Lee', 'Brian Ragnastone', 'Rycky Optimal'],
            'tags': 'count:37',
            'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$'
        }
    }, {
        'url': 'https://pornbox.com/application/watch-page/216045',
        'info_dict': {

Review comment (suggestion):
```suggestion
    int_or_none,
    parse_duration,
    parse_iso8601,
    qualities,
    str_or_none,
    traverse_obj,
    url_or_none,
```

Code after:
from .common import InfoExtractor
from ..compat import functools
from ..utils import (
    int_or_none,
    parse_duration,
    parse_iso8601,
    qualities,
    str_or_none,
    traverse_obj,
    url_or_none,
)


class PornboxIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?pornbox\.com/application/watch-page/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://pornbox.com/application/watch-page/212108',
        'md5': '3ff6b6e206f263be4c5e987a3162ac6e',
        'info_dict': {
            'id': '212108',
            'ext': 'mp4',
            'title': 'md5:ececc5c6e6c9dd35d290c45fed05fd49',
            'uploader': 'Lily Strong',
            'timestamp': 1665871200,
            'upload_date': '20221015',
            'age_limit': 18,
            'availability': 'needs_auth',
            'duration': 1505,
            'cast': ['Lily Strong', 'John Strong'],
            'tags': 'count:11',
            'description': 'md5:589c7f33e183aa8aa939537300efb859',
            'thumbnail': r're:^https?://cdn-image\.gtflixtv\.com.*\.jpg.*$'
        }
    }, {
        'url': 'https://pornbox.com/application/watch-page/216045',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/theplatform.py (Python)

Code before:
import re
import time
import hmac
import binascii
import hashlib


from .once import OnceIE
from .adobepass import AdobePassIE
from ..networking import Request
from ..utils import (
    determine_ext,
    ExtractorError,
    float_or_none,
    int_or_none,
    parse_qs,
    unsmuggle_url,
    update_url_query,
    xpath_with_ns,
    mimetype2ext,
    find_xpath_attr,
    update_url,
    urlhandle_detect_ext,
)
from ..networking import HEADRequest

default_ns = 'http://www.w3.org/2005/SMIL21/Language'
_x = lambda p: xpath_with_ns(p, {'smil': default_ns})


class ThePlatformBaseIE(OnceIE):
    _TP_TLD = 'com'

    def _extract_theplatform_smil(self, smil_url, video_id, note='Downloading SMIL data'):
        meta = self._download_xml(
            smil_url, video_id, note=note, query={'format': 'SMIL'},
            headers=self.geo_verification_headers())
        error_element = find_xpath_attr(meta, _x('.//smil:ref'), 'src')
        if error_element is not None:
            exception = find_xpath_attr(
                error_element, _x('.//smil:param'), 'name', 'exception')
            if exception is not None:
                if exception.get('value') == 'GeoLocationBlocked':
                    self.raise_geo_restricted(error_element.attrib['abstract'])
                elif error_element.attrib['src'].startswith(
                        'http://link.theplatform.%s/s/errorFiles/Unavailable.'
                        % self._TP_TLD):

Review comment (suggestion):
```suggestion
    find_xpath_attr,
    traverse_obj,
    update_url,
```

Code after:
import re
import time
import hmac
import binascii
import hashlib


from .once import OnceIE
from .adobepass import AdobePassIE
from ..networking import Request
from ..utils import (
    determine_ext,
    ExtractorError,
    float_or_none,
    int_or_none,
    parse_qs,
    unsmuggle_url,
    update_url_query,
    xpath_with_ns,
    mimetype2ext,
    find_xpath_attr,
    traverse_obj,
    update_url,
    urlhandle_detect_ext,
)
from ..networking import HEADRequest

default_ns = 'http://www.w3.org/2005/SMIL21/Language'
_x = lambda p: xpath_with_ns(p, {'smil': default_ns})


class ThePlatformBaseIE(OnceIE):
    _TP_TLD = 'com'

    def _extract_theplatform_smil(self, smil_url, video_id, note='Downloading SMIL data'):
        meta = self._download_xml(
            smil_url, video_id, note=note, query={'format': 'SMIL'},
            headers=self.geo_verification_headers())
        error_element = find_xpath_attr(meta, _x('.//smil:ref'), 'src')
        if error_element is not None:
            exception = find_xpath_attr(
                error_element, _x('.//smil:param'), 'name', 'exception')
            if exception is not None:
                if exception.get('value') == 'GeoLocationBlocked':
                    self.raise_geo_restricted(error_element.attrib['abstract'])
                elif error_element.attrib['src'].startswith(
                        'http://link.theplatform.%s/s/errorFiles/Unavailable.'
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/wimbledon.py (Python)

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


class WimbledonIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/en_GB/video/media/(?P<id>[0-9]+).html'
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'

    _TESTS = [{
        'url': 'https://www.wimbledon.com/en_GB/video/media/6330247525112.html',
        'info_dict': {
            'id': '6330247525112',
            'ext': 'mp4',
            'timestamp': 1687972186,
            'description': '',
            'thumbnail': 'https://cf-images.eu-west-1.prod.boltdns.net/v1/static/3506358525001/97312363-ba01-4158-8a45-1e51e518c0ff/806b5b8a-22dc-4618-aac9-f73bd6202715/1920x1080/match/image.jpg',
            'upload_date': '20230628',
            'title': 'Coco Gauff | My Wimbledon Inspiration',
            'tags': ['features', 'trending', 'homepage'],
            'uploader_id': '3506358525001',
            'duration': 163072.0,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_GB/video/media/6308703111112.html',
        'info_dict': {
            'id': '6308703111112',
            'ext': 'mp4',
            'thumbnail': 'https://cf-images.eu-west-1.prod.boltdns.net/v1/jit/3506358525001/3144a401-e6b3-4d49-9dfc-627866a2e2de/main/1920x1080/50s720ms/match/image.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',

Review comment (suggestion):
Allow other languages/locales; seems many other work in browser.
You could also add an `'only_matching': True` test for an `en_US` URL etc
```suggestion
    _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+)\.html'
```

Code after:
from .common import InfoExtractor
from ..utils import (
    parse_duration,
    traverse_obj,
)


class WimbledonIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+).html'
    _TESTS = [{
        'url': 'https://www.wimbledon.com/en_GB/video/media/6330247525112.html',
        'info_dict': {
            'id': '6330247525112',
            'ext': 'mp4',
            'timestamp': 1687972186,
            'description': '',
            'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
            'upload_date': '20230628',
            'title': 'Coco Gauff | My Wimbledon Inspiration',
            'tags': ['features', 'trending', 'homepage'],
            'uploader_id': '3506358525001',
            'duration': 163072.0,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_GB/video/media/6308703111112.html',
        'info_dict': {
            'id': '6308703111112',
            'ext': 'mp4',
            'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',
            'duration': 101440.0,
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/wimbledon.py (Python)

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


class WimbledonIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/en_GB/video/media/(?P<id>[0-9]+).html'
    BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/%s/default_default/index.html?videoId=%s'

    _TESTS = [{
        'url': 'https://www.wimbledon.com/en_GB/video/media/6330247525112.html',
        'info_dict': {
            'id': '6330247525112',
            'ext': 'mp4',
            'timestamp': 1687972186,
            'description': '',
            'thumbnail': 'https://cf-images.eu-west-1.prod.boltdns.net/v1/static/3506358525001/97312363-ba01-4158-8a45-1e51e518c0ff/806b5b8a-22dc-4618-aac9-f73bd6202715/1920x1080/match/image.jpg',
            'upload_date': '20230628',
            'title': 'Coco Gauff | My Wimbledon Inspiration',
            'tags': ['features', 'trending', 'homepage'],
            'uploader_id': '3506358525001',
            'duration': 163072.0,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_GB/video/media/6308703111112.html',
        'info_dict': {
            'id': '6308703111112',
            'ext': 'mp4',
            'thumbnail': 'https://cf-images.eu-west-1.prod.boltdns.net/v1/jit/3506358525001/3144a401-e6b3-4d49-9dfc-627866a2e2de/main/1920x1080/50s720ms/match/image.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',

Review comment (refactor):
since the extractor is fairly simple, it makes sense to just inline this
```suggestion
```

Code after:
from .common import InfoExtractor
from ..utils import (
    parse_duration,
    traverse_obj,
)


class WimbledonIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?wimbledon\.com/\w+/video/media/(?P<id>\d+).html'
    _TESTS = [{
        'url': 'https://www.wimbledon.com/en_GB/video/media/6330247525112.html',
        'info_dict': {
            'id': '6330247525112',
            'ext': 'mp4',
            'timestamp': 1687972186,
            'description': '',
            'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
            'upload_date': '20230628',
            'title': 'Coco Gauff | My Wimbledon Inspiration',
            'tags': ['features', 'trending', 'homepage'],
            'uploader_id': '3506358525001',
            'duration': 163072.0,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_GB/video/media/6308703111112.html',
        'info_dict': {
            'id': '6308703111112',
            'ext': 'mp4',
            'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',
            'duration': 101440.0,
            'tags': ['features', 'kids'],
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/wimbledon.py (Python)

Code before:
        'info_dict': {
            'id': '6308703111112',
            'ext': 'mp4',
            'thumbnail': 'https://cf-images.eu-west-1.prod.boltdns.net/v1/jit/3506358525001/3144a401-e6b3-4d49-9dfc-627866a2e2de/main/1920x1080/50s720ms/match/image.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',
            'duration': 101440.0,
            'tags': ['features', 'kids'],
            'timestamp': 1656500867,
        },
    }]

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

        metadata = self._download_json(
            f'https://www.wimbledon.com/relatedcontent/rest/v2/wim_v1/en/content/wim_v1_{video_id}_en',
            video_id,
        )

        return {
            '_type': 'url_transparent',
            'url': self.BRIGHTCOVE_URL_TEMPLATE % (account, video_id),
            'ie_key': 'BrightcoveNew',
            'id': video_id,
            'title': metadata.get('title'),
            'description': metadata.get('description'),
            'language': metadata.get('language'),
            'duration': parse_duration(traverse_obj(metadata, ('metadata', 'duration'))),
        }


Review comment (suggestion):
```suggestion
            'url': 'https://players.brightcove.net/3506358525001/default_default/index.html?videoId={video_id}',
```

Code after:
            'ext': 'mp4',
            'thumbnail': r're:^https://[\w.-]+\.prod\.boltdns\.net/[^?#]+/image\.jpg',
            'description': 'null',
            'upload_date': '20220629',
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',
            'duration': 101440.0,
            'tags': ['features', 'kids'],
            'timestamp': 1656500867,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_US/video/media/6309327106112.html',
        'only_matching': True,
    }, {
        'url': 'https://www.wimbledon.com/es_Es/video/media/6308377909112.html',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        metadata = self._download_json(
            f'https://www.wimbledon.com/relatedcontent/rest/v2/wim_v1/en/content/wim_v1_{video_id}_en', video_id)

        return {
            '_type': 'url_transparent',
            'url': f'http://players.brightcove.net/3506358525001/default_default/index.html?videoId={video_id}',
            'ie_key': 'BrightcoveNew',
            'id': video_id,
            **traverse_obj(metadata, {
                'title': 'title',
                'description': 'description',
                'duration': ('metadata', 'duration', {parse_duration}),
            }),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/wimbledon.py (Python)

Code before:
            'uploader_id': '3506358525001',
            'title': 'Roblox | WimbleWorld ',
            'duration': 101440.0,
            'tags': ['features', 'kids'],
            'timestamp': 1656500867,
        },
    }]

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

        metadata = self._download_json(
            f'https://www.wimbledon.com/relatedcontent/rest/v2/wim_v1/en/content/wim_v1_{video_id}_en',
            video_id,
        )

        return {
            '_type': 'url_transparent',
            'url': self.BRIGHTCOVE_URL_TEMPLATE % (account, video_id),
            'ie_key': 'BrightcoveNew',
            'id': video_id,
            'title': metadata.get('title'),
            'description': metadata.get('description'),
            'language': metadata.get('language'),
            'duration': parse_duration(traverse_obj(metadata, ('metadata', 'duration'))),
        }


Review comment (suggestion):
`language` is a format field, so we can leave it out
```suggestion
            **traverse_obj(metadata, {
                'title': 'title',
                'description': 'description',
                'duration': ('metadata', 'duration', {parse_duration}),
            }),
```

Code after:
            'duration': 101440.0,
            'tags': ['features', 'kids'],
            'timestamp': 1656500867,
        },
    }, {
        'url': 'https://www.wimbledon.com/en_US/video/media/6309327106112.html',
        'only_matching': True,
    }, {
        'url': 'https://www.wimbledon.com/es_Es/video/media/6308377909112.html',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        metadata = self._download_json(
            f'https://www.wimbledon.com/relatedcontent/rest/v2/wim_v1/en/content/wim_v1_{video_id}_en', video_id)

        return {
            '_type': 'url_transparent',
            'url': f'http://players.brightcove.net/3506358525001/default_default/index.html?videoId={video_id}',
            'ie_key': 'BrightcoveNew',
            'id': video_id,
            **traverse_obj(metadata, {
                'title': 'title',
                'description': 'description',
                'duration': ('metadata', 'duration', {parse_duration}),
            }),
        }