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

Code before:
            'id': 898,
            'title': 'AZ-500: Microsoft Azure Security Technologies',
            'description': 'md5:69549d379c0fc1dec92926d4e8b6fbd4'
        },
        'playlist_count': 59
    }, {
        'url': 'https://app.cybrary.it/browse/course/cybrary-orientation',
        'info_dict': {
            'id': 1245,
            'title': 'Cybrary Orientation',
            'description': 'md5:9e69ff66b32fe78744e0ad4babe2e88e'
        },
        'playlist_count': 4
    }]

    def _real_extract(self, url):
        course_id = self._match_id(url)
        course = self._call_api('course', course_id)
        enrollment_info = self._call_api('course_enrollment', course['id'])

        entries = [self.url_result(
            f'https://app.cybrary.it/immersive/{enrollment_info["id"]}/activity/{activity["id"]}')
            for activity in traverse_obj(course, ('content_item', 'learning_modules', ..., 'activities', ...))]

        return self.playlist_result(
            entries, traverse_obj(course, ('content_item', 'id')), course.get('title'), course.get('short_description'))


Review comment (suggestion):
```suggestion
        return self.playlist_result(
            entries,
            traverse_obj(course, ('content_item', 'id'), expected_type=str_or_none),
            course.get('title'), course.get('short_description'))
```
id shouldn't be a number

Code after:
        },
        'playlist_count': 59
    }, {
        'url': 'https://app.cybrary.it/browse/course/cybrary-orientation',
        'info_dict': {
            'id': 1245,
            'title': 'Cybrary Orientation',
            'description': 'md5:9e69ff66b32fe78744e0ad4babe2e88e'
        },
        'playlist_count': 4
    }]

    def _real_extract(self, url):
        course_id = self._match_id(url)
        course = self._call_api('course', course_id)
        enrollment_info = self._call_api('course_enrollment', course['id'])

        entries = [self.url_result(
            f'https://app.cybrary.it/immersive/{enrollment_info["id"]}/activity/{activity["id"]}')
            for activity in traverse_obj(course, ('content_item', 'learning_modules', ..., 'activities', ...))]

        return self.playlist_result(
            entries,
            traverse_obj(course, ('content_item', 'id'), expected_type=str_or_none),
            course.get('title'), course.get('short_description'))
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/moviepilot.py (Python)

Code before:
# coding: utf-8
from __future__ import unicode_literals

from .common import InfoExtractor
from ..utils import (
    int_or_none,
    parse_duration,
    parse_iso8601,
    unescapeHTML,
)


