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

Code before:
            'thumbnail': r're:https?://.+\.(?:jpg|png)',
        },
    }, {
        'url': 'https://www.startrek.com/en-ca/videos/my-first-contact-senator-cory-booker',
        'info_dict': {
            'id': 'my-first-contact-senator-cory-booker',
            'ext': 'mp4',
            'title': 'My First Contact: Senator Cory Booker',
            'alt_title': 'md5:fe74a8bdb0afab421c6e159a7680db4d',
            'categories': ['MY FIRST CONTACT'],
            'description': 'md5:a3992ab3b3e0395925d71156bbc018ce',
            'release_date': '20250401',
            'release_timestamp': 1743512400,
            'series': 'Star Trek: The Original Series',
            'series_id': 'star-trek-the-original-series',
            'thumbnail': r're:https?://.+\.(?:jpg|png)',
        },
    }]

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

        page_props = traverse_obj(self._search_nextjs_data(
            webpage, video_id), ('props', 'pageProps', {dict}), default={})
        video_data = traverse_obj(page_props, ('video', 'data', {dict}))
        if youtube_id := video_data.get('youtube_video_id'):
            return self.url_result(youtube_id, 'Youtube')

        series_id = traverse_obj(video_data, (
            'series_and_movies', ..., 'series_or_movie', 'slug', {str}, any))

        subtitles = {}
        if sub_url := traverse_obj(video_data, ('legacy_subtitle_file', {url_or_none})):
            subtitles.setdefault('en', []).append({
                'ext': determine_ext(sub_url),
                'url': sub_url,
            })

        return {
            'id': video_id,
            'series': traverse_obj(page_props, (
                'queried', 'header', 'tab3', 'slices', ..., 'items',
                lambda _, v: v['link']['slug'] == series_id, 'link_copy', {str}, any)),
            'series_id': series_id,
            'subtitles': subtitles,
            **traverse_obj(video_data, {
                'title': ('title', ..., 'text', {clean_html}, any),
                'alt_title': ('subhead', ..., 'text', {clean_html}, any),
                'categories': ('category', 'data', 'category_name', {str.upper}, all),
                'description': ('slices', ..., 'primary', 'content', ..., 'text', {clean_html}, any),

Review comment (bug):
As I said in https://github.com/yt-dlp/yt-dlp/pull/13302#discussion_r2108411367, don't bother with `traverse_obj` if the rest of the extractor is broken without the data you're traversing for (unless you otherwise need the filtering/transformations/versatility of `traverse_obj`)
```suggestion
        page_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
        video_data = page_props['video']['data']
```

Code after:
        },
    }, {
        'url': 'https://www.startrek.com/en-ca/videos/my-first-contact-senator-cory-booker',
        'info_dict': {
            'id': 'my-first-contact-senator-cory-booker',
            'ext': 'mp4',
            'title': 'My First Contact: Senator Cory Booker',
            'alt_title': 'md5:fe74a8bdb0afab421c6e159a7680db4d',
            'categories': ['MY FIRST CONTACT'],
            'description': 'md5:a3992ab3b3e0395925d71156bbc018ce',
            'release_date': '20250401',
            'release_timestamp': 1743512400,
            'series': 'Star Trek: The Original Series',
            'series_id': 'star-trek-the-original-series',
            'thumbnail': r're:https?://.+\.(?:jpg|png)',
        },
    }]

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

        page_props = self._search_nextjs_data(webpage, video_id)['props']['pageProps']
        video_data = page_props['video']['data']
        if youtube_id := video_data.get('youtube_video_id'):
            return self.url_result(youtube_id, YoutubeIE)

        series_id = traverse_obj(video_data, (
            'series_and_movies', ..., 'series_or_movie', 'slug', {str}, any))

        return {
            'id': video_id,
            'series': traverse_obj(page_props, (
                'queried', 'header', 'tab3', 'slices', ..., 'items',
                lambda _, v: v['link']['slug'] == series_id, 'link_copy', {str}, any)),
            'series_id': series_id,
            **traverse_obj(video_data, {
                'title': ('title', ..., 'text', {clean_html}, any),
                'alt_title': ('subhead', ..., 'text', {clean_html}, any),
                'categories': ('category', 'data', 'category_name', {str.upper}, filter, all),
                'description': ('slices', ..., 'primary', 'content', ..., 'text', {clean_html}, any),
                'release_timestamp': ('published', {parse_iso8601}),
                'subtitles': ({'url': 'legacy_subtitle_file'}, all, {subs_list_to_dict(lang='en')}),
                'thumbnail': ('poster_frame', 'url', {url_or_none}, {update_url(query=None)}),
                'url': ('legacy_video_url', {url_or_none}),
            }),
        }