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

Code before:
        'url': 'https://screenrec.com/share/DasLtbknYo',
        'info_dict': {
            'id': 'DasLtbknYo',
            'ext': 'mp4',
            'title': '02.05.2024_03.01.25_REC',
            'description': 'Recorded with ScreenRec',
            'thumbnail': r're:^https?://.*\.gif$',
        },
        'params': {
            'skip_download': True,
        },
    }]

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

        m3u8_url = self._search_regex(
            r'customUrl\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 URL', group='url')

        return {
            'id': video_id,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
            'formats': self._extract_m3u8_formats(url_or_none(m3u8_url), video_id, ext='mp4'),
        }


Review comment (refactor):
Imo. we don't need the `url_or_none`
```suggestion
            'formats': self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4'),
```

Code after:
        'info_dict': {
            'id': 'DasLtbknYo',
            'ext': 'mp4',
            'title': '02.05.2024_03.01.25_REC',
            'description': 'Recorded with ScreenRec',
            'thumbnail': r're:^https?://.*\.gif$',
        },
        'params': {
            'skip_download': True,
        },
    }]

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

        m3u8_url = self._search_regex(
            r'customUrl\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 URL', group='url')

        return {
            'id': video_id,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
            'formats': self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4'),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/screenrec.py (Python)

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


class ScreenRecIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?screenrec\.com/share/(?P<id>[A-Za-z0-9]{10})'
    _TESTS = [{
        'url': 'https://screenrec.com/share/DasLtbknYo',
        'info_dict': {
            'id': 'DasLtbknYo',
            'ext': 'mp4',
            'title': '02.05.2024_03.01.25_REC',
            'description': 'Recorded with ScreenRec',
            'thumbnail': r're:^https?://.*\.gif$',
        },
        'params': {
            'skip_download': True,
        },
    }]

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

        m3u8_url = self._search_regex(
            r'customUrl\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 URL', group='url')

        return {
            'id': video_id,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'description': self._og_search_description(webpage),

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?screenrec\.com/share/(?P<id>\w{10})'
```

Code after:
from .common import InfoExtractor


class ScreenRecIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?screenrec\.com/share/(?P<id>\w{10})'
    _TESTS = [{
        'url': 'https://screenrec.com/share/DasLtbknYo',
        'info_dict': {
            'id': 'DasLtbknYo',
            'ext': 'mp4',
            'title': '02.05.2024_03.01.25_REC',
            'description': 'Recorded with ScreenRec',
            'thumbnail': r're:^https?://.*\.gif$',
        },
        'params': {
            'skip_download': True,
        },
    }]

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

        m3u8_url = self._search_regex(
            r'customUrl\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'm3u8 URL', group='url')

        return {
            'id': video_id,
            'title': self._og_search_title(webpage, default=None) or self._html_extract_title(webpage),
            'description': self._og_search_description(webpage),
            'thumbnail': self._og_search_thumbnail(webpage),
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/onsen.py (Python)

Code before:

        display_id = enc_id(program)
        date_str = self._search_regex(
            rf'{program_id}0?(\d{{6}})', m3u8_url, 'date string', default=None)

        return {
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(m3u8_url, raw_id, headers=self._HEADERS),
            'http_headers': self._HEADERS,
            'section_start': int_or_none(query.get('t', 0)),
            'upload_date': strftime_or_none(f'20{date_str}') if date_str else None,
            'webpage_url': f'{self._BASE_URL}/program/{program_id}?c={display_id}',
            **traverse_obj(program, {
                'id': ('id', {str_or_none}),
                'title': ('title', {clean_html}),
                'media_type': ('media_type', {str}),
                'thumbnail': ('poster_image_url', {url_or_none}, {update_url(query=None)}),
            }),
            **traverse_obj(programs, {
                'cast': (('performers', (*p_keys, 'guests')), ..., 'name', {str}, filter, all, filter),
                'series_id': ('directory_name', {str}),
            }),
            **traverse_obj(programs, ('program_info', {
                'description': ('description', {clean_html}, filter),
                'series': ('title', {clean_html}),
                'tags': ('hashtag_list', ..., {str}, filter, all, filter),
            })),
        }


Review comment (suggestion):
same
```suggestion
                'tags': ('hashtag_list', ..., {str}, filter),
```

Code after:
                'This program is no longer available', expected=True)
        m3u8_url = traverse_obj(program, ('streaming_url', {url_or_none}))
        if not m3u8_url:
            self.raise_login_required(
                'This program is only available for premium supporters')

        display_id = self._get_encoded_id(program)
        date_str = self._search_regex(
            rf'{program_id}0?(\d{{6}})', m3u8_url, 'date string', default=None)

        return {
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(m3u8_url, raw_id, headers=self._HEADERS),
            'http_headers': self._HEADERS,
            'section_start': int_or_none(query.get('t', 0)),
            'upload_date': strftime_or_none(f'20{date_str}'),
            'webpage_url': f'{self._BASE_URL}/program/{program_id}?c={display_id}',
            **traverse_obj(program, {
                'id': ('id', {int}, {str_or_none}),
                'title': ('title', {clean_html}),
                'media_type': ('media_type', {str}),
                'thumbnail': ('poster_image_url', {url_or_none}, {update_url(query=None)}),
            }),
            **traverse_obj(programs, {
                'cast': (('performers', (*p_keys, 'guests')), ..., 'name', {str}, filter),
                'series_id': ('directory_name', {str}),
            }),
            **traverse_obj(programs, ('program_info', {
                'description': ('description', {clean_html}, filter),
                'series': ('title', {clean_html}),
                'tags': ('hashtag_list', ..., {str}, filter),
            })),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/snapchat.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, url_or_none
from ..utils.traversal import traverse_obj


class SnapchatSpotlightIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>[\w]+)'

    _TESTS = [{
        'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
        'md5': '46c580f63592d0cbb76e974d2f9f0fcc',
        'info_dict': {
            'id': 'W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
            'ext': 'mp4',
            'title': 'Views 💕',
            'description': '',
            'thumbnail': r're:https://cf-st\.sc-cdn\.net/d/kKJHIR1QAznRKK9jgYYDq\.256\.IRZXSOY',
            'duration': 4.665,
            'timestamp': 1637777831.369,
            'upload_date': '20211124',
            'repost_count': int,
            'uploader': 'shreypatel57',
            'uploader_url': 'https://www.snapchat.com/add/shreypatel57',
        },
    }, {
        'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
        'md5': '4cd9626458c1a0e3e6dbe72c544a9ec2',
        'info_dict': {
            'id': 'W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
            'ext': 'mp4',
            'title': 'Spotlight Snap',
            'description': 'How he flirt her teacher🤭🤭🤩😍 #kdrama#cdrama #dramaclips #dramaspotlight',

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>\w+)'
```

Code after:
from .common import InfoExtractor
from ..utils import float_or_none, int_or_none, url_or_none
from ..utils.traversal import traverse_obj


class SnapchatSpotlightIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?snapchat\.com/spotlight/(?P<id>\w+)'

    _TESTS = [{
        'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
        'md5': '46c580f63592d0cbb76e974d2f9f0fcc',
        'info_dict': {
            'id': 'W7_EDlXWTBiXAEEniNoMPwAAYYWtidGhudGZpAX1TKn0JAX1TKnXJAAAAAA',
            'ext': 'mp4',
            'title': 'Views 💕',
            'description': '',
            'thumbnail': r're:https://cf-st\.sc-cdn\.net/d/kKJHIR1QAznRKK9jgYYDq\.256\.IRZXSOY',
            'duration': 4.665,
            'timestamp': 1637777831.369,
            'upload_date': '20211124',
            'repost_count': int,
            'uploader': 'shreypatel57',
            'uploader_url': 'https://www.snapchat.com/add/shreypatel57',
        },
    }, {
        'url': 'https://www.snapchat.com/spotlight/W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
        'md5': '4cd9626458c1a0e3e6dbe72c544a9ec2',
        'info_dict': {
            'id': 'W7_EDlXWTBiXAEEniNoMPwAAYcnVjYWdwcGV1AZEaIYn5AZEaIYnrAAAAAQ',
            'ext': 'mp4',
            'title': 'Spotlight Snap',
            'description': 'How he flirt her teacher🤭🤭🤩😍 #kdrama#cdrama #dramaclips #dramaspotlight',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bluesky.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none


class BlueskyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
    _TESTS = [{
        'url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',
        'md5': '375539c1930ab05d15585ed772ab54fd',
        'info_dict': {
            'id': '3l4omssdl632g',
            'ext': 'mp4',
            'title': str,
            'upload_date': '20240921',
            'description': 'OMG WE HAVE VIDEOS NOW',
            'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
            'uploader': str,
            'channel': 'blu3blue.bsky.social',
            'uploader_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'channel_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social',
            'channel_url': 'https://bsky.app/profile/did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'timestamp': 1726940605,
            'like_count': int,
            'repost_count': int,
            'comment_count': int,
            'webpage_url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',
            'tags': 'count:1',
            'comments': 'mincount:29',
            'age_limit': 0,
        },

Review comment (suggestion):
Imo. Let's also support `at://` urls
```suggestion
    _VALID_URL = [
        r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>\w+)',
        r'at://(?P<handle>[^/]+)/app.bsky.feed.post/(?P<id>\w+)',
    ]
```

Code after:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    format_field,
    int_or_none,
    mimetype2ext,
    orderedSet,
    parse_iso8601,
    truncate_string,
    update_url_query,
    url_basename,
    url_or_none,
    variadic,
)
from ..utils.traversal import traverse_obj


class BlueskyIE(InfoExtractor):
    _VALID_URL = [
        r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[\w.:%-]+)/post/(?P<id>\w+)',
        r'at://(?P<handle>[\w.:%-]+)/app\.bsky\.feed\.post/(?P<id>\w+)',
    ]
    _TESTS = [{
        'url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',
        'md5': '375539c1930ab05d15585ed772ab54fd',
        'info_dict': {
            'id': '3l4omssdl632g',
            'ext': 'mp4',
            'uploader': 'Blu3Blu3Lilith',
            'uploader_id': 'blu3blue.bsky.social',
            'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/bluesky.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import int_or_none, mimetype2ext, parse_iso8601, traverse_obj, url_or_none


class BlueskyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[^/]+)/post/(?P<id>[0-9a-zA-Z]+)'
    _TESTS = [{
        'url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',
        'md5': '375539c1930ab05d15585ed772ab54fd',
        'info_dict': {
            'id': '3l4omssdl632g',
            'ext': 'mp4',
            'title': str,
            'upload_date': '20240921',
            'description': 'OMG WE HAVE VIDEOS NOW',
            'thumbnail': r're:https://video.bsky.app/watch/.*\.jpg$',
            'uploader': str,
            'channel': 'blu3blue.bsky.social',
            'uploader_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'channel_id': 'did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'uploader_url': 'https://bsky.app/profile/blu3blue.bsky.social',
            'channel_url': 'https://bsky.app/profile/did:plc:pzdr5ylumf7vmvwasrpr5bf2',
            'timestamp': 1726940605,
            'like_count': int,
            'repost_count': int,
            'comment_count': int,
            'webpage_url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',

Review comment (suggestion):
For my suggestions to work:
```suggestion
from ..utils import (
    format_field,
    int_or_none,
    mimetype2ext,
    parse_iso8601,
    truncate_string,
    update_url_query,
    url_or_none,
    variadic,
)
from ..utils.traversal import traverse_obj
```

Code after:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    format_field,
    int_or_none,
    mimetype2ext,
    orderedSet,
    parse_iso8601,
    truncate_string,
    update_url_query,
    url_basename,
    url_or_none,
    variadic,
)
from ..utils.traversal import traverse_obj


class BlueskyIE(InfoExtractor):
    _VALID_URL = [
        r'https?://(?:www\.)?(?:bsky\.app|main\.bsky\.dev)/profile/(?P<handle>[\w.:%-]+)/post/(?P<id>\w+)',
        r'at://(?P<handle>[\w.:%-]+)/app\.bsky\.feed\.post/(?P<id>\w+)',
    ]
    _TESTS = [{
        'url': 'https://bsky.app/profile/blu3blue.bsky.social/post/3l4omssdl632g',
        'md5': '375539c1930ab05d15585ed772ab54fd',
        'info_dict': {
            'id': '3l4omssdl632g',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/litv.py (Python)

Code before:
import json
import uuid

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    int_or_none,
    smuggle_url,
    traverse_obj,
    try_call,
    unsmuggle_url,
)


class LiTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/]+/watch/|vod/[^/]+/content\.do\?content_id=)(?P<id>[a-z\-A-Z0-9]+)'

    _URL_TEMPLATE = 'https://www.litv.tv/%s/watch/%s'

    _GEO_COUNTRIES = ['TW']

    _TESTS = [{
        'url': 'https://www.litv.tv/drama/watch/VOD00041610',
        'info_dict': {
            'id': 'VOD00041606',
            'title': '花千骨',
        },
        'playlist_count': 51,  # 50 episodes + 1 trailer
    }, {
        'url': 'https://www.litv.tv/drama/watch/VOD00041610',
        'md5': 'b90ff1e9f1d8f5cfcd0a44c3e2b34c7a',
        'info_dict': {
            'id': 'VOD00041610',
            'ext': 'mp4',
            'title': '花千骨第1集',
            'thumbnail': r're:https?://.*\.jpg$',
            'description': '《花千骨》陸劇線上看。十六年前，平靜的村莊內，一名女嬰隨異相出生，途徑此地的蜀山掌門清虛道長算出此女命運非同一般，她體內散發的異香易招惹妖魔。一念慈悲下，他在村莊周邊設下結界阻擋妖魔入侵，讓其年滿十六後去蜀山，並賜名花千骨。',
            'categories': ['奇幻', '愛情', '仙俠', '古裝'],
            'episode': 'Episode 1',
            'episode_number': 1,
        },

Review comment (suggestion):
do `/promo` URLs no longer exist?

```suggestion
    _VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/[^/?#]+/content\.do\?content_id=)(?P<id>[\w-]+)'
```

Code after:
import json
import uuid

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    int_or_none,
    join_nonempty,
    smuggle_url,
    traverse_obj,
    try_call,
    unsmuggle_url,
    urljoin,
)


class LiTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?litv\.tv/(?:[^/?#]+/watch/|vod/[^/?#]+/content\.do\?content_id=)(?P<id>[\w-]+)'
    _URL_TEMPLATE = 'https://www.litv.tv/%s/watch/%s'
    _GEO_COUNTRIES = ['TW']
    _TESTS = [{
        'url': 'https://www.litv.tv/drama/watch/VOD00041610',
        'info_dict': {
            'id': 'VOD00041606',
            'title': '花千骨',
        },
        'playlist_count': 51,  # 50 episodes + 1 trailer
    }, {
        'url': 'https://www.litv.tv/drama/watch/VOD00041610',
        'md5': 'b90ff1e9f1d8f5cfcd0a44c3e2b34c7a',
        'info_dict': {
            'id': 'VOD00041610',
            'ext': 'mp4',
            'title': '花千骨第1集',
            'thumbnail': r're:https?://.*\.jpg$',
            'description': '《花千骨》陸劇線上看。十六年前，平靜的村莊內，一名女嬰隨異相出生，途徑此地的蜀山掌門清虛道長算出此女命運非同一般，她體內散發的異香易招惹妖魔。一念慈悲下，他在村莊周邊設下結界阻擋妖魔入侵，讓其年滿十六後去蜀山，並賜名花千骨。',
            'categories': ['奇幻', '愛情', '仙俠', '古裝'],
            'episode': 'Episode 1',
            'episode_number': 1,
        },
        'params': {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/telecinco.py (Python)

Code before:
import json
import re

from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    str_or_none,
    traverse_obj,
)


class TelecincoIE(InfoExtractor):
    IE_DESC = 'telecinco.es, cuatro.com and mediaset.es'
    _VALID_URL = r'https?://(?:www\.)?(?:telecinco\.es|cuatro\.com|mediaset\.es)/(?:[^/]+/)+(?P<id>.+?)\.html'

    _TESTS = [{
        'url': 'http://www.telecinco.es/robinfood/temporada-01/t01xp14/Bacalao-cocochas-pil-pil_0_1876350223.html',
        'info_dict': {
            'id': '1876350223',
            'title': 'Bacalao con kokotxas al pil-pil',
            'description': 'md5:716caf5601e25c3c5ab6605b1ae71529',
        },
        'playlist': [{
            'md5': '7ee56d665cfd241c0e6d80fd175068b0',
            'info_dict': {
                'id': 'JEA5ijCnF6p5W08A1rNKn7',
                'ext': 'mp4',
                'title': 'Con Martín Berasategui, hacer un bacalao al pil-pil es fácil y divertido',
                'duration': 662,
            },
        }],
    }, {
        'url': 'http://www.cuatro.com/deportes/futbol/barcelona/Leo_Messi-Champions-Roma_2_2052780128.html',
        'md5': 'c86fe0d99e3bdb46b7950d38bf6ef12a',
        'info_dict': {
            'id': 'jn24Od1zGLG4XUZcnUnZB6',

Review comment (suggestion):
needed for other suggestions
```suggestion
    traverse_obj,
    update_url,
    url_or_none,
```

Code after:
import json
import re

from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
    ExtractorError,
    clean_html,
    int_or_none,
    join_nonempty,
    str_or_none,
    traverse_obj,
    update_url,
    url_or_none,
)


class TelecincoBaseIE(InfoExtractor):
    def _parse_content(self, content, url):
        video_id = content['dataMediaId']
        config = self._download_json(
            content['dataConfig'], video_id, 'Downloading config JSON')
        services = config['services']
        caronte = self._download_json(services['caronte'], video_id)
        if traverse_obj(caronte, ('dls', 0, 'drm', {bool})):
            self.report_drm(video_id)

        stream = caronte['dls'][0]['stream']
        headers = {
            'Referer': url,
            'Origin': re.match(r'https?://[^/]+', url).group(0),
        }
        geo_headers = {**headers, **self.geo_verification_headers()}

        try:
            cdn = self._download_json(
                caronte['cerbero'], video_id, data=json.dumps({