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

Code before:
            'ext': 'mp4',
            'title': 'Bundesrats-Vakanzen / EU-Rahmenabkommen',
            'uploader_id': 'TVOnline',
            'upload_date': '20180930',
            'timestamp': 1538328802,
            'view_count': int,
            'thumbnail': 'http://cfvod.kaltura.com/p/1719221/sp/171922100/thumbnail/entry_id/1_anruz3wy/version/100031',
            'duration': 1930,
        },
        'params': {
            'skip_download': True,
        },
    }, {
        'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
        'only_matching': True,
    }]
    _PARTNER_ID = '1719221'

    def _real_extract(self, url):
        display_id, entry_id = self._match_valid_url(url).groups()

        if not entry_id:
            webpage = self._download_webpage(url, display_id)
            data = self._search_json(
                r'window\.__APOLLO_STATE__\s*=', webpage, 'video data',
                display_id)
            entry_id = traverse_obj(data, (
                lambda _, v: v.get('__typename') == 'KalturaData',
                'kalturaId',
            ), get_all=False)
            if not entry_id:
                raise ExtractorError('Could not extract kaltura id')

        return self.url_result(
            f'kaltura:{self._PARTNER_ID}:{entry_id}',
            ie=KalturaIE.ie_key(), video_id=entry_id)


Review comment (suggestion):
just formatting
```suggestion
            data = self._search_json(
                r'window\.__APOLLO_STATE__\s*=', webpage, 'video data', display_id)
```

Code after:
            'upload_date': '20180930',
            'timestamp': 1538328802,
            'view_count': int,
            'thumbnail': 'http://cfvod.kaltura.com/p/1719221/sp/171922100/thumbnail/entry_id/1_anruz3wy/version/100031',
            'duration': 1930,
        },
        'params': {
            'skip_download': True,
        },
    }, {
        'url': 'https://www.telebaern.tv/telebaern-news/montag-1-oktober-2018-ganze-sendung-133531189#video=0_7xjo9lf1',
        'only_matching': True,
    }]
    _PARTNER_ID = '1719221'

    def _real_extract(self, url):
        display_id, entry_id = self._match_valid_url(url).groups()

        if not entry_id:
            webpage = self._download_webpage(url, display_id)
            data = self._search_json(
                r'window\.__APOLLO_STATE__\s*=', webpage, 'video data', display_id)
            entry_id = traverse_obj(data, (
                lambda _, v: v['__typename'] == 'KalturaData', 'kalturaId', any, {require('kaltura id')}))

        return self.url_result(
            f'kaltura:{self._PARTNER_ID}:{entry_id}',
            ie=KalturaIE.ie_key(), video_id=entry_id)
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/azmedien.py (Python)

Code before:
from .common import InfoExtractor
from .kaltura import KalturaIE
from ..utils import (
    ExtractorError,
    traverse_obj,
)


class AZMedienIE(InfoExtractor):
    IE_DESC = 'AZ Medien videos'
    _VALID_URL = r'''(?x)
                    https?://
                        (?:www\.|tv\.)?
                        (?:
                            telezueri\.ch|
                            telebaern\.tv|
                            telem1\.ch|
                            tvo-online\.ch
                        )/
                        [^/]+/
                        (?P<id>
                            [^/]+-\d+
                        )
                        (?:
                            \#video=
                            (?P<kaltura_id>
                                [_0-9a-z]+
                            )
                        )?
                    '''


Review comment (suggestion):
```suggestion
from ..utils.traversal import require, traverse_obj
```

Code after:
from .common import InfoExtractor
from .kaltura import KalturaIE
from ..utils.traversal import require, traverse_obj


