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

Code before:
            'subtitles': subtitles
        }

    def _extract_thumbnails(self, thumbs):
        return traverse_obj(thumbs, (lambda _, v: url_or_none(v['url']), {
            'url': 'url',
            'width': ('width', {int_or_none}),
            'height': ('height', {int_or_none}),
        }))

    def _real_extract(self, url):
        page_id = self._match_id(url)
        webpage = self._download_webpage(url, page_id)
        article_json = self._search_json(
            r'window\.__preloadedData\s*=', webpage, 'media details', page_id,
            transform_source=lambda x: x.replace('undefined', 'null'))['initialData']['data']['article']

        blocks = traverse_obj(article_json, (
            'sprinkledBody', 'content', ..., ('ledeMedia', None),
            lambda _, v: v['__typename'] in ('Video', 'Audio')))

        art_title = remove_end(self._html_extract_title(webpage), ' - The New York Times')
        art_description = traverse_obj(
            article_json, ('sprinkledBody', 'content', ..., 'summary', 'content', ..., 'text'),
            get_all=False) or self._html_search_meta(['og:description', 'twitter:description'], webpage)
        art_upload_date = traverse_obj(article_json, ('firstPublished'))
        creator = ', '.join(
            traverse_obj(article_json, ('bylines', ..., 'creators', ..., 'displayName')))

        # more than 1 video in the article, treat it as a playlist
        if len(blocks) > 1:
            entries = []
            for block in blocks:
                entries.append(merge_dicts(self._extract_content_from_block(block), {
                    'title': art_title,
                    'description': art_description,
                    'creator': creator,  # TODO: change to 'creators' (list)
                    'thumbnails': self._extract_thumbnails(traverse_obj(
                        block, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
                }))
            return self.playlist_result(entries, page_id, art_title, art_description)

        return merge_dicts(self._extract_content_from_block(blocks[0]), {
            'title': art_title,
            'description': art_description,
            'creator': creator,  # TODO: change to 'creators'
            'upload_date': unified_strdate(art_upload_date),
            'timestamp': parse_iso8601(art_upload_date),
            'thumbnails': self._extract_thumbnails(traverse_obj(
                blocks[0], ('promotionalMedia', 'crops', ..., 'renditions', ...)) or traverse_obj(
                article_json, ('promotionalMedia', 'assetCrops', ..., 'renditions', ...))),

Review comment (performance):
inline `art_upload_date` in the `timestamp` field below -- as I said in another comment, manually calculating `upload_date` from the same value that you are using for `timestamp` is just unnecessary complexity.

Also, `timestamp` is not being added to the entries. Is this intentional? If it was an oversight, then it might be better to construct a `common_info` dict here and unpack it in the entries and single video result below

Code after:
            'uploader': 'Matthew Williams',
            'creator': 'Patricia Cohen',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
            'duration': 119.0,
        },
    }, {
        # article with audio and no video
        'url': 'https://www.nytimes.com/2023/09/29/health/mosquitoes-genetic-engineering.html',
        'md5': '2365b3555c8aa7f4dd34ca735ad02e6a',
        'info_dict': {
            'id': '100000009110381',
            'ext': 'mp3',
            'title': 'The Gamble: Can Genetically Modified Mosquitoes End Disease?',
            'description': 'md5:9ff8b47acbaf7f3ca8c732f5c815be2e',
            'timestamp': 1695960700,
            'upload_date': '20230929',
            'creator': 'Stephanie Nolen, Natalija Gormalova',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
            'duration': 1322,
        },
    }, {
        'url': 'https://www.nytimes.com/2023/11/29/business/dealbook/kamala-harris-biden-voters.html',
        'md5': '3eb5ddb1d6f86254fe4f233826778737',
        'info_dict': {
            'id': '100000009202270',
            'ext': 'mp4',
            'title': 'Kamala Harris Defends Biden Policies, but Says ‘More Work’ Needed to Reach Voters',
            'description': 'md5:de4212a7e19bb89e4fb14210ca915f1f',
            'timestamp': 1701290997,
            'upload_date': '20231129',
            'uploader': 'By The New York Times',
            'creator': 'Katie Rogers',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
            'duration': 97.631,
        },
        'params': {
            'skip_download': 'm3u8',
        },
    }, {
        # multiple videos in the same article
        'url': 'https://www.nytimes.com/2023/12/02/business/air-traffic-controllers-safety.html',
        'info_dict': {
            'id': 'air-traffic-controllers-safety',
            'title': 'Drunk and Asleep on the Job: Air Traffic Controllers Pushed to the Brink',
            'description': 'md5:549e5a5e935bf7d048be53ba3d2c863d',
            'upload_date': '20231202',
            'creator': 'Emily Steel, Sydney Ember',
            'timestamp': 1701511264,
        },
        'playlist_count': 3,
    }, {