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

Code before:
            r'^([\d,]+)', re.sub(r'\s', '', view_count_text),
            'view count', default=None))

        uploader = self._get_text(renderer, 'ownerText', 'shortBylineText')
        channel_id = traverse_obj(
            renderer, ('shortBylineText', 'runs', ..., 'navigationEndpoint', 'browseEndpoint', 'browseId'), expected_type=str, get_all=False)
        timestamp, time_text = self._extract_time_text(renderer, 'publishedTimeText')
        scheduled_timestamp = str_to_int(traverse_obj(renderer, ('upcomingEventData', 'startTime'), get_all=False))
        overlay_style = traverse_obj(
            renderer, ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'style'), get_all=False, expected_type=str)
        badges = self._extract_badges(renderer)
        return {
            '_type': 'url',
            'ie_key': YoutubeIE.ie_key(),
            'id': video_id,
            'url': f'https://www.youtube.com/watch?v={video_id}',
            'title': title,
            'description': description,
            'duration': duration,
            'view_count': view_count,
            'uploader': uploader,
            'channel_id': channel_id,  # TODO: validate?
            'upload_date': strftime_or_none(timestamp, '%Y%m%d'),
            'live_status': ('is_upcoming' if scheduled_timestamp is not None else None
                            or 'was_live' if any(i in time_text.lower() for i in ('streamed', 'premiered')) else None
                            or 'is_live' if overlay_style is not None and overlay_style == 'LIVE' or 'live now' in badges else None),
            'release_timestamp': scheduled_timestamp,
            'availability': self._availability(needs_premium='premium' in badges, needs_subscription='members only' in badges)
        }


class YoutubeIE(YoutubeBaseInfoExtractor):
    IE_DESC = 'YouTube'
    _VALID_URL = r"""(?x)^
                     (
                         (?:https?://|//)                                    # http(s):// or protocol-independent URL
                         (?:(?:(?:(?:\w+\.)?[yY][oO][uU][tT][uU][bB][eE](?:-nocookie|kids)?\.com|
                            (?:www\.)?deturl\.com/www\.youtube\.com|
                            (?:www\.)?pwnyoutube\.com|
                            (?:www\.)?hooktube\.com|
                            (?:www\.)?yourepeat\.com|
                            tube\.majestyc\.net|
                            %(invidious)s|
                            youtube\.googleapis\.com)/                        # the various hostnames, with wildcard subdomains
                         (?:.*?\#/)?                                          # handle anchor (#/) redirect urls
                         (?:                                                  # the various things that can precede the ID:
                             (?:(?:v|embed|e|shorts)/(?!videoseries))         # v/ or embed/ or e/ or shorts/
                             |(?:                                             # or the v= param in all its forms
                                 (?:(?:watch|movie)(?:_popup)?(?:\.php)?/?)?  # preceding watch(_popup|.php) or nothing (like /?v=xxxx)
                                 (?:\?|\#!?)                                  # the params delimiter ? or # or #!
                                 (?:.*?[&;])??                                # any other preceding param (like /?s=tuff&v=xxxx or ?s=tuff&amp;v=V36LpHqtcDY)

Review comment (suggestion):
```suggestion
            'live_status': ('is_upcoming' if scheduled_timestamp is not None
                            else 'was_live' if any(i in time_text.lower() for i in ('streamed', 'premiered'))
                            else 'is_live' if overlay_style is not None and overlay_style == 'LIVE' or 'live now' in badges
                            else None),
```
or
```suggestion
            'live_status': (scheduled_timestamp is not None and 'is_upcoming'
                            or any(i in time_text.lower() for i in ('streamed', 'premiered')) and 'was_live'
                            or overlay_style is not None and overlay_style == 'LIVE' or 'live now' in badges and 'is_live'
                            or None),
```
personally, I prefer the first

Code after:
            r'^([\d,]+)', re.sub(r'\s', '', view_count_text),
            'view count', default=None))

        uploader = self._get_text(renderer, 'ownerText', 'shortBylineText')
        channel_id = traverse_obj(
            renderer, ('shortBylineText', 'runs', ..., 'navigationEndpoint', 'browseEndpoint', 'browseId'), expected_type=str, get_all=False)
        timestamp, time_text = self._extract_time_text(renderer, 'publishedTimeText')
        scheduled_timestamp = str_to_int(traverse_obj(renderer, ('upcomingEventData', 'startTime'), get_all=False))
        overlay_style = traverse_obj(
            renderer, ('thumbnailOverlays', ..., 'thumbnailOverlayTimeStatusRenderer', 'style'), get_all=False, expected_type=str)
        badges = self._extract_badges(renderer)
        return {
            '_type': 'url',
            'ie_key': YoutubeIE.ie_key(),
            'id': video_id,
            'url': f'https://www.youtube.com/watch?v={video_id}',
            'title': title,
            'description': description,
            'duration': duration,
            'view_count': view_count,
            'uploader': uploader,
            'channel_id': channel_id,
            'upload_date': strftime_or_none(timestamp, '%Y%m%d'),
            'live_status': ('is_upcoming' if scheduled_timestamp is not None
                            else 'was_live' if 'streamed' in time_text.lower()
                            else 'is_live' if overlay_style is not None and overlay_style == 'LIVE' or 'live now' in badges
                            else None),
            'release_timestamp': scheduled_timestamp,
            'availability': self._availability(needs_premium='premium' in badges, needs_subscription='members only' in badges)
        }


class YoutubeIE(YoutubeBaseInfoExtractor):
    IE_DESC = 'YouTube'
    _VALID_URL = r"""(?x)^
                     (
                         (?:https?://|//)                                    # http(s):// or protocol-independent URL
                         (?:(?:(?:(?:\w+\.)?[yY][oO][uU][tT][uU][bB][eE](?:-nocookie|kids)?\.com|
                            (?:www\.)?deturl\.com/www\.youtube\.com|
                            (?:www\.)?pwnyoutube\.com|
                            (?:www\.)?hooktube\.com|
                            (?:www\.)?yourepeat\.com|
                            tube\.majestyc\.net|
                            %(invidious)s|
                            youtube\.googleapis\.com)/                        # the various hostnames, with wildcard subdomains
                         (?:.*?\#/)?                                          # handle anchor (#/) redirect urls
                         (?:                                                  # the various things that can precede the ID:
                             (?:(?:v|embed|e|shorts)/(?!videoseries))         # v/ or embed/ or e/ or shorts/
                             |(?:                                             # or the v= param in all its forms
                                 (?:(?:watch|movie)(?:_popup)?(?:\.php)?/?)?  # preceding watch(_popup|.php) or nothing (like /?v=xxxx)
                                 (?:\?|\#!?)                                  # the params delimiter ? or # or #!