class AZMedienIE(InfoExtractor):
    IE_DESC = 'AZ Medien videos'
    _VALID_URL = r'''(?x)
                    https?://
                        (?:www\.|tv\.)?
                        (?:
                            telezueri\.ch|
                            telebaern\.tv|
                            telem1\.ch|
                            tvo-online\.ch
                        )/
                        [^/?#]+/
                        (?P<id>
                            [^/?#]+-\d+
                        )
                        (?:
                            \#video=
                            (?P<kaltura_id>
                                [_0-9a-z]+
                            )
                        )?
                    '''

    _TESTS = [{
        'url': 'https://tv.telezueri.ch/sonntalk/bundesrats-vakanzen-eu-rahmenabkommen-133214569',
        'info_dict': {
Repository: yt-dlp/yt-dlp
File: devscripts/make_supportedsites.py (Python)

Code before:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently part of yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp due to embed extraction or the generic extractor.
Not all sites listed here are guaranteed to work. If websites change the extractor might stop working.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()


Review comment (refactor):
```suggestion
If a site is not listed here, it might still be supported by yt-dlp's embed extraction or generic extractor.
```

Code after:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently included with yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp's embed extraction or generic extractor.
Not all sites listed here are guaranteed to work; websites are constantly changing and sometimes this breaks yt-dlp's support for them.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()
Repository: yt-dlp/yt-dlp
File: devscripts/make_supportedsites.py (Python)

Code before:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently part of yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp due to embed extraction or the generic extractor.
Not all sites listed here are guaranteed to work. If websites change the extractor might stop working.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()


Review comment (suggestion):
```suggestion
Not all sites listed here are guaranteed to work; websites are constantly changing and sometimes this breaks yt-dlp's support for them.
```

Code after:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently included with yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp's embed extraction or generic extractor.
Not all sites listed here are guaranteed to work; websites are constantly changing and sometimes this breaks yt-dlp's support for them.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()
Repository: yt-dlp/yt-dlp
File: devscripts/make_supportedsites.py (Python)

Code before:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently part of yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp due to embed extraction or the generic extractor.
Not all sites listed here are guaranteed to work. If websites change the extractor might stop working.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()


Review comment (refactor):
```suggestion
Below is a list of all extractors that are currently included with yt-dlp.
```

Code after:
#!/usr/bin/env python3

# Allow direct execution
import os
import sys

sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


from devscripts.utils import get_filename_args, write_file
from yt_dlp.extractor import list_extractor_classes

TEMPLATE = '''\
# Supported sites

Below is a list of all extractors that are currently included with yt-dlp.
If a site is not listed here, it might still be supported by yt-dlp's embed extraction or generic extractor.
Not all sites listed here are guaranteed to work; websites are constantly changing and sometimes this breaks yt-dlp's support for them.
The only reliable way to check if a site is supported is to try it.

{ie_list}
'''


def main():
    out = '\n'.join(ie.description() for ie in list_extractor_classes() if ie.IE_DESC is not False)
    write_file(get_filename_args(), TEMPLATE.format(ie_list=out))


if __name__ == '__main__':
    main()
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/wsj.py (Python)

Code before:
import re

from .common import InfoExtractor
from ..utils import (
    float_or_none,
    int_or_none,
    join_nonempty,
    unified_strdate,
)


class WSJIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            https?://video-api\.wsj\.com/api-video/player/iframe\.html\?.*?\bguid=|
                            https?://(?:www\.)?(?:wsj|barrons)\.com/video/(?:[^/]+/)+|
                            wsj:
                        )
                        (?P<id>[a-fA-F0-9-]{36})
                    '''
    IE_DESC = 'Wall Street Journal'
    _TESTS = [{
        'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
        'md5': 'e230a5bb249075e40793b655a54a02e4',
        'info_dict': {
            'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
            'ext': 'mp4',
            'upload_date': '20150202',

Review comment (refactor):
revert pt.3
```suggestion
from .common import InfoExtractor
```

Code after:
from .common import InfoExtractor
from ..utils import (
    float_or_none,
    int_or_none,
    join_nonempty,
    unified_strdate,
)


class WSJIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        (?:
                            https?://video-api\.wsj\.com/api-video/player/iframe\.html\?.*?\bguid=|
                            https?://(?:www\.)?(?:wsj|barrons)\.com/video/(?:[^/]+/)+|
                            wsj:
                        )
                        (?P<id>[a-fA-F0-9-]{36})
                    '''
    IE_DESC = 'Wall Street Journal'
    _TESTS = [{
        'url': 'http://video-api.wsj.com/api-video/player/iframe.html?guid=1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
        'md5': 'e230a5bb249075e40793b655a54a02e4',
        'info_dict': {
            'id': '1BD01A4C-BFE8-40A5-A42F-8A8AF9898B1A',
            'ext': 'mp4',
            'upload_date': '20150202',
            'uploader_id': 'jdesai',
            'creator': 'jdesai',
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/playsuisse.py (Python)

Code before:
        },
    ]

    _GRAPHQL_QUERY = '''
        query AssetWatch($assetId: ID!) {
            assetV2(id: $assetId) {
                ...Asset
                episodes {
                    ...Asset
                }
            }
        }
        fragment Asset on AssetV2 {
            id
            name
            description
            descriptionLong
            year
            contentTypes
            countries
            composers
            directors
            writers
            mainCast
            productionCompanies
            productionCountries
            duration
            episodeNumber
            seasonNumber
            seriesName
            medias {
                type
                url
            }
            thumbnail16x9 {
                ...ImageDetails
            }
            thumbnail2x3 {
                ...ImageDetails
            }
            thumbnail16x9WithTitle {
                ...ImageDetails
            }
            thumbnail2x3WithTitle {
                ...ImageDetails
            }
        }
        fragment ImageDetails on AssetImage {
            id
            url
        }'''

Review comment (refactor):
yt-dlp's graphql queries are intentionally kept as lean as possible. Don't add fields we aren't using in the extractor code
```suggestion
            descriptionLong
            year
            contentTypes
            directors
            mainCast
            productionCountries
```

Code after:
                    'episode': 'Folge 3',
                    'episode_number': 3,
                    'id': '1112664',
                    'season': 'Season 1',
                    'season_number': 1,
                    'series': 'They all came out to Montreux',
                    'thumbnail': 're:https://playsuisse-img.akamaized.net/',
                    'title': 'Folge 3',
                    'ext': 'mp4',
                },
            }],
        },
    ]

    _GRAPHQL_QUERY = '''
        query AssetWatch($assetId: ID!) {
            assetV2(id: $assetId) {
                ...Asset
                episodes {
                    ...Asset
                }
            }
        }
        fragment Asset on AssetV2 {
            id
            name
            description
            descriptionLong
            year
            contentTypes
            directors
            mainCast
            productionCountries
            duration
            episodeNumber
            seasonNumber
            seriesName
            medias {
                type
                url
            }
            thumbnail16x9 {
                ...ImageDetails
            }
            thumbnail2x3 {
                ...ImageDetails
            }
            thumbnail16x9WithTitle {
                ...ImageDetails
            }
            thumbnail2x3WithTitle {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/blackboardcollaborate.py (Python)

Code before:
import base64
import json

from .common import InfoExtractor
from ..utils import (
    int_or_none,
    mimetype2ext,
    parse_iso8601,
    parse_qs,
    str_or_none,
    url_or_none,
)
from ..utils.traversal import traverse_obj

'''APIs references - Blackboard Learn: https://developer.blackboard.com/portal/displayApi
                   - Blackboard Collaborate: https://github.com/blackboard/BBDN-Collab-Postman-REST'''


class BlackboardCollaborateIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        https?://
                        (?P<region>[a-z]+)(?:-lti)?\.bbcollab\.com/
                        (?:
                            collab/ui/session/playback/load|
                            recording
                        )/
                        (?P<id>[^/\?]+)
                        \??(authToken=(?P<token>[\w\.\-]+))?'''
    _TESTS = [
        {
            'url': 'https://us-lti.bbcollab.com/collab/ui/session/playback/load/0a633b6a88824deb8c918f470b22b256',
            'md5': 'bb7a055682ee4f25fdb5838cdf014541',
            'info_dict': {
                'id': '0a633b6a88824deb8c918f470b22b256',
                'title': 'HESI A2 Information Session - Thursday, May 6, 2021 - recording_1',
                'ext': 'mp4',
                'duration': 1896,
                'timestamp': 1620333295,
                'upload_date': '20210506',
                'subtitles': {
                    'live_chat': 'mincount:1',

Review comment (refactor):
It's not clear what "Blackboard Learn" is; if this is for a future PR please remove this and save it for the future PR

I'd move the "Blackboard Collaborate" ref as a comment on the `_call_api` method

Code after:
from .common import InfoExtractor
from ..utils import (
    UnsupportedError,
    float_or_none,
    int_or_none,
    join_nonempty,
    jwt_decode_hs256,
    mimetype2ext,
    parse_iso8601,
    parse_qs,
    url_or_none,
)
from ..utils.traversal import traverse_obj


class BlackboardCollaborateIE(InfoExtractor):
    _VALID_URL = r'''(?x)
                        https?://
                        (?P<region>[a-z]+)(?:-lti)?\.bbcollab\.com/
                        (?:
                            collab/ui/session/playback/load|
                            recording
                        )/
                        (?P<id>[^/?#]+)'''
    _TESTS = [
        {
            'url': 'https://us-lti.bbcollab.com/collab/ui/session/playback/load/0a633b6a88824deb8c918f470b22b256',
            'md5': 'bb7a055682ee4f25fdb5838cdf014541',
            'info_dict': {
                'id': '0a633b6a88824deb8c918f470b22b256',
                'title': 'HESI A2 Information Session - Thursday, May 6, 2021 - recording_1',
                'ext': 'mp4',
                'duration': 1896,
                'timestamp': 1620333295,
                'upload_date': '20210506',
                'subtitles': {
                    'live_chat': 'mincount:1',
                },
            },
        },
        {
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/canalsurmas.py (Python)

Code before:
import json

from .common import InfoExtractor
from ..networking.common import Request


class CanalsurmasExtractorIE(InfoExtractor):
    _VALID_URL = r'https://www.canalsurmas.es/videos/(?P<id>[0-9]*)-.*'

    _TESTS = [
        {
            'url': 'https://www.canalsurmas.es/videos/44006-el-gran-queo-1-lora-del-rio-sevilla-20072014',
            'md5': '861f86fdc1221175e15523047d0087ef',
            'info_dict': {
                'id': '44006',
                'ext': 'mp4',
                'title': 'Lora del Río (Sevilla)  ',
                'description': 'md5:3d9ee40a9b1b26ed8259e6b71ed27b8b',
            },
        },
    ]

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

        access_token = self._download_json(
            Request(
                url='https://api-rtva.interactvty.com/jwt/token/',
                method='POST',
                headers={
                    'Content-Type': 'application/json',
                },
                data=json.dumps(

Review comment (suggestion):
```suggestion
    _VALID_URL = r'https?://(?:www\.)?canalsurmas\.es/videos/(?P<id>\d+)'
```

Code after:
import json
import time

from .common import InfoExtractor
from ..utils import (
    determine_ext,
    float_or_none,
    jwt_decode_hs256,
    parse_iso8601,
    url_or_none,
    variadic,
)
from ..utils.traversal import traverse_obj


class CanalsurmasIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?canalsurmas\.es/videos/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.canalsurmas.es/videos/44006-el-gran-queo-1-lora-del-rio-sevilla-20072014',
        'md5': '861f86fdc1221175e15523047d0087ef',
        'info_dict': {
            'id': '44006',
            'ext': 'mp4',
            'title': 'Lora del Río (Sevilla)',
            'description': 'md5:3d9ee40a9b1b26ed8259e6b71ed27b8b',
            'thumbnail': 'https://cdn2.rtva.interactvty.com/content_cards/00f3e8f67b0a4f3b90a4a14618a48b0d.jpg',
            'timestamp': 1648123182,
            'upload_date': '20220324',
        },
    }]
    _API_BASE = 'https://api-rtva.interactvty.com'
    _access_token = None
Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/canalsurmas.py (Python)

Code before:
import json

from .common import InfoExtractor
from ..networking.common import Request


class CanalsurmasExtractorIE(InfoExtractor):
    _VALID_URL = r'https://www.canalsurmas.es/videos/(?P<id>[0-9]*)-.*'

    _TESTS = [
        {
            'url': 'https://www.canalsurmas.es/videos/44006-el-gran-queo-1-lora-del-rio-sevilla-20072014',
            'md5': '861f86fdc1221175e15523047d0087ef',
            'info_dict': {
                'id': '44006',
                'ext': 'mp4',
                'title': 'Lora del Río (Sevilla)  ',
                'description': 'md5:3d9ee40a9b1b26ed8259e6b71ed27b8b',
            },
        },
    ]

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

        access_token = self._download_json(
            Request(
                url='https://api-rtva.interactvty.com/jwt/token/',
                method='POST',
                headers={
                    'Content-Type': 'application/json',
                },

Review comment (refactor):
```suggestion
class CanalsurmasIE(InfoExtractor):
```

Code after:
import json
import time

from .common import InfoExtractor
from ..utils import (
    determine_ext,
    float_or_none,
    jwt_decode_hs256,
    parse_iso8601,
    url_or_none,
    variadic,
)
from ..utils.traversal import traverse_obj


class CanalsurmasIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?canalsurmas\.es/videos/(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.canalsurmas.es/videos/44006-el-gran-queo-1-lora-del-rio-sevilla-20072014',
        'md5': '861f86fdc1221175e15523047d0087ef',
        'info_dict': {
            'id': '44006',
            'ext': 'mp4',
            'title': 'Lora del Río (Sevilla)',
            'description': 'md5:3d9ee40a9b1b26ed8259e6b71ed27b8b',
            'thumbnail': 'https://cdn2.rtva.interactvty.com/content_cards/00f3e8f67b0a4f3b90a4a14618a48b0d.jpg',
            'timestamp': 1648123182,
            'upload_date': '20220324',
        },
    }]
    _API_BASE = 'https://api-rtva.interactvty.com'
    _access_token = None