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

Code before:
            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'), get_all=True))

        # more than 1 video in the article, treat it as a playlist
        if len(blocks_json) > 1:
            entries = []
            for block_json in blocks_json:
                content = self._extract_content_from_block(block_json)
                thumbnails = self._extract_thumbnails(traverse_obj(
                    block_json, ('promotionalMedia', 'crops', ..., 'renditions', ...)))
                info = merge_dicts(content, {
                    'title': art_title,
                    'description': art_description,
                    'creator': creator,
                    'thumbnails': thumbnails,
                })

                entries.append(info)

            return self.playlist_result(entries, page_id, art_title, art_description)

        block_json = blocks_json.pop()
        content = self._extract_content_from_block(block_json)
        thumbnails = self._extract_thumbnails(traverse_obj(
            block_json, ('promotionalMedia', 'crops', ..., 'renditions', ...)) or traverse_obj(
                article_json, ('promotionalMedia', 'assetCrops', ..., 'renditions', ...)))

        info = merge_dicts(content, {
            'title': art_title,
            'description': art_description,
            'creator': creator,
            'upload_date': unified_strdate(art_upload_date),
            'timestamp': parse_iso8601(art_upload_date),
            'thumbnails': thumbnails,
        })

        return {
            **info
        }


class NYTimesCookingIE(InfoExtractor):
    IE_NAME = 'NYTimesCookingRecipes'
    _VALID_URL = r'https?://cooking\.nytimes\.com/recipes/(?P<id>\d+)'

Review comment (refactor):
```suggestion
                entries.append(merge_dicts(self._extract_content_from_block(block_json), {
                    'title': art_title,
                    'description': art_description,
                    'creator': creator,  # TODO: change to 'creators' (list)
                    'thumbnails': self._extract_thumbnails(traverse_obj(
                        block_json, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
                }))
```

Code after:
            '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,
    }, {
        'url': 'https://www.nytimes.com/2023/12/02/business/media/netflix-squid-game-challenge.html',
        'only_matching': True,
    }]

    def _extract_content_from_block(self, block):
        details = traverse_obj(block, {
            'id': ('sourceId', {str}),
            'uploader': ('bylines', ..., 'renderedRepresentation', {str}),
            'duration': (None, (('duration', {lambda x: float_or_none(x, scale=1000)}), ('length', {int_or_none}))),
            'timestamp': ('firstPublished', {parse_iso8601}),
            'series': ('podcastSeries', {str}),
        }, get_all=False)

        formats, subtitles = self._extract_formats_and_subtitles(details.get('id'), block)
        # audio articles will have an url and no formats
        url = traverse_obj(block, ('fileUrl', {url_or_none}))
        if not formats and url:
            formats.append({'url': url, 'vcodec': 'none'})

        return {
            **details,
            'thumbnails': self._extract_thumbnails(traverse_obj(
                block, ('promotionalMedia', 'crops', ..., 'renditions', ...))),
            'formats': formats,
            'subtitles': subtitles
        }

    def _real_extract(self, url):
        page_id = self._match_id(url)
        webpage = self._download_webpage(url, page_id)
        art_json = self._search_json(
            r'window\.__preloadedData\s*=', webpage, 'media details', page_id,