class MoviepilotIE(InfoExtractor):
    _IE_NAME = "moviepilot"
    _IE_DESC = "Moviepilot trailer"
    _VALID_URL = r'https?://(?:www\.)?moviepilot\.de/movies/(?P<id>[^/]+)/?.*'

    _TESTS = [{
        'url': 'https://www.moviepilot.de/movies/interstellar-2/',
        'info_dict': {
            # 'id': 'interstellar-2',
            'id': 'x7xdut5',
            'ext': 'mp4',
            'title': 'Interstellar',
            'thumbnail': 'https://s1.dmcdn.net/v/SaXev1VvzitVZMFsR/x720',
            'timestamp': 1400491705,
            'description': 'md5:7dfc5c1758e7322a7346934f1f0c489c',
            # coming from Dailymotion
            'uploader': 'Moviepilot',
            'like_count': int,
            'view_count': int,
            'uploader_id': 'x6nd9k',
            'upload_date': '20140519',
            'duration': 140,
            'age_limit': 0,
            'tags': ['Alle Trailer', 'Movie', 'Third Party'],
        },
    }, {
        'url': 'https://www.moviepilot.de/movies/interstellar-2',
        'only_matching': True,
    }, {

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?moviepilot\.de/movies/(?P<id>[^/]+)'
```
it doesnt do anything

Code after:
# coding: utf-8
from __future__ import unicode_literals

from .dailymotion import DailymotionIE
from .common import InfoExtractor
from ..utils import (
    parse_iso8601,
    try_get,
)

import re


class MoviepilotIE(InfoExtractor):
    _IE_NAME = 'moviepilot'
    _IE_DESC = 'Moviepilot trailer'
    _VALID_URL = r'https?://(?:www\.)?moviepilot\.de/movies/(?P<id>[^/]+)'

    _TESTS = [{
        'url': 'https://www.moviepilot.de/movies/interstellar-2/',
        'info_dict': {
            'id': 'x7xdut5',
            'display_id': 'interstellar-2',
            'ext': 'mp4',
            'title': 'Interstellar',
            'thumbnail': r're:https://\w+\.dmcdn\.net/v/SaXev1VvzitVZMFsR/x720',
            'timestamp': 1400491705,
            'description': 'md5:7dfc5c1758e7322a7346934f1f0c489c',
            'uploader': 'Moviepilot',
            'like_count': int,
            'view_count': int,
            'uploader_id': 'x6nd9k',
            'upload_date': '20140519',
            'duration': 140,
            'age_limit': 0,
            'tags': ['Alle Trailer', 'Movie', 'Third Party'],
        },
    }, {
        'url': 'https://www.moviepilot.de/movies/interstellar-2/trailer',
        'only_matching': True,
    }, {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/moviepilot.py (Python)

Code before:
            'view_count': int,
            'tags': ['Alle Trailer', 'Movie', 'Verleih'],
            'uploader_id': 'x6nd9k',
        },
    }]

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

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
        # _html_search_meta is not used since we don't want name=description to match
        description = unescapeHTML(
            self._search_regex(f'meta itemprop="description" content="(.*?)"', webpage, 'description', fatal=False))

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._html_search_meta('embedURL', webpage),
            'thumbnail': self._html_search_meta('thumbnailURL', webpage, fatal=False),
            'description': description,
            'duration': duration,
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage, fatal=False), delimiter=' ')
        }


Review comment (suggestion):
```suggestion
            'thumbnail': self._html_search_meta('thumbnailURL', webpage),
```
that is the default!

Code after:
            'tags': ['Alle Trailer', 'Movie', 'Verleih'],
            'uploader_id': 'x6nd9k',
        },
    }]

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

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
        # _html_search_meta is not used since we don't want name=description to match
        description = self._html_search_regex(
            '<meta[^>]+itemprop="description"[^>]+content="([^>"]+)"', webpage, 'description', fatal=False)

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._html_search_meta('embedURL', webpage),
            'thumbnail': self._html_search_meta('thumbnailURL', webpage),
            'description': description,
            'duration': duration,
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), delimiter=' ')
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/moviepilot.py (Python)

Code before:
        },
    }]

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

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
        # _html_search_meta is not used since we don't want name=description to match
        description = unescapeHTML(
            self._search_regex(f'meta itemprop="description" content="(.*?)"', webpage, 'description', fatal=False))

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._html_search_meta('embedURL', webpage),
            'thumbnail': self._html_search_meta('thumbnailURL', webpage, fatal=False),
            'description': description,
            'duration': duration,
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage, fatal=False), delimiter=' ')
        }


Review comment (suggestion):
```suggestion
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), delimiter=' ')
```

Code after:
    }]

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

        webpage = self._download_webpage(f'https://www.moviepilot.de/movies/{video_id}/trailer', video_id)

        duration = try_get(
            re.match(r'P(?P<hours>\d+)H(?P<mins>\d+)M(?P<secs>\d+)S',
                     self._html_search_meta('duration', webpage, fatal=False) or ''),
            lambda mobj: sum(float(x) * y for x, y in zip(mobj.groups(), (3600, 60, 1))))
        # _html_search_meta is not used since we don't want name=description to match
        description = self._html_search_regex(
            '<meta[^>]+itemprop="description"[^>]+content="([^>"]+)"', webpage, 'description', fatal=False)

        return {
            '_type': 'url_transparent',
            'ie_key': DailymotionIE.ie_key(),
            'display_id': video_id,
            'title': self._og_search_title(webpage),
            'url': self._html_search_meta('embedURL', webpage),
            'thumbnail': self._html_search_meta('thumbnailURL', webpage),
            'description': description,
            'duration': duration,
            'timestamp': parse_iso8601(self._html_search_meta('uploadDate', webpage), delimiter=' ')
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/gronkh.py (Python)

Code before:
            for item in traverse_obj(info, ('discovery', ...)) or []:
                yield self.url_result(f'https://gronkh.tv/watch/stream/{item.get("episode")}', GronkhIE, item.get('title'))

    def _real_extract(self, url):
        return self.playlist_result(self._entries(), 'feed', 'feed', 'feed')


class GronkhVodsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?gronkh\.tv/vods/streams/?(?:#|$)'
    IE_NAME = 'gronkh:vods'

    _TESTS = [{
        'url': 'https://gronkh.tv/vods/streams',
        'info_dict': {
            'id': 'vods',
        },
        'playlist_mincount': 150,
    }]
    _PER_PAGE = 25

    def _fetch_page(self, page):
        items = traverse_obj(self._download_json(
            'https://api.gronkh.tv/v1/search', 'vods', query={'offset': self._PER_PAGE * page, 'first': self._PER_PAGE},
            note=f'Downloading stream video page {page + 1}'), ('results', 'videos', ...))
        for item in items or []:
            yield self.url_result(f'https://gronkh.tv/watch/stream/{item.get("episode")}', GronkhIE, item.get("episode"), item.get('title'))

    def _real_extract(self, url):
        entries = OnDemandPagedList(functools.partial(self._fetch_page), self._PER_PAGE)
        return self.playlist_result(entries, 'vods', 'vods', 'vods')


Review comment (suggestion):
```suggestion
            yield self.url_result(f'https://gronkh.tv/watch/stream/{item["episode"]}', GronkhIE, item['episode'], item.get('title'))
