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

Code before:
from .common import InfoExtractor
from .vimeo import VimeoIE


class ShieyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?shiey\.com/videos/v/(?P<id>[^/]+)'

    _TESTS = [{
        'url': 'https://www.shiey.com/videos/v/train-journey-to-edge-of-serbia-ep-2',
        'info_dict': {
            'id': 'train-journey-to-edge-of-serbia-ep-2',
            'title': 'Train Journey to the Edge of Serbia - Ep. 2',
            'uploader': 'Shiey',
        },
        'params': {
            'skip_download': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        vimeo_url = self._search_regex(r'iframe src=\\&quot;(https?://player\.vimeo\.com/video/[^\\&]+)', webpage, 'vimeo url')
        return self.url_result(VimeoIE._smuggle_referrer(vimeo_url, url), VimeoIE)


Review comment (refactor):
This should be more robust
```suggestion
        oembed_html = traverse_obj(webpage, (
            {find_element(attr='data-controller', value='VideoEmbed', html=True)},
            {extract_attributes}, 'data-config-embed-video', {json.loads}, 'oembedHtml', {str}))

        return self.url_result(VimeoIE._extract_url(url, oembed_html), VimeoIE)
```

Code after:
import json

from .common import InfoExtractor
from .vimeo import VimeoIE
from ..utils import extract_attributes
from ..utils.traversal import find_element, traverse_obj


class ShieyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?shiey\.com/videos/v/(?P<id>[^/?#]+)'

    _TESTS = [{
        'url': 'https://www.shiey.com/videos/v/train-journey-to-edge-of-serbia-ep-2',
        'info_dict': {
            'id': '1103409448',
            'ext': 'mp4',
            'title': 'Train Journey To Edge of Serbia (Ep. 2)',
            'uploader': 'shiey',
            'uploader_url': '',
            'duration': 1364,
            'thumbnail': r're:^https?://.+',
        },
        'params': {'skip_download': True},
        'expected_warnings': ['Failed to parse XML: not well-formed'],
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        oembed_html = traverse_obj(webpage, (
            {find_element(attr='data-controller', value='VideoEmbed', html=True)},
            {extract_attributes}, 'data-config-embed-video', {json.loads}, 'oembedHtml', {str}))

        return self.url_result(VimeoIE._extract_url(url, oembed_html), VimeoIE)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/shiey.py (Python)

Code before:
from .common import InfoExtractor
from .vimeo import VimeoIE


class ShieyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?shiey\.com/videos/v/(?P<id>[^/]+)'

    _TESTS = [{
        'url': 'https://www.shiey.com/videos/v/train-journey-to-edge-of-serbia-ep-2',
        'info_dict': {
            'id': 'train-journey-to-edge-of-serbia-ep-2',
            'title': 'Train Journey to the Edge of Serbia - Ep. 2',
            'uploader': 'Shiey',
        },
        'params': {
            'skip_download': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
        vimeo_url = self._search_regex(r'iframe src=\\&quot;(https?://player\.vimeo\.com/video/[^\\&]+)', webpage, 'vimeo url')
        return self.url_result(VimeoIE._smuggle_referrer(vimeo_url, url), VimeoIE)


Review comment (refactor):
Needed for the other changes
```suggestion
import json

from .common import InfoExtractor
from .vimeo import VimeoIE
from ..utils import extract_attributes
from ..utils.traversal import find_element, traverse_obj
```

Code after:
import json

from .common import InfoExtractor
from .vimeo import VimeoIE
from ..utils import extract_attributes
from ..utils.traversal import find_element, traverse_obj


class ShieyIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?shiey\.com/videos/v/(?P<id>[^/?#]+)'

    _TESTS = [{
        'url': 'https://www.shiey.com/videos/v/train-journey-to-edge-of-serbia-ep-2',
        'info_dict': {
            'id': '1103409448',
            'ext': 'mp4',
            'title': 'Train Journey To Edge of Serbia (Ep. 2)',
            'uploader': 'shiey',
            'uploader_url': '',
            'duration': 1364,
            'thumbnail': r're:^https?://.+',
        },
        'params': {'skip_download': True},
        'expected_warnings': ['Failed to parse XML: not well-formed'],
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/umg.py (Python)

Code before:
            'view_count': int,
        },
    }, {
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        video_id = display_id.split('-')[-1]
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artist': self._html_search_meta('umg-artist-screenname', webpage),
            'description': traverse_obj(webpage, (
                {find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }


Review comment (suggestion):
I'd just return `artists` here since `artist` is technically deprecated
```suggestion
            'artists': list(filter(None, self._html_search_meta('umg-artist-screenname', webpage))),
```

Code after:
        },
    }, {
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id, video_id = self._match_valid_url(url).group('slug', 'id')
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artists': traverse_obj(self._html_search_meta('umg-artist-screenname', webpage), (filter, all)),
            # The JSON LD description duplicates the title
            'description': traverse_obj(webpage, ({find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/umg.py (Python)

Code before:
    }, {
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id = self._match_id(url)
        video_id = display_id.split('-')[-1]
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artist': self._html_search_meta('umg-artist-screenname', webpage),
            'description': traverse_obj(webpage, (
                {find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }


Review comment (refactor):
per Grub's suggestion
```suggestion
            # The JSON LD description duplicates the title
            'description': traverse_obj(webpage, ({find_element(cls='_3Y0Lj')}, {clean_html})),
```

Code after:
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id, video_id = self._match_valid_url(url).group('slug', 'id')
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artists': traverse_obj(self._html_search_meta('umg-artist-screenname', webpage), (filter, all)),
            # The JSON LD description duplicates the title
            'description': traverse_obj(webpage, ({find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/umg.py (Python)

Code before:
            'upload_date': '20171218',
            'view_count': int,
        },
    }, {
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id, video_id = self._match_valid_url(url).group('slug', 'id')
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artists': traverse_obj(self._html_search_meta('umg-artist-screenname', webpage), all),
            # The JSON LD description duplicates the title
            'description': traverse_obj(webpage, ({find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }


Review comment (suggestion):
to guard against empty strings (as my original suggestion would've if I hadn't made that typo)
```suggestion
            'artists': traverse_obj(self._html_search_meta('umg-artist-screenname', webpage), (filter, all)),
```

Code after:
            'view_count': int,
        },
    }, {
        'url': 'https://www.universal-music.de/alexander-eder/videos/der-doktor-hat-gesagt-609533',
        'info_dict': {
            'id': '609533',
            'ext': 'mp4',
            'title': 'Der Doktor hat gesagt',
            'artists': ['Alexander Eder'],
            'display_id': 'der-doktor-hat-gesagt-609533',
            'duration': 146.0,
            'thumbnail': r're:https?://images\.universal-music\.de/img/assets/.+\.jpg',
            'timestamp': 1742982100,
            'upload_date': '20250326',
        },
    }]

    def _real_extract(self, url):
        display_id, video_id = self._match_valid_url(url).group('slug', 'id')
        webpage = self._download_webpage(url, display_id)

        return {
            **self._search_json_ld(webpage, display_id),
            'id': video_id,
            'artists': traverse_obj(self._html_search_meta('umg-artist-screenname', webpage), (filter, all)),
            # The JSON LD description duplicates the title
            'description': traverse_obj(webpage, ({find_element(cls='_3Y0Lj')}, {clean_html})),
            'display_id': display_id,
            'formats': self._extract_m3u8_formats(
                'https://hls.universal-music.de/get', display_id, 'mp4', query={'id': video_id}),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/mave.py (Python)

Code before:
import json
import re

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


class MaveIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<channel_id>[a-z]+)\.mave\.digital/ep-(?P<short_id>[0-9]+)'
    _TESTS = [
        {
            'url': 'https://ochenlichnoe.mave.digital/ep-25',
            'md5': 'aa3e513ef588b4366df1520657cbc10c',
            'info_dict': {
                'id': 'ochenlichnoe-25',
                'title': 'Между мной и миром: психология самооценки',
                'description': 'md5:83183d7002dc32fbebc3ccecd4a1ac03',
                'thumbnail': r're:https?://.*\.jpg$',
                'ext': 'mp3',
                'channel': 'Очень личное',
                'channel_id': 'ochenlichnoe',
                'channel_url': 'https://ochenlichnoe.mave.digital/',
            },
        },
        {
            'url': 'https://budem.mave.digital/ep-12',
            'md5': 'e1ce2780fcdb6f17821aa3ca3e8c919f',
            'info_dict': {
                'id': 'budem-12',
                'title': 'Екатерина Михайлова: "Горе от ума" не про женщин написана',
                'description': 'md5:d9ce1fc1fb5fc7b7a4e7a0b84a7861c3',
                'thumbnail': r're:https?://.*\.jpg$',
                'ext': 'mp3',
                'channel': 'Все там будем',

Review comment (suggestion):
IMO we should relax the subdomain character class and capture the whole slug
```suggestion
    _VALID_URL = r'https?://(?P<channel>[\w-]+)\.mave\.digital/(?P<id>ep-\d+)'
```

Code after:
import re

from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    parse_iso8601,
    urljoin,
)
from ..utils.traversal import require, traverse_obj


class MaveIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<channel>[\w-]+)\.mave\.digital/(?P<id>ep-\d+)'
    _TESTS = [{
        'url': 'https://ochenlichnoe.mave.digital/ep-25',
        'md5': 'aa3e513ef588b4366df1520657cbc10c',
        'info_dict': {
            'id': '4035f587-914b-44b6-aa5a-d76685ad9bc2',
            'ext': 'mp3',
            'display_id': 'ochenlichnoe-ep-25',
            'title': 'Между мной и миром: психология самооценки',
            'description': 'md5:4b7463baaccb6982f326bce5c700382a',
            'uploader': 'Самарский университет',
            'channel': 'Очень личное',
            'channel_id': 'ochenlichnoe',
            'channel_url': 'https://ochenlichnoe.mave.digital/',
            'view_count': int,
            'like_count': int,
            'dislike_count': int,
            'duration': 3744,
            'thumbnail': r're:https://.+/storage/podcasts/.+\.jpg',
            'series': 'Очень личное',
            'series_id': '2e0c3749-6df2-4946-82f4-50691419c065',
            'season': 'Season 3',
            'season_number': 3,
            'episode': 'Episode 3',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/mave.py (Python)

Code before:
import json
import re

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


class MaveIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<channel_id>[a-z]+)\.mave\.digital/ep-(?P<short_id>[0-9]+)'
    _TESTS = [
        {
            'url': 'https://ochenlichnoe.mave.digital/ep-25',
            'md5': 'aa3e513ef588b4366df1520657cbc10c',
            'info_dict': {
                'id': 'ochenlichnoe-25',
                'title': 'Между мной и миром: психология самооценки',
                'description': 'md5:83183d7002dc32fbebc3ccecd4a1ac03',
                'thumbnail': r're:https?://.*\.jpg$',
                'ext': 'mp3',
                'channel': 'Очень личное',
                'channel_id': 'ochenlichnoe',
                'channel_url': 'https://ochenlichnoe.mave.digital/',
            },
        },
        {
            'url': 'https://budem.mave.digital/ep-12',
            'md5': 'e1ce2780fcdb6f17821aa3ca3e8c919f',
            'info_dict': {
                'id': 'budem-12',
                'title': 'Екатерина Михайлова: "Горе от ума" не про женщин написана',
                'description': 'md5:d9ce1fc1fb5fc7b7a4e7a0b84a7861c3',
                'thumbnail': r're:https?://.*\.jpg$',
                'ext': 'mp3',
                'channel': 'Все там будем',
                'channel_id': 'budem',
                'channel_url': 'https://budem.mave.digital/',

Review comment (suggestion):
you'll have an easier time generating & adding the test data if you format the `_TESTS` like this and unindent below:
```suggestion
    _TESTS = [{
```

Code after:
import re

from .common import InfoExtractor
from ..utils import (
    clean_html,
    int_or_none,
    parse_iso8601,
    urljoin,
)
from ..utils.traversal import require, traverse_obj


class MaveIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<channel>[\w-]+)\.mave\.digital/(?P<id>ep-\d+)'
    _TESTS = [{
        'url': 'https://ochenlichnoe.mave.digital/ep-25',
        'md5': 'aa3e513ef588b4366df1520657cbc10c',
        'info_dict': {
            'id': '4035f587-914b-44b6-aa5a-d76685ad9bc2',
            'ext': 'mp3',
            'display_id': 'ochenlichnoe-ep-25',
            'title': 'Между мной и миром: психология самооценки',
            'description': 'md5:4b7463baaccb6982f326bce5c700382a',
            'uploader': 'Самарский университет',
            'channel': 'Очень личное',
            'channel_id': 'ochenlichnoe',
            'channel_url': 'https://ochenlichnoe.mave.digital/',
            'view_count': int,
            'like_count': int,
            'dislike_count': int,
            'duration': 3744,
            'thumbnail': r're:https://.+/storage/podcasts/.+\.jpg',
            'series': 'Очень личное',
            'series_id': '2e0c3749-6df2-4946-82f4-50691419c065',
            'season': 'Season 3',
            'season_number': 3,
            'episode': 'Episode 3',
            'episode_number': 3,
            'timestamp': 1747817300,
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/hypergryph.py (Python)

Code before:
            'album': 'Heavenly Me',
            'artists': ['塞壬唱片-MSR', 'AIYUE blessed : 理名'],
            'description': 'md5:ce790b41c932d1ad72eb791d1d8ae598',
            'thumbnail': r're:https?://web\.hycdn\.cn/siren/pic/.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        audio_id = self._match_id(url)
        song = self._download_json(
            f'{self._API_BASE}/song/{audio_id}', audio_id)
        if song['code'] != 0:
            raise ExtractorError(song['msg'].replace('‘', '\''), expected=True)

        album_id = song['data']['albumCid']
        album = self._download_json(
            f'{self._API_BASE}/album/{album_id}/detail', album_id)

        return {
            'id': audio_id,
            'vcodec': 'none',
            **traverse_obj(song, ('data', {
                'title': ('name', {str}),
                'artists': ('artists', ..., {str}),
                'subtitles': ({'url': 'lyricUrl'}, all, {subs_list_to_dict(lang='en')}),
                'url': ('sourceUrl', {url_or_none}),
            })),
            **traverse_obj(album, ('data', {
                'album': ('name', {str}),
                'description': ('intro', {clean_html}),
                'thumbnail': ('coverUrl', {url_or_none}),
            })),
        }


Review comment (suggestion):
```py
                'subtitles': ({'url': ('lyricUrl', {url_or_none})}, all, {subs_list_to_dict(lang='en')}),
```

Code after:
            'artists': ['塞壬唱片-MSR', 'AIYUE blessed : 理名'],
            'description': 'md5:ce790b41c932d1ad72eb791d1d8ae598',
            'thumbnail': r're:https?://web\.hycdn\.cn/siren/pic/.+\.jpg',
        },
    }]

    def _real_extract(self, url):
        audio_id = self._match_id(url)
        song = self._download_json(f'{self._API_BASE}/song/{audio_id}', audio_id)
        if traverse_obj(song, 'code') != 0:
            msg = traverse_obj(song, ('msg', {str}, filter))
            raise ExtractorError(
                msg or 'API returned an error response', expected=bool(msg))

        album = None
        if album_id := traverse_obj(song, ('data', 'albumCid', {str})):
            album = self._download_json(
                f'{self._API_BASE}/album/{album_id}/detail', album_id, fatal=False)

        return {
            'id': audio_id,
            'vcodec': 'none',
            **traverse_obj(song, ('data', {
                'title': ('name', {str}),
                'artists': ('artists', ..., {str}),
                'subtitles': ({'url': 'lyricUrl'}, all, {subs_list_to_dict(lang='en')}),
                'url': ('sourceUrl', {url_or_none}),
            })),
            **traverse_obj(album, ('data', {
                'album': ('name', {str}),
                'description': ('intro', {clean_html}),
                'thumbnail': ('coverUrl', {url_or_none}),
            })),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/faulio.py (Python)

Code before:
import re

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


class FaulioLiveIE(InfoExtractor):
    _VALID_URL = (
        r'https?://(?P<domain>aloula\.sba\.sa|maraya\.sba\.net\.ae|sat7plus\.org)/'
        r'(?:en/)?live/(?P<faulio_url>[a-zA-Z0-9\-]+)'
    )

    _TESTS = [{
        'url': 'https://aloula.sba.sa/live/saudiatv',
        'info_dict': {
            'id': '2',
            'title': str,
            'description': str,
            'ext': 'mp4',
            'live_status': 'is_live',
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://aloula.sba.sa/live/sbc-channel',
        'info_dict': {
            'id': '1',
            'title': str,

Review comment (refactor):
```suggestion
from ..utils import ExtractorError
from ..utils.traversal import traverse_obj
```

Code after:
import re
import urllib.parse

from .common import InfoExtractor
from ..utils import js_to_json, url_or_none
from ..utils.traversal import traverse_obj


class FaulioLiveIE(InfoExtractor):
    _DOMAINS = (
        'aloula.sba.sa',
        'maraya.sba.net.ae',
        'sat7plus.org',
    )
    _VALID_URL = fr'https?://(?:{"|".join(map(re.escape, _DOMAINS))})/(?:(?:en|ar|fa)/)?live/(?P<id>[a-zA-Z0-9-]+)'
    _TESTS = [{
        'url': 'https://aloula.sba.sa/live/saudiatv',
        'info_dict': {
            'id': 'aloula.faulio.com_saudiatv',
            'title': str,
            'description': str,
            'ext': 'mp4',
            'live_status': 'is_live',
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://maraya.sba.net.ae/live/1',
        'info_dict': {
            'id': 'maraya.faulio.com_1',
            'title': str,