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

Code before:
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
    ExtractorError,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    UserNotLive,
    url_or_none,
)


class FlexTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?flextv\.co\.kr/channels/(?P<id>\d+)/live'
    _TESTS = [{
        'url': 'https://www.flextv.co.kr/channels/231638/live',
        'info_dict': {
            'id': '231638',
            'ext': 'mp4',
            'title': r're:^214하나만\.\.\. ',
            'thumbnail': r're:^https?://.+\.jpg',
            'upload_date': r're:\d{8}',
            'timestamp': int,
            'live_status': 'is_live',
            'channel': 'Hi별',
            'channel_id': '244396',
        },
        'skip': 'The channel is offline',
    }, {
        'url': 'https://www.flextv.co.kr/channels/746/live',
        'only_matching': True,
    }]


Review comment (refactor):
```suggestion
    ExtractorError,
    UserNotLive,
    parse_iso8601,
    str_or_none,
    traverse_obj,
```

Code after:
from .common import InfoExtractor
from ..networking.exceptions import HTTPError
from ..utils import (
    ExtractorError,
    UserNotLive,
    parse_iso8601,
    str_or_none,
    traverse_obj,
    url_or_none,
)


class FlexTVIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?flextv\.co\.kr/channels/(?P<id>\d+)/live'
    _TESTS = [{
        'url': 'https://www.flextv.co.kr/channels/231638/live',
        'info_dict': {
            'id': '231638',
            'ext': 'mp4',
            'title': r're:^214하나만\.\.\. ',
            'thumbnail': r're:^https?://.+\.jpg',
            'upload_date': r're:\d{8}',
            'timestamp': int,
            'live_status': 'is_live',
            'channel': 'Hi별',
            'channel_id': '244396',
        },
        'skip': 'The channel is offline',
    }, {
        'url': 'https://www.flextv.co.kr/channels/746/live',
        'only_matching': True,
    }]
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/onefootball.py (Python)

