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

Code before:
                    'url': url,
                })

                if ext == 'vtt':
                    subtitles[lang].append({
                        'ext': 'srt',
                        'url': f'{remove_end(initial_state[key], "vtt")}srt',
                    })

        episode = traverse_obj(list(filter(
            lambda x: x.get('@type') in ('TVEpisode', 'Movie'), self._yield_json_ld(webpage, display_id))), 0) or {}
        return {
            'id': display_id,
            'title': (traverse_obj(initial_state, 'title', 'display_title')
                      or episode.get('name')),
            'description': initial_state.get('description') or episode.get('description'),
            'duration': initial_state.get('duration'),
            'thumbnail': traverse_obj(episode, ('image', 'url')),
            'timestamp': unified_timestamp(episode.get('dateCreated')),
            'formats': formats,
            'subtitles': subtitles,
            'episode_number': (traverse_obj(initial_state, 'episode_no', 'episodeno', expected_type=int_or_none)
                               or int_or_none(episode.get('episodeNumber'))),
            'cast': traverse_obj(episode, ('actor', ..., 'name'), default=None),
            'age_limit': self._AGE_RATINGS_MAPPER.get(
                initial_state.get('internal_age_rating'))
        }


Review comment (suggestion):
```suggestion
            'age_limit': self._AGE_RATINGS_MAPPER.get(initial_state.get('internal_age_rating'))
```

