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

Code before:
        'url': 'https://www.philo.com',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/3533
        'url': 'https://www.mech-plus.com/',
        'only_matching': True,
    }, {
        'url': 'https://watch.mech-plus.com/',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/2934
        'url': 'https://www.aha.video',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/2743
        'url': 'https://mubi.com',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/3287
        'url': 'https://www.vootkids.com',
        'only_matching': True,
    }]

    @classproperty
    def _VALID_URL(cls):
        return r'https?://(?:www\.)?(?:%s)' % '|'.join(rf'(?:{s})' for s in cls.UNSUPPORTED_URLS)

    def _real_extract(self, url):
        raise ExtractorError(
            f'The requested site is known to use DRM protection. It will {self._downloader._format_err("NOT", self._downloader.Styles.EMPHASIS)} be supported by yt-dlp. '
            f'Please {self._downloader._format_err("DO NOT", self._downloader.Styles.ERROR)} open an issue, unless you have evidence that it is not DRM protected.',
            expected=True)


Review comment (suggestion):
This could be simplified to:
```py
    _VALID_URL = r'https?://(?:www\.)?(?:%s)' % '|'.join((
        r'play\.hbomax\.com',
        ...
    ))
```

Code after:
        'url': 'https://www.philo.com',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/3533
        'url': 'https://www.mech-plus.com/',
        'only_matching': True,
    }, {
        'url': 'https://watch.mech-plus.com/',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/2934
        'url': 'https://www.aha.video',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/2743
        'url': 'https://mubi.com',
        'only_matching': True,
    }, {
        # https://github.com/yt-dlp/yt-dlp/issues/3287
        'url': 'https://www.vootkids.com',
        'only_matching': True,
    }]

    @classproperty
    def _VALID_URL(cls):
        return rf'https?://(?:www\.)?(?:{"|".join(cls.UNSUPPORTED_URLS)})'

    def _real_extract(self, url):
        raise ExtractorError(
            f'The requested site is known to use DRM protection. It will {self._downloader._format_err("NOT", self._downloader.Styles.EMPHASIS)} be supported by yt-dlp. '
            f'Please {self._downloader._format_err("DO NOT", self._downloader.Styles.ERROR)} open an issue, unless you have evidence that it is not DRM protected.',
            expected=True)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/oneplace.py (Python)

Code before:
        'info_dict': {
            'id': '958461',
            'ext': 'mp3',
            'title': 'Living in the Last Days Part 2 | A Daily Walk with John Randall',
            'description': 'md5:fbb8f1cf21447ac54ecaa2887fc20c6e',
        }
    }]

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

        media_url = self._search_regex(r'mp3-url="([^"]+)', webpage, 'media_url', fatal=False) or self._search_regex(
            r'<div[^>]+id\s*=\s*"player"[^>]+data-media-url\s*=\s*"(?P<media_url>[^"]+)', webpage,
            'media_url')

        return {
            'id': video_id,
            'url': media_url,
            'title': clean_html(self._search_regex(
                r'<div[^>]class\s*=\s*"details"[^>]+>[^<]<h2[^>]+>(?P<title>[^>]+)>', webpage,
                'title', fatal=False, default=None)) or self._html_search_meta(['og:title', 'title'], webpage),
            'ext': 'mp3',
            'description': clean_html(self._search_regex(
                r'<div[^>]+class="[^"]+epDesc"[^>]*>\s*(?P<desc>.+)', webpage, 'description',
                fatal=False, default=None))
        }


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