```
same issue above

Code after:
            for item in traverse_obj(info, ('discovery', ...)) or []:
                yield self.url_result(f'https://gronkh.tv/watch/stream/{item["episode"]}', GronkhIE, item.get('title'))

    def _real_extract(self, url):
        return self.playlist_result(self._entries(), 'feed')


class GronkhVodsIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?gronkh\.tv/vods/streams/?(?:#|$)'
    IE_NAME = 'gronkh:vods'

    _TESTS = [{
        'url': 'https://gronkh.tv/vods/streams',
        'info_dict': {
            'id': 'vods',
        },
        'playlist_mincount': 150,
    }]
    _PER_PAGE = 25

    def _fetch_page(self, page):
        items = traverse_obj(self._download_json(
            'https://api.gronkh.tv/v1/search', 'vods', query={'offset': self._PER_PAGE * page, 'first': self._PER_PAGE},
            note=f'Downloading stream video page {page + 1}'), ('results', 'videos', ...))
        for item in items or []:
            yield self.url_result(f'https://gronkh.tv/watch/stream/{item["episode"]}', GronkhIE, item['episode'], item.get('title'))

    def _real_extract(self, url):
        entries = OnDemandPagedList(functools.partial(self._fetch_page), self._PER_PAGE)
        return self.playlist_result(entries, 'vods')
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/masters.py (Python)

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


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/[\d]{4}-[\d]{2}-[\d]{2}/(?P<id>[0-9]+)/(.*)\.html'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    _CONTENT_API_URL = "https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en"

    def _real_extract(self, url):
        video_id = self._match_id(url)
        content_resp = self._download_json(self._CONTENT_API_URL.format(video_id=video_id), video_id)
        formats = self._extract_m3u8_formats(content_resp['media']['m3u8'], video_id, 'mp4')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': content_resp["title"],
            'formats': formats,
            'thumbnail': url_or_none(content_resp['images'][0]['large']),
        }


Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/)?P<date>\d{4}-\d{2}-\d{2})/(?P<id>\d+)'
```