Code after:
                    'url': url,
                })

                if ext == 'vtt':
                    subtitles[lang].append({
                        'ext': 'srt',
                        'url': f'{remove_end(initial_state[key], "vtt")}srt',
                    })

        episode = traverse_obj(list(filter(
            lambda x: x.get('@type') in ('TVEpisode', 'Movie'), self._yield_json_ld(webpage, display_id))), 0) or {}
        return {
            'id': display_id,
            'title': (traverse_obj(initial_state, 'title', 'display_title')
                      or episode.get('name')),
            'description': initial_state.get('description') or episode.get('description'),
            'duration': initial_state.get('duration'),
            'thumbnail': traverse_obj(episode, ('image', 'url')),
            'timestamp': unified_timestamp(episode.get('dateCreated')),
            'formats': formats,
            'subtitles': subtitles,
            'episode_number': (traverse_obj(initial_state, 'episode_no', 'episodeno', expected_type=int_or_none)
                               or int_or_none(episode.get('episodeNumber'))),
            'cast': traverse_obj(episode, ('actor', ..., 'name'), default=None),
            'age_limit': self._AGE_RATINGS_MAPPER.get(initial_state.get('internal_age_rating'))
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/clyp.py (Python)

Code before:
from .common import InfoExtractor
from ..utils import (
    float_or_none,
    parse_qs,
    unified_timestamp,
)


class ClypIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
    _TESTS = [{
        'url': 'https://clyp.it/ojz2wfah',
        'md5': '1d4961036c41247ecfdcc439c0cddcbb',
        'info_dict': {
            'id': 'ojz2wfah',
            'ext': 'mp3',
            'title': 'Krisson80 - bits wip wip',
            'description': '#Krisson80BitsWipWip #chiptune\n#wip',
            'duration': 263.21,
            'timestamp': 1443515251,
            'upload_date': '20150929',
        },
    }, {
        'url': 'https://clyp.it/b04p1odi?token=b0078e077e15835845c528a44417719d',
        'info_dict': {
            'id': 'b04p1odi',
            'ext': 'mp3',
            'title': 'GJ! (Reward Edit)',
            'description': 'Metal Resistance (THE ONE edition)',
            'duration': 177.789,
            'timestamp': 1528241278,
            'upload_date': '20180605',
        },
        'params': {
            'skip_download': True,
        },
    }]

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

        qs = parse_qs(url)
        token = qs.get('token', [None])[0]

Review comment (suggestion):
```suggestion
```
Neither of the tests have description? Add one with it is possible

Code after:
from .common import InfoExtractor
from ..utils import (
    float_or_none,
    parse_qs,
    unified_timestamp,
)


class ClypIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?clyp\.it/(?P<id>[a-z0-9]+)'
    _TESTS = [{
        'url': 'https://clyp.it/iynkjk4b',
        'md5': '4bc6371c65210e7b372097fce4d92441',
        'info_dict': {
            'id': 'iynkjk4b',
            'ext': 'ogg',
            'title': 'research',
            'description': '#Research',
            'duration': 51.278,
            'timestamp': 1435524981,
            'upload_date': '20150628',
        },
    }, {
        'url': 'https://clyp.it/b04p1odi?token=b0078e077e15835845c528a44417719d',
        'info_dict': {
            'id': 'b04p1odi',
            'ext': 'ogg',
            'title': 'GJ! (Reward Edit)',
            'description': 'Metal Resistance (THE ONE edition)',
            'duration': 177.789,
            'timestamp': 1528241278,
            'upload_date': '20180605',
        },
        'params': {
            'skip_download': True,
        },
    }, {
        'url': 'https://clyp.it/v42214lc',
        'md5': '4aca4dfc3236fb6d6ddc4ea08314f33f',
        'info_dict': {
            'id': 'v42214lc',
            'ext': 'wav',
            'title': 'i dont wanna go (old version)',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/vocaroo.py (Python)

Code before:
from .common import InfoExtractor


class VocarooIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:vocaroo\.com|voca\.ro)/(?:embed/)?(?P<id>[a-zA-Z0-9]{11,12})'
    _TESTS = [
        {
            'url': 'https://vocaroo.com/1de8yA3LNe77',
            'md5': 'c557841d5e50261777a6585648adf439',
            'info_dict': {
                'id': '1de8yA3LNe77',
                'ext': 'mp3',
                'title': 'Vocaroo 1de8yA3LNe77',
            },
        },
        {
            'url': 'https://vocaroo.com/embed/my6dHeF93UR?autoplay=0',
            'only_matching': True,
        },
        {
            'url': 'https://voca.ro/15VY7fSWDqpU',
            'only_matching': True,
        },
    ]

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

        return {
            'id': audio_id,
            'title': f'Vocaroo {audio_id}',
            'url': f'https://media1.vocaroo.com/mp3/{audio_id}',
            'ext': 'mp3',
            'http_headers': {'Referer': 'https://vocaroo.com/'},
        }


Review comment (suggestion):
```suggestion
            'ext': 'mp3',
            'vcodec': 'none',
```

Code after:
            'md5': 'f322e529275dd8a47994919eeac404a5',
            'info_dict': {
                'id': '19cgWmKO6AmC',
                'ext': 'mp3',
                'title': 'Vocaroo video #19cgWmKO6AmC',
                'timestamp': 1675093841.408,
                'upload_date': '20230130',
            },
        },
    ]

    def _real_extract(self, url):
        audio_id = self._match_id(url)
        if len(audio_id) == 10 or (len(audio_id) == 12 and audio_id[0] == '1'):
            media_subdomain = 'media1'
        else:
            media_subdomain = 'media'

        url = f'https://{media_subdomain}.vocaroo.com/mp3/{audio_id}'
        http_headers = {'Referer': 'https://vocaroo.com/'}
        resp = self._request_webpage(HEADRequest(url), audio_id, headers=http_headers)
        return {
            'id': audio_id,
            'title': '',
            'url': url,
            'ext': 'mp3',
            'timestamp': float_or_none(resp.getheader('x-bz-upload-timestamp'), scale=1000),
            'vcodec': 'none',
            'http_headers': http_headers,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/vocaroo.py (Python)

Code before:
from .common import InfoExtractor


class VocarooIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:vocaroo\.com|voca\.ro)/(?:embed/)?(?P<id>[a-zA-Z0-9]{11,12})'
    _TESTS = [
        {
            'url': 'https://vocaroo.com/1de8yA3LNe77',
            'md5': 'c557841d5e50261777a6585648adf439',
            'info_dict': {
                'id': '1de8yA3LNe77',
                'ext': 'mp3',
                'title': 'Vocaroo 1de8yA3LNe77',
            },
        },
        {
            'url': 'https://vocaroo.com/embed/my6dHeF93UR?autoplay=0',
            'only_matching': True,
        },
        {
            'url': 'https://voca.ro/15VY7fSWDqpU',
            'only_matching': True,
        },
    ]

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

        return {
            'id': audio_id,

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?(?:vocaroo\.com|voca\.ro)/(?:embed/)?(?P<id>\w+)'
```

Code after:
from .common import InfoExtractor
from ..utils import (
    HEADRequest,
    float_or_none,
)


class VocarooIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?(?:vocaroo\.com|voca\.ro)/(?:embed/)?(?P<id>\w+)'
    _EMBED_REGEX = [r'<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?(?:www\.)?vocaroo\.com/embed/.+?)\1']
    _TESTS = [
        {
            'url': 'https://vocaroo.com/1de8yA3LNe77',
            'md5': 'c557841d5e50261777a6585648adf439',
            'info_dict': {
                'id': '1de8yA3LNe77',
                'ext': 'mp3',
                'title': 'Vocaroo video #1de8yA3LNe77',
                'timestamp': 1675059800.370,
                'upload_date': '20230130',
            },
        },
        {
            'url': 'https://vocaroo.com/embed/12WqtjLnpj6g?autoplay=0',
            'only_matching': True,
        },
        {
            'url': 'https://voca.ro/12D52rgpzkB0',
            'only_matching': True,
        },
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/vocaroo.py (Python)

Code before:

    _WEBPAGE_TESTS = [
        {
            'url': 'https://qbnu.github.io/cool.html',
            'md5': 'f322e529275dd8a47994919eeac404a5',
            'info_dict': {
                'id': '19cgWmKO6AmC',
                'ext': 'mp3',
                'title': 'Vocaroo video #19cgWmKO6AmC',
                'timestamp': 1675093841.408,
                'upload_date': '20230130',
            },
        },
    ]

    def _real_extract(self, url):
        audio_id = self._match_id(url)
        if len(audio_id) == 10 or (len(audio_id) == 12 and audio_id[0] == '1'):
            media_subdomain = 'media1'
        else:
            media_subdomain = 'media'

        url = f'https://{media_subdomain}.vocaroo.com/mp3/{audio_id}'
        http_headers = {'Referer': 'https://vocaroo.com/'}
        req = HEADRequest(url, headers=http_headers)
        resp = self._request_webpage(req, audio_id)
        timestamp = float_or_none(resp.getheader('x-bz-upload-timestamp'), scale=1000)

        return {
            'id': audio_id,
            'title': '',
            'url': url,
            'ext': 'mp3',
            'timestamp': timestamp,
            'vcodec': 'none',
            'http_headers': http_headers,
        }


Review comment (suggestion):
```suggestion
        resp = self._request_webpage(HEADRequest(url), audio_id, headers=http_headers)
```

Code after:

    _WEBPAGE_TESTS = [
        {
            'url': 'https://qbnu.github.io/cool.html',
            'md5': 'f322e529275dd8a47994919eeac404a5',
            'info_dict': {
                'id': '19cgWmKO6AmC',
                'ext': 'mp3',
                'title': 'Vocaroo video #19cgWmKO6AmC',
                'timestamp': 1675093841.408,
                'upload_date': '20230130',
            },
        },
    ]

    def _real_extract(self, url):
        audio_id = self._match_id(url)
        if len(audio_id) == 10 or (len(audio_id) == 12 and audio_id[0] == '1'):
            media_subdomain = 'media1'
        else:
            media_subdomain = 'media'

        url = f'https://{media_subdomain}.vocaroo.com/mp3/{audio_id}'
        http_headers = {'Referer': 'https://vocaroo.com/'}
        resp = self._request_webpage(HEADRequest(url), audio_id, headers=http_headers)
        return {
            'id': audio_id,
            'title': '',
            'url': url,
            'ext': 'mp3',
            'timestamp': float_or_none(resp.getheader('x-bz-upload-timestamp'), scale=1000),
            'vcodec': 'none',
            'http_headers': http_headers,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/ebay.py (Python)

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


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TEST = {
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'HELIX upload [AN_Master_A04B.mp4] - 1666069406072',
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        }
    }

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

        video_json = self._search_json(r'"video":\s*', webpage, "video_json", video_id)

        playlist_map = video_json.get('playlistMap')
        if not playlist_map:
            raise ExtractorError('Unable to extract video urls')

        formats = []
        for key in playlist_map:
            if key == "HLS":
                formats.extend(self._extract_m3u8_formats(
                    playlist_map.get(key), video_id, m3u8_id='hls', fatal=False))
            if key == "DASH":
                formats.extend(self._extract_mpd_formats(
                    playlist_map.get(key), video_id, fatal=False))

        return {
            'id': video_id,
            'title': video_json.get('title'),
            'formats': formats
        }


Review comment (suggestion):
```suggestion
        video_json = self._search_json(r'"video":', webpage, 'video json', video_id)
```

Code after:
from .common import InfoExtractor
from ..utils import remove_end


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'WiFi internal antenna adhesive for wifi 2.4GHz wifi 5 wifi 6 wifi 6E full bands',
        },
        'params': {'skip_download': 'm3u8'}
    }]

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

        video_json = self._search_json(r'"video":', webpage, 'video json', video_id)

        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                self.report_warning(f'Unsupported format {key}', video_id)

        return {
            'id': video_id,
            'title': remove_end(self._html_extract_title(webpage), ' | eBay'),
            'formats': formats
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/ebay.py (Python)

Code before:
            'title': 'HELIX upload [AN_Master_A04B.mp4] - 1666069406072',
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        }
    }

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

        video_json = self._search_json(r'"video":\s*', webpage, "video_json", video_id)

        playlist_map = video_json.get('playlistMap')
        if not playlist_map:
            raise ExtractorError('Unable to extract video urls')

        formats = []
        for key in playlist_map:
            if key == "HLS":
                formats.extend(self._extract_m3u8_formats(
                    playlist_map.get(key), video_id, m3u8_id='hls', fatal=False))
            if key == "DASH":
                formats.extend(self._extract_mpd_formats(
                    playlist_map.get(key), video_id, fatal=False))

        return {
            'id': video_id,
            'title': video_json.get('title'),
            'formats': formats
        }


Review comment (refactor):
```suggestion
        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                # Add a warning here
```

Code after:
            'title': 'WiFi internal antenna adhesive for wifi 2.4GHz wifi 5 wifi 6 wifi 6E full bands',
        },
        'params': {'skip_download': 'm3u8'}
    }]

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

        video_json = self._search_json(r'"video":', webpage, 'video json', video_id)

        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                self.report_warning(f'Unsupported format {key}', video_id)

        return {
            'id': video_id,
            'title': remove_end(self._html_extract_title(webpage), ' | eBay'),
            'formats': formats
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/ebay.py (Python)

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


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TEST = {
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'HELIX upload [AN_Master_A04B.mp4] - 1666069406072',
        },
        'params': {
            # m3u8 download
            'skip_download': True,
        }
    }

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

        video_json = self._search_json(r'"video":\s*', webpage, "video_json", video_id)

        playlist_map = video_json.get('playlistMap')
        if not playlist_map:
            raise ExtractorError('Unable to extract video urls')

        formats = []
        for key in playlist_map:
            if key == "HLS":
                formats.extend(self._extract_m3u8_formats(
                    playlist_map.get(key), video_id, m3u8_id='hls', fatal=False))
            if key == "DASH":
                formats.extend(self._extract_mpd_formats(
                    playlist_map.get(key), video_id, fatal=False))

        return {
            'id': video_id,
            'title': video_json.get('title'),

Review comment (suggestion):
```suggestion
            'skip_download': 'm3u8'',
```

Code after:
from .common import InfoExtractor
from ..utils import remove_end


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'WiFi internal antenna adhesive for wifi 2.4GHz wifi 5 wifi 6 wifi 6E full bands',
        },
        'params': {'skip_download': 'm3u8'}
    }]

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

        video_json = self._search_json(r'"video":', webpage, 'video json', video_id)

        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                self.report_warning(f'Unsupported format {key}', video_id)

        return {
            'id': video_id,
            'title': remove_end(self._html_extract_title(webpage), ' | eBay'),
            'formats': formats
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/ebay.py (Python)

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


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TEST = {
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'HELIX upload [AN_Master_A04B.mp4] - 1666069406072',
        },
        'params': {
            # m3u8 download
            'skip_download': 'm3u8',
        }
    }

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

        video_json = self._search_json(r'"video":', webpage, "video json", video_id)

        playlist_map = video_json.get('playlistMap')
        if not playlist_map:
            raise ExtractorError('Unable to extract video urls')

        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                self.report_warning('unsupported format found: %s' % key, video_id)

        return {
            'id': video_id,
            'title': video_json.get('title'),
            'formats': formats
        }

Review comment (suggestion):
```suggestion
    _TESTS = [{
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'HELIX upload [AN_Master_A04B.mp4] - 1666069406072',
        },
        'params': {'skip_download': 'm3u8'}
    }]
```

Code after:
from .common import InfoExtractor
from ..utils import remove_end


class EbayIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?ebay\.com/itm/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.ebay.com/itm/194509326719',
        'info_dict': {
            'id': '194509326719',
            'ext': 'mp4',
            'title': 'WiFi internal antenna adhesive for wifi 2.4GHz wifi 5 wifi 6 wifi 6E full bands',
        },
        'params': {'skip_download': 'm3u8'}
    }]

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

        video_json = self._search_json(r'"video":', webpage, 'video json', video_id)

        formats = []
        for key, url in video_json['playlistMap'].items():
            if key == 'HLS':
                formats.extend(self._extract_m3u8_formats(url, video_id, fatal=False))
            elif key == 'DASH':
                formats.extend(self._extract_mpd_formats(url, video_id, fatal=False))
            else:
                self.report_warning(f'Unsupported format {key}', video_id)

        return {
            'id': video_id,
            'title': remove_end(self._html_extract_title(webpage), ' | eBay'),
            'formats': formats
        }