Code after:
            'id': '958461',
            'ext': 'mp3',
            'title': 'Living in the Last Days Part 2 | A Daily Walk with John Randall',
            'description': 'md5:fbb8f1cf21447ac54ecaa2887fc20c6e',
        }
    }, {
        'url': 'https://www.oneplace.com/ministries/ankerberg-show/listen/ep-3-relying-on-the-constant-companionship-of-the-holy-spirit-part-2-922513.html',
        'info_dict': {
            'id': '922513',
            'ext': 'mp3',
            'description': 'md5:8b810b4349aa40a5d033b4536fe428e1',
            'title': 'md5:ce10f7d8d5ddcf485ed8905ef109659d',
        }
    }]

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

        return {
            'id': video_id,
            'url': self._search_regex((
                r'mp3-url\s*=\s*"([^"]+)',
                r'<div[^>]+id\s*=\s*"player"[^>]+data-media-url\s*=\s*"(?P<media_url>[^"]+)',
            ), webpage, 'media url'),
            'ext': 'mp3',
            'vcodec': 'none',
            'title': self._html_search_regex((
                r'<div[^>]class\s*=\s*"details"[^>]+>[^<]<h2[^>]+>(?P<content>[^>]+)>',
                self._meta_regex('og:title'), self._meta_regex('title'),
            ), webpage, 'title', group='content', default=None),
            'description': self._html_search_regex(
                r'<div[^>]+class="[^"]+epDesc"[^>]*>\s*(?P<desc>.+?)\s*</div>',
                webpage, 'description', default=None),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/oneplace.py (Python)

Code before:
        'info_dict': {
            'id': '958461',
            'ext': 'mp3',
            'title': 'Living in the Last Days Part 2 | A Daily Walk with John Randall',
            'description': 'md5:fbb8f1cf21447ac54ecaa2887fc20c6e',
        }
    }]

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

        media_url = self._search_regex(r'mp3-url="([^"]+)', webpage, 'media_url', fatal=False) or self._search_regex(
            r'<div[^>]+id\s*=\s*"player"[^>]+data-media-url\s*=\s*"(?P<media_url>[^"]+)', webpage,
            'media_url')

        return {
            'id': video_id,
            'url': media_url,
            'title': clean_html(self._search_regex(
                r'<div[^>]class\s*=\s*"details"[^>]+>[^<]<h2[^>]+>(?P<title>[^>]+)>', webpage,
                'title', fatal=False, default=None)) or self._html_search_meta(['og:title', 'title'], webpage),
            'ext': 'mp3',
            'description': clean_html(self._search_regex(
                r'<div[^>]+class="[^"]+epDesc"[^>]*>\s*(?P<desc>.+)', webpage, 'description',
                fatal=False, default=None))
        }


Review comment (suggestion):
```suggestion
                r'<div[^>]+class="[^"]+epDesc"[^>]*>\s*(?P<desc>.+)', webpage, 'description', default=None))
```
default implies non-fatal

Code after:
            'id': '958461',
            'ext': 'mp3',
            'title': 'Living in the Last Days Part 2 | A Daily Walk with John Randall',
            'description': 'md5:fbb8f1cf21447ac54ecaa2887fc20c6e',
        }
    }, {
        'url': 'https://www.oneplace.com/ministries/ankerberg-show/listen/ep-3-relying-on-the-constant-companionship-of-the-holy-spirit-part-2-922513.html',
        'info_dict': {
            'id': '922513',
            'ext': 'mp3',
            'description': 'md5:8b810b4349aa40a5d033b4536fe428e1',
            'title': 'md5:ce10f7d8d5ddcf485ed8905ef109659d',
        }
    }]

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

        return {
            'id': video_id,
            'url': self._search_regex((
                r'mp3-url\s*=\s*"([^"]+)',
                r'<div[^>]+id\s*=\s*"player"[^>]+data-media-url\s*=\s*"(?P<media_url>[^"]+)',
            ), webpage, 'media url'),
            'ext': 'mp3',
            'vcodec': 'none',
            'title': self._html_search_regex((
                r'<div[^>]class\s*=\s*"details"[^>]+>[^<]<h2[^>]+>(?P<content>[^>]+)>',
                self._meta_regex('og:title'), self._meta_regex('title'),
            ), webpage, 'title', group='content', default=None),
            'description': self._html_search_regex(
                r'<div[^>]+class="[^"]+epDesc"[^>]*>\s*(?P<desc>.+?)\s*</div>',
                webpage, 'description', default=None),
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/kanal2.py (Python)

Code before:
# coding: utf-8
from __future__ import unicode_literals
from datetime import datetime
import re
import time
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    url_or_none,
    traverse_obj,
)


