Repository: yt-dlp/yt-dlp
File: yt_dlp/extractor/loco.py (Python)

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


class LocoIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?loco\.com/(?P<type>streamers|stream)/(?P<id>[^/?#]+)'
    _TESTS = [{
        'url': 'https://loco.com/streamers/teuzinfps',
        'info_dict': {
            'id': 'teuzinfps',
            'ext': 'mp4',
            'title': r're:MS BOLADAO, RESENHA & GAMEPLAY ALTO NIVEL',
            'description': 'bom e novo',
            'uploader_id': 'RLUVE3S9JU',
            'channel': 'teuzinfps',
            'channel_follower_count': int,
            'comment_count': int,
            'view_count': int,
            'concurrent_view_count': int,
            'like_count': int,
            'thumbnail': 'https://static.ivory.getloconow.com/default_thumb/743701a9-98ca-41ae-9a8b-70bd5da070ad.jpg',
            'tags': ['MMORPG', 'Gameplay'],
            'series': 'Tibia',
            'timestamp': int,
            'modified_timestamp': int,
            'live_status': 'is_live',
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://loco.com/stream/c64916eb-10fb-46a9-9a19-8c4b7ed064e7',
        'md5': '45ebc8a47ee1c2240178757caf8881b5',
        'info_dict': {
            'id': 'c64916eb-10fb-46a9-9a19-8c4b7ed064e7',
            'ext': 'mp4',
            'title': 'PAULINHO LOKO NA LOCO!',
            'description': 'live on na loco',
            'uploader_id': '2MDO7Z1DPM',
            'channel': 'paulinholokobr',
            'channel_follower_count': int,
            'comment_count': int,
            'view_count': int,
            'concurrent_view_count': int,
            'like_count': int,
            'duration': 14491,
            'thumbnail': 'https://static.ivory.getloconow.com/default_thumb/59b5970b-23c1-4518-9e96-17ce341299fe.jpg',
            'tags': ['Gameplay'],
            'series': 'GTA 5',
            'timestamp': 1740612872041,

Review comment (suggestion):
Does the test harness look for `upload_date` too when `timestamp` is set, as in upstream? Or even `modified_date`? But if the test doesn't complain, that's fine.

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


class LocoIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)?loco\.com/(?P<type>streamers|stream)/(?P<id>[^/?#]+)'
    _TESTS = [{
        'url': 'https://loco.com/streamers/teuzinfps',
        'info_dict': {
            'id': 'teuzinfps',
            'ext': 'mp4',
            'title': r're:MS BOLADAO, RESENHA & GAMEPLAY ALTO NIVEL',
            'description': 'bom e novo',
            'uploader_id': 'RLUVE3S9JU',
            'channel': 'teuzinfps',
            'channel_follower_count': int,
            'comment_count': int,
            'view_count': int,
            'concurrent_view_count': int,
            'like_count': int,
            'thumbnail': 'https://static.ivory.getloconow.com/default_thumb/743701a9-98ca-41ae-9a8b-70bd5da070ad.jpg',
            'tags': ['MMORPG', 'Gameplay'],
            'series': 'Tibia',
            'timestamp': int,
            'modified_timestamp': int,
            'live_status': 'is_live',
            'upload_date': str,
            'modified_date': str,
        },
        'params': {
            'skip_download': 'Livestream',
        },
    }, {
        'url': 'https://loco.com/stream/c64916eb-10fb-46a9-9a19-8c4b7ed064e7',
        'md5': '45ebc8a47ee1c2240178757caf8881b5',
        'info_dict': {
            'id': 'c64916eb-10fb-46a9-9a19-8c4b7ed064e7',
            'ext': 'mp4',
            'title': 'PAULINHO LOKO NA LOCO!',
            'description': 'live on na loco',
            'uploader_id': '2MDO7Z1DPM',
            'channel': 'paulinholokobr',
            'channel_follower_count': int,
            'comment_count': int,
            'view_count': int,
            'concurrent_view_count': int,
            'like_count': int,
            'duration': 14491,
            'thumbnail': 'https://static.ivory.getloconow.com/default_thumb/59b5970b-23c1-4518-9e96-17ce341299fe.jpg',