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

Code before:
        notification_list = traverse_obj(
            response, ('actions', 0, 'openPopupAction', 'popup', 'multiPageMenuRenderer', 'sections', 0, 'multiPageMenuNotificationSectionRenderer', 'items'), expected_type=list)
        if not notification_list:
            notification_list = traverse_obj(
                response, ('actions', 0, 'appendContinuationItemsAction', 'continuationItems'), expected_type=list)
        for item in notification_list:
            for key in ('notificationRenderer', 'continuationItemRenderer'):
                value = item.get(key)
                if value:
                    if key == 'notificationRenderer':
                        yield value
                        break
                    elif key == 'continuationItemRenderer':
                        continuation_list[0] = value
                        return
        continuation_list[0] = None

    def _extract_notification(self, notification):
        # notificationRenderer
        video_id = traverse_obj(
            notification, ('navigationEndpoint', 'watchEndpoint', 'videoId'), expected_type=str)
        if not video_id:
            return None
        thumbnails = traverse_obj(notification, ('videoThumbnail', 'thumbnails'), expected_type=list)
        status_text = traverse_obj(notification, ('shortMessage', 'simpleText'), expected_type=str)
        uploader = traverse_obj(
            notification, ('contextualMenu', 'menuRenderer', 'items', 1, 'menuServiceItemRenderer', 'text', 'runs', 1, 'text'), expected_type=str)
        status_text = status_text.removeprefix(uploader + ' ')
        split_text = status_text.split(': ', 2)
        title = None
        if len(split_text) == 2:
            title = split_text[1]
        extra_info = {
            'thumbnails': thumbnails,
            'uploader': uploader,
        }
        return self.url_result(
            f'https://www.youtube.com/watch?v={video_id}', ie=YoutubeIE.ie_key(),
            video_id=video_id, video_title=title, **extra_info)

    @classmethod
    def _extract_next_notification_continuation_data(cls, renderer):
        # continuationItemRenderer
        ctoken = traverse_obj(
            renderer, ('continuationEndpoint', 'getNotificationMenuEndpoint', 'ctoken'), expected_type=str)
        if not ctoken:
            return
        return cls._build_notification_continuation_query(ctoken)

    @staticmethod
    def _build_notification_continuation_query(ctoken):

Review comment (suggestion):
there's also `_get_text` that's similar to traverse_obj but handles youtube's simpletext/runs

Code after:
    def _real_extract(self, url):
        return self.url_result(
            'https://www.youtube.com/playlist?list=LL',
            ie=YoutubeTabIE.ie_key())


class YoutubeNotificationsIE(YoutubeTabBaseInfoExtractor):
    IE_NAME = 'youtube:notif'
    IE_DESC = 'YouTube notifications; ":ytnotif" keyword (requires cookies)'
    _VALID_URL = r':ytnotif(?:ication)?s?'
    _LOGIN_REQUIRED = True
    _TESTS = [{
        'url': ':ytnotif',
        'only_matching': True,
    }, {
        'url': ':ytnotifications',
        'only_matching': True,
    }]

    def _extract_notification_menu(self, response, continuation_list):
        notification_list = traverse_obj(
            response,
            ('actions', 0, 'openPopupAction', 'popup', 'multiPageMenuRenderer', 'sections', 0, 'multiPageMenuNotificationSectionRenderer', 'items'),
            ('actions', 0, 'appendContinuationItemsAction', 'continuationItems'),
            expected_type=list) or []
        continuation_list[0] = None
        for item in notification_list:
            entry = self._extract_notification_renderer(item.get('notificationRenderer'))
            if entry:
                yield entry
            continuation = item.get('continuationItemRenderer')
            if continuation:
                continuation_list[0] = continuation

    def _extract_notification_renderer(self, notification):
        video_id = traverse_obj(
            notification, ('navigationEndpoint', 'watchEndpoint', 'videoId'), expected_type=str)
        url = f'https://www.youtube.com/watch?v={video_id}'
        channel_id = None
        if not video_id:
            browse_ep = traverse_obj(
                notification, ('navigationEndpoint', 'browseEndpoint'), expected_type=dict)
            channel_id = traverse_obj(browse_ep, 'browseId', expected_type=str)
            post_id = self._search_regex(
                r'/post/(.+)', traverse_obj(browse_ep, 'canonicalBaseUrl', expected_type=str),
                'post id', default=None)
            if not channel_id or not post_id:
                return
            # The direct /post url redirects to this in the browser
            url = f'https://www.youtube.com/channel/{channel_id}/community?lb={post_id}'