class Kanal2IE(InfoExtractor):
    SUBTITLE_DATE_RE = re.compile(r'\((\d{2}\.\d{2}\.\d{4}\s\d{2}:\d{2})\)$')

    _VALID_URL = r'https?://.+\.postimees\.ee/[^?]+\?(.*?&)?id=(?P<id>\d+)'
    _TESTS = [
        {
            'note': 'Test standard url (#5575)',
            'url': 'https://kanal2.postimees.ee/pluss/video/?id=40792',
            'md5': 'baf49cab468cf553bc1cf36909f1a0c7',
            'info_dict': {
                'id': '40792',
                'ext': 'mp4',
                'title': 'Aedniku aabits / Osa 53  (05.08.2016 20:00)',
                'thumbnail': r're:https?://.*\.jpg$',
                'description': 'md5:53cabf3c5d73150d594747f727431248',
                'upload_date': '20160805',
                'timestamp': 1470416400,
            }
        },
    ]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        playlist = self.get_playlist(video_id)

        info = {
            'id': video_id,

Review comment (suggestion):
one-time use var; use pattern inline instead
```suggestion
```

Code after:
from .common import InfoExtractor
from ..utils import (
    ExtractorError,
    join_nonempty,
    traverse_obj,
    unified_timestamp,
    update_url_query,
)


class Kanal2IE(InfoExtractor):
    _VALID_URL = r'https?://kanal2\.postimees\.ee/[^?#]+\?([^#]+&)?id=(?P<id>\d+)'
    _TESTS = [{
        'note': 'Test standard url (#5575)',
        'url': 'https://kanal2.postimees.ee/pluss/video/?id=40792',
        'md5': '7ea7b16266ec1798743777df241883dd',
        'info_dict': {
            'id': '40792',
            'ext': 'mp4',
            'title': 'Aedniku aabits / Osa 53  (05.08.2016 20:00)',
            'thumbnail': r're:https?://.*\.jpg$',
            'description': 'md5:53cabf3c5d73150d594747f727431248',
            'upload_date': '20160805',
            'timestamp': 1470420000,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        playlist = self._download_json(
            f'https://kanal2.postimees.ee/player/playlist/{video_id}',
            video_id, query={'type': 'episodes'},
            headers={'X-Requested-With': 'XMLHttpRequest'})

        return {
            'id': video_id,
            'title': join_nonempty(*traverse_obj(playlist, ('info', ('title', 'subtitle'))), delim=' / '),
            'description': traverse_obj(playlist, ('info', 'description')),
            'thumbnail': traverse_obj(playlist, ('data', 'image')),
            'formats': self.get_formats(playlist, video_id),
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/radioradicale.py (Python)

Code before:
from locale import LC_ALL, setlocale
from .common import InfoExtractor
from urllib.parse import urlparse
from re import sub
from datetime import datetime
from os.path import dirname


class RadioRadicaleIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?radioradicale\.it/scheda/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://www.radioradicale.it/scheda/471591',
        'info_dict': {
            'id': '471591',
            'ext': 'mp4',
            'title': 'md5:e8fbb8de57011a3255db0beca69af73d',
            'creator': 'Giuseppe Di Leo',
            'location': 'Napoli',
            'timestamp': 1460044800.0,
            'upload_date': '20160407',
            'description': 'md5:5e15a789a2fe4d67da8d1366996e89ef',
            'thumbnail': 'https://www.radioradicale.it/photo400/0/0/9/0/1/00901768.jpg',
        }
    }]

    def _real_extract(self, url):
        setlocale(LC_ALL, '')

        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)


Review comment (refactor):
```suggestion
import os.path
import re
import urllib.parse

from .common import InfoExtractor
```

* Sort imports
* Always import whole modules from stdlib

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


class RadioRadicaleIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?radioradicale\.it/scheda/(?P<id>[0-9]+)'
    _TESTS = [{
        'url': 'https://www.radioradicale.it/scheda/471591',
        'md5': 'eb0fbe43a601f1a361cbd00f3c45af4a',
        'info_dict': {
            'id': '471591',
            'ext': 'mp4',
            'title': 'md5:e8fbb8de57011a3255db0beca69af73d',
            'description': 'md5:5e15a789a2fe4d67da8d1366996e89ef',
            'location': 'Napoli',
            'duration': 2852.0,
            'timestamp': 1459987200,
            'upload_date': '20160407',
            'thumbnail': 'https://www.radioradicale.it/photo400/0/0/9/0/1/00901768.jpg',
        },
    }, {
        'url': 'https://www.radioradicale.it/scheda/742783/parlamento-riunito-in-seduta-comune-11a-della-xix-legislatura',
        'info_dict': {
            'id': '742783',
            'title': 'Parlamento riunito in seduta comune (11ª della XIX legislatura)',
            'description': '-) Votazione per l\'elezione di un giudice della Corte Costituzionale (nono scrutinio)',
            'location': 'CAMERA',
            'duration': 5868.0,
            'timestamp': 1730246400,
            'upload_date': '20241030',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/webcamerapl.py (Python)

Code before:
        'info_dict': {
            'id': 'warszawa-plac-zamkowy',
            'ext': 'mp4',
            'title': 'WIDOK NA PLAC ZAMKOWY W WARSZAWIE',
        }
    }, {
        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': 'GDAŃSK - widok na Stare Miasto'
        }
    }]

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

        title = self._html_search_regex(r'<h1.*?>(.+?)</h1>', webpage, 'title')

        rot13_m3u8_url = self._search_regex(r'data-src="(uggc.+?\.z3h8)"', webpage, 'm3u8 url', fatal=False)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url.', expected=True)
        m3u8_url = decode(rot13_m3u8_url, 'rot-13')

        formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'url': m3u8_url,
            'ext': 'mp4',
        }


Review comment (refactor):
We usually extract `subtitles` as well
```suggestion
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, ext='mp4')
```

Code after:
        'info_dict': {
            'id': 'warszawa-plac-zamkowy',
            'ext': 'mp4',
            'title': r're:WIDOK NA PLAC ZAMKOWY W WARSZAWIE \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
            'live_status': 'is_live',
        }
    }, {
        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': r're:GDAŃSK - widok na Stare Miasto \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
            'live_status': 'is_live',
        }
    }]

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

        rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
                                            webpage, 'm3u8 url', default=None)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url', expected=True)

        m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)

        return {
            'id': video_id,
            'title': self._html_search_regex(r'<h1\b[^>]*>([^>]+)</h1>', webpage, 'title'),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': True,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/webcamerapl.py (Python)

Code before:
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': 'GDAŃSK - widok na Stare Miasto'
        }
    }]

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

        title = self._html_search_regex(r'<h1.*?>(.+?)</h1>', webpage, 'title')

        rot13_m3u8_url = self._search_regex(r'data-src="(uggc.+?\.z3h8)"', webpage, 'm3u8 url', fatal=False)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url.', expected=True)
        m3u8_url = decode(rot13_m3u8_url, 'rot-13')

        formats = self._extract_m3u8_formats(m3u8_url, video_id, ext='mp4')

        return {
            'id': video_id,
            'title': title,
            'formats': formats,
            'url': m3u8_url,
            'ext': 'mp4',
        }