Code after:
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
    traverse_obj,
    unified_strdate,
)


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/(?P<date>\d{4}-\d{2}-\d{2})/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'upload_date': '20220407',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    def _real_extract(self, url):
        video_id, upload_date = self._match_valid_url(url).group('id', 'date')
        content_resp = self._download_json(
            f'https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en',
            video_id)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(traverse_obj(content_resp, ('media', 'm3u8')), video_id, 'mp4')
        self._sort_formats(formats)

        thumbnails = [{'id': name, 'url': url} for name, url in traverse_obj(content_resp, ('images', 0), default={}).items()]

        return {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/masters.py (Python)

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


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/[\d]{4}-[\d]{2}-[\d]{2}/(?P<id>[0-9]+)/(.*)\.html'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    _CONTENT_API_URL = "https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en"

    def _real_extract(self, url):
        video_id = self._match_id(url)
        content_resp = self._download_json(self._CONTENT_API_URL.format(video_id=video_id), video_id)
        formats = self._extract_m3u8_formats(content_resp['media']['m3u8'], video_id, 'mp4')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': content_resp["title"],
            'formats': formats,
            'thumbnail': url_or_none(content_resp['images'][0]['large']),
        }


Review comment (suggestion):
```suggestion
        content_resp = self._download_json(
            f'https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en',
            video_id)
```

Code after:
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
    traverse_obj,
    unified_strdate,
)


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/(?P<date>\d{4}-\d{2}-\d{2})/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'upload_date': '20220407',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    def _real_extract(self, url):
        video_id, upload_date = self._match_valid_url(url).group('id', 'date')
        content_resp = self._download_json(
            f'https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en',
            video_id)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(traverse_obj(content_resp, ('media', 'm3u8')), video_id, 'mp4')
        self._sort_formats(formats)

        thumbnails = [{'id': name, 'url': url} for name, url in traverse_obj(content_resp, ('images', 0), default={}).items()]

        return {
            'id': video_id,
            'title': content_resp.get('title'),
            'formats': formats,
            'subtitles': subtitles,
            'upload_date': unified_strdate(upload_date),
            'thumbnails': thumbnails,
        }
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/masters.py (Python)

Code before:
from ..utils import url_or_none


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/[\d]{4}-[\d]{2}-[\d]{2}/(?P<id>[0-9]+)/(.*)\.html'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    _CONTENT_API_URL = "https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en"

    def _real_extract(self, url):
        video_id = self._match_id(url)
        content_resp = self._download_json(self._CONTENT_API_URL.format(video_id=video_id), video_id)
        formats = self._extract_m3u8_formats(content_resp['media']['m3u8'], video_id, 'mp4')
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': content_resp["title"],
            'formats': formats,
            'thumbnail': url_or_none(content_resp['images'][0]['large']),
        }


Review comment (suggestion):
```suggestion
            'title': content_resp.get('title'),
```

Code after:
from ..utils import (
    traverse_obj,
    unified_strdate,
)


class MastersIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?masters\.com/en_US/watch/(?P<date>\d{4}-\d{2}-\d{2})/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.masters.com/en_US/watch/2022-04-07/16493755593805191/sungjae_im_thursday_interview_2022.html',
        'info_dict': {
            'id': '16493755593805191',
            'ext': 'mp4',
            'title': 'Sungjae Im: Thursday Interview 2022',
            'upload_date': '20220407',
            'thumbnail': r're:^https?://.*\.jpg$',
        }
    }]

    def _real_extract(self, url):
        video_id, upload_date = self._match_valid_url(url).group('id', 'date')
        content_resp = self._download_json(
            f'https://www.masters.com/relatedcontent/rest/v2/masters_v1/en/content/masters_v1_{video_id}_en',
            video_id)
        formats, subtitles = self._extract_m3u8_formats_and_subtitles(traverse_obj(content_resp, ('media', 'm3u8')), video_id, 'mp4')
        self._sort_formats(formats)

        thumbnails = [{'id': name, 'url': url} for name, url in traverse_obj(content_resp, ('images', 0), default={}).items()]

        return {
            'id': video_id,
            'title': content_resp.get('title'),
            'formats': formats,
            'subtitles': subtitles,
            'upload_date': unified_strdate(upload_date),
            'thumbnails': thumbnails,
        }