Code before:
    }, {
        'url': 'https://onefootball.com/en/video/klopp-fumes-at-var-decisions-in-west-ham-defeat-34041020',
        'info_dict': {
            'id': 'leVJrMho',
            'ext': 'mp4',
            'title': 'Klopp fumes at VAR decisions in West Ham defeat',
            'description': 'md5:9c50371095a01ad3f63311c73d8f51a5',
            'thumbnail': 'https://cdn.jwplayer.com/v2/media/leVJrMho/poster.jpg?width=720',
            'timestamp': 1636315232,
            'upload_date': '20211107',
            'duration': 93.0,
            'tags': ['Football', 'Soccer', 'OneFootball'],
            '_old_archive_ids': ['onefootball 34041020'],
        },
        'params': {'skip_download': True}
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        data_json = self._search_json_ld(webpage, video_id, fatal=False)
        m3u8_url = self._html_search_regex(r'(https://cdn\.jwplayer\.com/manifests/\w+\.m3u8)', webpage, 'm3u8_url')

        return self.url_result(
            m3u8_url, JWPlatformIE, video_id, _old_archive_ids=[make_archive_id(self, video_id)],
            **filter_dict(data_json, cndn=lambda k, _: k != 'url'), url_transparent=True)


Review comment (suggestion):
this is simpler IMO
```suggestion
        data_json = self._search_json_ld(webpage, video_id, fatal=False)
        data_json.pop('url', None)
        m3u8_url = self._html_search_regex(r'(https://cdn\.jwplayer\.com/manifests/\w+\.m3u8)', webpage, 'm3u8_url')

        return self.url_result(
            m3u8_url, JWPlatformIE, video_id, _old_archive_ids=[make_archive_id(self, video_id)],
            **data_json, url_transparent=True)
```

Code after:
    }, {
        'url': 'https://onefootball.com/en/video/klopp-fumes-at-var-decisions-in-west-ham-defeat-34041020',
        'info_dict': {
            'id': 'leVJrMho',
            'ext': 'mp4',
            'title': 'Klopp fumes at VAR decisions in West Ham defeat',
            'description': 'md5:9c50371095a01ad3f63311c73d8f51a5',
            'thumbnail': 'https://cdn.jwplayer.com/v2/media/leVJrMho/poster.jpg?width=720',
            'timestamp': 1636315232,
            'upload_date': '20211107',
            'duration': 93.0,
            'tags': ['Football', 'Soccer', 'OneFootball'],
            '_old_archive_ids': ['onefootball 34041020'],
        },
        'params': {'skip_download': True}
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        data_json = self._search_json_ld(webpage, video_id, fatal=False)
        data_json.pop('url', None)
        m3u8_url = self._html_search_regex(r'(https://cdn\.jwplayer\.com/manifests/\w+\.m3u8)', webpage, 'm3u8_url')

        return self.url_result(
            m3u8_url, JWPlatformIE, video_id, _old_archive_ids=[make_archive_id(self, video_id)],
            **data_json, url_transparent=True)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/onefootball.py (Python)

Code before:
from .common import InfoExtractor
from .jwplatform import JWPlatformIE
from ..utils import filter_dict, make_archive_id


class OneFootballIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?onefootball\.com/[a-z]{2}/video/[^/&?#]+-(?P<id>\d+)'

    _TESTS = [{
        'url': 'https://onefootball.com/en/video/highlights-fc-zuerich-3-3-fc-basel-34012334',
        'info_dict': {
            'id': 'Y2VtcWAT',
            'ext': 'mp4',
            'title': 'Highlights: FC Zürich 3-3 FC Basel',
            'description': 'md5:33d9855cb790702c4fe42a513700aba8',
            'thumbnail': 'https://cdn.jwplayer.com/v2/media/Y2VtcWAT/poster.jpg?width=720',
            'timestamp': 1635874895,
            'upload_date': '20211102',
            'duration': 375.0,
            'tags': ['Football', 'Soccer', 'OneFootball'],
            '_old_archive_ids': ['onefootball 34012334'],
        },
        'params': {'skip_download': True},
        'expected_warnings': ['Failed to download m3u8 information'],
    }, {
        'url': 'https://onefootball.com/en/video/klopp-fumes-at-var-decisions-in-west-ham-defeat-34041020',
        'info_dict': {
            'id': 'leVJrMho',

Review comment (suggestion):
```suggestion
from ..utils import make_archive_id
```

Code after:
from .common import InfoExtractor
from .jwplatform import JWPlatformIE
from ..utils import make_archive_id


class OneFootballIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?onefootball\.com/[a-z]{2}/video/[^/&?#]+-(?P<id>\d+)'

    _TESTS = [{
        'url': 'https://onefootball.com/en/video/highlights-fc-zuerich-3-3-fc-basel-34012334',
        'info_dict': {
            'id': 'Y2VtcWAT',
            'ext': 'mp4',
            'title': 'Highlights: FC Zürich 3-3 FC Basel',
            'description': 'md5:33d9855cb790702c4fe42a513700aba8',
            'thumbnail': 'https://cdn.jwplayer.com/v2/media/Y2VtcWAT/poster.jpg?width=720',
            'timestamp': 1635874895,
            'upload_date': '20211102',
            'duration': 375.0,
            'tags': ['Football', 'Soccer', 'OneFootball'],
            '_old_archive_ids': ['onefootball 34012334'],
        },
        'params': {'skip_download': True},
        'expected_warnings': ['Failed to download m3u8 information'],
    }, {
        'url': 'https://onefootball.com/en/video/klopp-fumes-at-var-decisions-in-west-ham-defeat-34041020',
        'info_dict': {
            'id': 'leVJrMho',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/tiktok.py (Python)

Code before:
import itertools
import json
import random
import re
import string
import time

from .common import InfoExtractor
from ..networking import HEADRequest
from ..compat import compat_urllib_parse_urlparse
from ..utils import (
    ExtractorError,
    LazyList,
    UnsupportedError,
    UserNotLive,
    determine_ext,
    format_field,
    int_or_none,
    join_nonempty,
    merge_dicts,
    qualities,
    remove_start,
    srt_subtitles_timecode,
    str_or_none,
    traverse_obj,
    try_call,
    try_get,
    url_or_none,
)


class TikTokBaseIE(InfoExtractor):
    _APP_VERSIONS = [('26.1.3', '260103'), ('26.1.2', '260102'), ('26.1.1', '260101'), ('25.6.2', '250602')]
    _WORKING_APP_VERSION = None
    _APP_NAME = 'trill'

Review comment (suggestion):
revert unnecessary/unrelated formatting change
```suggestion
from ..compat import compat_urllib_parse_urlparse
from ..networking import HEADRequest
```

Code after:
import itertools
import json
import random
import re
import string
import time

from .common import InfoExtractor
from ..compat import compat_urllib_parse_urlparse
from ..networking import HEADRequest
from ..utils import (
    ExtractorError,
    LazyList,
    UnsupportedError,
    UserNotLive,
    determine_ext,
    format_field,
    int_or_none,
    join_nonempty,
    merge_dicts,
    qualities,
    remove_start,
    srt_subtitles_timecode,
    str_or_none,
    traverse_obj,
    try_call,
    try_get,
    url_or_none,
)


class TikTokBaseIE(InfoExtractor):
    _APP_VERSIONS = [('26.1.3', '260103'), ('26.1.2', '260102'), ('26.1.1', '260101'), ('25.6.2', '250602')]
    _WORKING_APP_VERSION = None
    _APP_NAME = 'trill'
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/murrtube.py (Python)

Code before:
import functools

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    urlencode_postdata,
    extract_attributes
)


class MurrtubeIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            murrtube:|
                            https?://murrtube\.net/v/|
                            https?://murrtube\.net/videos/(?P<slug>[a-z0-9\-]+?)\-
                        )
                        (?P<id>[A-Z0-9]{4}|[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12})
                    '''

    _TESTS = [
        {
            'url': 'https://murrtube.net/videos/inferno-x-skyler-148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
            'md5': '70380878a77e8565d4aea7f68b8bbb35',
            'info_dict': {
                'id': 'ca885d8456b95de529b6723b158032e11115d',
                'ext': 'mp4',
                'title': 'Inferno X Skyler',
                'description': 'Humping a very good slutty sheppy (roomate)',
                'uploader': 'Inferno Wolf',
                'age_limit': 18,
                'thumbnail': 'https://storage.murrtube.net/murrtube-production/ekbs3zcfvuynnqfx72nn2tkokvsd',

Review comment (refactor):
```suggestion
    clean_html,
    extract_attributes,
    get_element_by_class,
    get_element_html_by_id,
    parse_count,
    remove_end,
    update_url,
    urlencode_postdata,
```

Code after:
import functools
import json

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    clean_html,
    extract_attributes,
    get_element_by_class,
    get_element_html_by_id,
    parse_count,
    remove_end,
    update_url,
    urlencode_postdata,
)


class MurrtubeIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            murrtube:|
                            https?://murrtube\.net/(?:v/|videos/(?P<slug>[a-z0-9-]+?)-)
                        )
                        (?P<id>[A-Z0-9]{4}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})
                    '''
    _TESTS = [{
        'url': 'https://murrtube.net/videos/inferno-x-skyler-148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
        'md5': '70380878a77e8565d4aea7f68b8bbb35',
        'info_dict': {
            'id': 'ca885d8456b95de529b6723b158032e11115d',
            'ext': 'mp4',
            'title': 'Inferno X Skyler',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/murrtube.py (Python)

Code before:
import functools

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    urlencode_postdata,
    extract_attributes
)


class MurrtubeIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            murrtube:|
                            https?://murrtube\.net/v/|
                            https?://murrtube\.net/videos/(?P<slug>[a-z0-9\-]+?)\-
                        )
                        (?P<id>[A-Z0-9]{4}|[a-f0-9]{8}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{4}\-[a-f0-9]{12})
                    '''

    _TESTS = [
        {
            'url': 'https://murrtube.net/videos/inferno-x-skyler-148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
            'md5': '70380878a77e8565d4aea7f68b8bbb35',
            'info_dict': {
                'id': 'ca885d8456b95de529b6723b158032e11115d',
                'ext': 'mp4',
                'title': 'Inferno X Skyler',
                'description': 'Humping a very good slutty sheppy (roomate)',
                'uploader': 'Inferno Wolf',
                'age_limit': 18,
                'thumbnail': 'https://storage.murrtube.net/murrtube-production/ekbs3zcfvuynnqfx72nn2tkokvsd',
                'comment_count': int,
                'view_count': int,
                'like_count': int,
            },
        },
        {
            'url': 'https://murrtube.net/v/0J2Q',
            'md5': '31262f6ac56f0ca75e5a54a0f3fefcb6',
            'info_dict': {

Review comment (suggestion):
```suggestion
                            https?://murrtube\.net/(?:v/|videos/(?P<slug>[a-z0-9-]+?)-)
```

Code after:
import functools
import json

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    OnDemandPagedList,
    clean_html,
    extract_attributes,
    get_element_by_class,
    get_element_html_by_id,
    parse_count,
    remove_end,
    update_url,
    urlencode_postdata,
)


class MurrtubeIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            murrtube:|
                            https?://murrtube\.net/(?:v/|videos/(?P<slug>[a-z0-9-]+?)-)
                        )
                        (?P<id>[A-Z0-9]{4}|[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})
                    '''
    _TESTS = [{
        'url': 'https://murrtube.net/videos/inferno-x-skyler-148b6f2a-fdcc-4902-affe-9c0f41aaaca0',
        'md5': '70380878a77e8565d4aea7f68b8bbb35',
        'info_dict': {
            'id': 'ca885d8456b95de529b6723b158032e11115d',
            'ext': 'mp4',
            'title': 'Inferno X Skyler',
            'description': 'Humping a very good slutty sheppy (roomate)',
            'uploader': 'Inferno Wolf',
            'age_limit': 18,
            'thumbnail': 'https://storage.murrtube.net/murrtube-production/ekbs3zcfvuynnqfx72nn2tkokvsd',
            'comment_count': int,
            'view_count': int,
            'like_count': int,
        },
    }, {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/gofile.py (Python)

Code before:
import hashlib
import requests
import json

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    try_get
)


class GofileIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
    _TESTS = [{
        'url': 'https://gofile.io/d/AMZyDw',
        'info_dict': {
            'id': 'AMZyDw',
        },
        'playlist_mincount': 2,
        'playlist': [{
            'info_dict': {
                'id': 'de571ac1-5edc-42e2-8ec2-bdac83ad4a31',
                'filesize': 928116,
                'ext': 'mp4',
                'title': 'nuuh',
                'release_timestamp': 1638338704,
                'release_date': '20211201',
            }

Review comment (refactor):
not needed, we should be using the helper methods instead
```suggestion
```

Code after:
import hashlib

from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    try_get
)


class GofileIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?gofile\.io/d/(?P<id>[^/]+)'
    _TESTS = [{
        'url': 'https://gofile.io/d/AMZyDw',
        'info_dict': {
            'id': 'AMZyDw',
        },
        'playlist_mincount': 2,
        'playlist': [{
            'info_dict': {
                'id': 'de571ac1-5edc-42e2-8ec2-bdac83ad4a31',
                'filesize': 928116,
                'ext': 'mp4',
                'title': 'nuuh',
                'release_timestamp': 1638338704,
                'release_date': '20211201',
            }
        }]
    }, {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/fathom.py (Python)

Code before:
            'duration': 8125.380507,
            'timestamp': 1699036314.0,
            'upload_date': '20231103',
        },
    }, {
        'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
        'md5': '4f5cb382126c22d1aba8a939f9c49690',
        'info_dict': {
            'id': '46812957',
            'ext': 'mp4',
            'title': 'Jon, Lawrence, Neman chat about practice',
            'duration': 3571.517847,
            'timestamp': 1698921000.0,
            'upload_date': '20231102',
        },
    }]

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

        div_app = get_element_html_by_id('app', webpage)
        attrs = extract_attributes(div_app)
        data = json.loads(attrs["data-page"])

        video_id = str(data['props']['call']['id'])
        title = data['props']['head']['title']
        duration = data['props']['duration']
        upload_date = datetime.fromisoformat(data['props']['call']['started_at'])
        timestamp = time.mktime(upload_date.timetuple())

        source_url = data['props']['call']['video_url']

        formats = self._extract_m3u8_formats(
            source_url, video_id, 'mp4', entry_protocol='m3u8_native', fatal=False)

        return {
            'id': video_id,
            'title': title,
            'duration': duration,
            'timestamp': timestamp,
            'formats': formats,
        }


Review comment (suggestion):
adjusting per my above suggestion
```suggestion
        video_id = str(props['call']['id'])
```

Code after:
            'title': 'eCom Inucbator - Coaching Session',
            'duration': 8125.380507,
            'timestamp': 1699048914,
            'upload_date': '20231103',
        },
    }, {
        'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
        'md5': '4f5cb382126c22d1aba8a939f9c49690',
        'info_dict': {
            'id': '46812957',
            'ext': 'mp4',
            'title': 'Jon, Lawrence, Neman chat about practice',
            'duration': 3571.517847,
            'timestamp': 1698933600,
            'upload_date': '20231102',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        props = traverse_obj(
            get_element_html_by_id('app', webpage), ({extract_attributes}, 'data-page', {json.loads}, 'props'))
        video_id = str(props['call']['id'])

        return {
            'id': video_id,
            'formats': self._extract_m3u8_formats(props['call']['video_url'], video_id, 'mp4'),
            **traverse_obj(props, {
                'title': ('head', 'title', {str}),
                'duration': ('duration', {float_or_none}),
                'timestamp': ('call', 'started_at', {parse_iso8601}),
            }),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/fathom.py (Python)

Code before:
        'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
        'md5': '4f5cb382126c22d1aba8a939f9c49690',
        'info_dict': {
            'id': '46812957',
            'ext': 'mp4',
            'title': 'Jon, Lawrence, Neman chat about practice',
            'duration': 3571.517847,
            'timestamp': 1698921000.0,
            'upload_date': '20231102',
        },
    }]

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

        div_app = get_element_html_by_id('app', webpage)
        attrs = extract_attributes(div_app)
        data = json.loads(attrs["data-page"])

        video_id = str(data['props']['call']['id'])
        title = data['props']['head']['title']
        duration = data['props']['duration']
        upload_date = datetime.fromisoformat(data['props']['call']['started_at'])
        timestamp = time.mktime(upload_date.timetuple())

        source_url = data['props']['call']['video_url']

        formats = self._extract_m3u8_formats(
            source_url, video_id, 'mp4', entry_protocol='m3u8_native', fatal=False)

        return {
            'id': video_id,
            'title': title,
            'duration': duration,
            'timestamp': timestamp,
            'formats': formats,
        }


Review comment (refactor):
this metadata extraction should be completely non-fatal and can be inlined in the return
```suggestion
```

Code after:
    }, {
        'url': 'https://fathom.video/share/mEws3bybftHL2QLymxYEDeE21vtLxGVm',
        'md5': '4f5cb382126c22d1aba8a939f9c49690',
        'info_dict': {
            'id': '46812957',
            'ext': 'mp4',
            'title': 'Jon, Lawrence, Neman chat about practice',
            'duration': 3571.517847,
            'timestamp': 1698933600,
            'upload_date': '20231102',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        webpage = self._download_webpage(url, display_id)
        props = traverse_obj(
            get_element_html_by_id('app', webpage), ({extract_attributes}, 'data-page', {json.loads}, 'props'))
        video_id = str(props['call']['id'])

        return {
            'id': video_id,
            'formats': self._extract_m3u8_formats(props['call']['video_url'], video_id, 'mp4'),
            **traverse_obj(props, {
                'title': ('head', 'title', {str}),
                'duration': ('duration', {float_or_none}),
                'timestamp': ('call', 'started_at', {parse_iso8601}),
            }),
        }