Review comment (refactor):
If formats already extracted, it not necessary to set `url` and `ext` field, as this information already in `formats` field
```suggestion
```

Code after:
        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': r're:GDAŃSK - widok na Stare Miasto \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
            'live_status': 'is_live',
        }
    }]

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

        rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
                                            webpage, 'm3u8 url', default=None)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url', expected=True)

        m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)

        return {
            'id': video_id,
            'title': self._html_search_regex(r'<h1\b[^>]*>([^>]+)</h1>', webpage, 'title'),
            'formats': formats,
            'subtitles': subtitles,
            'is_live': True,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/webcamerapl.py (Python)

Code before:
import codecs

from .common import InfoExtractor


class WebcameraplIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<id>[\w-]+)\.webcamera\.pl'
    _TESTS = [{
        'url': 'https://warszawa-plac-zamkowy.webcamera.pl',
        'info_dict': {
            'id': 'warszawa-plac-zamkowy',
            'ext': 'mp4',
            'title': 'WIDOK NA PLAC ZAMKOWY W WARSZAWIE',
        }
    }, {
        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': 'GDAŃSK - widok na Stare Miasto',
        }
    }]

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

        rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
                                            webpage, 'm3u8 url', default=None)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url', expected=True)

        m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)

        return {
            'id': video_id,
            'title': self._html_search_regex(r'<h1\b[^>]*>([^>]+)</h1>', webpage, 'title'),

Review comment (suggestion):
```suggestion
            'title': r're:WIDOK NA PLAC ZAMKOWY W WARSZAWIE \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
```
yt-dlp adds timestamp to title for livestreams. Do same for the other test

Code after:
import codecs

from .common import InfoExtractor


class WebcameraplIE(InfoExtractor):
    _VALID_URL = r'https?://(?P<id>[\w-]+)\.webcamera\.pl'
    _TESTS = [{
        'url': 'https://warszawa-plac-zamkowy.webcamera.pl',
        'info_dict': {
            'id': 'warszawa-plac-zamkowy',
            'ext': 'mp4',
            'title': r're:WIDOK NA PLAC ZAMKOWY W WARSZAWIE \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
            'live_status': 'is_live',
        }
    }, {
        'url': 'https://gdansk-stare-miasto.webcamera.pl/',
        'info_dict': {
            'id': 'gdansk-stare-miasto',
            'ext': 'mp4',
            'title': r're:GDAŃSK - widok na Stare Miasto \d{4}-\d{2}-\d{2} \d{2}:\d{2}$',
            'live_status': 'is_live',
        }
    }]

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

        rot13_m3u8_url = self._search_regex(r'data-src\s*=\s*"(uggc[^"]+\.z3h8)"',
                                            webpage, 'm3u8 url', default=None)
        if not rot13_m3u8_url:
            self.raise_no_formats('No video/audio found at the provided url', expected=True)

        m3u8_url = codecs.decode(rot13_m3u8_url, 'rot-13')
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id, live=True)

        return {