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

Code before:
            'timestamp': 1701302400,
            'upload_date': '20231130',
            'creator': 'Sue Li',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
        },
    }, {
        'url': 'https://cooking.nytimes.com/recipes/1019516-overnight-oats',
        'md5': '2fe7965a3adc899913b8e25ada360823',
        'info_dict': {
            'id': '1019516',
            'ext': 'mp4',
            'timestamp': 1546387200,
            'description': 'md5:8856ce10239161bd2596ac335b9f9bfb',
            'upload_date': '20190102',
            'title': 'Overnight Oats',
            'creator': 'Genevieve Ko',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
        }
    }]

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

        json_obj = traverse_obj(
            self._search_nextjs_data(webpage, page_id), ('props', 'pageProps'), default={})

        info = traverse_obj(json_obj, {
            'id': ('recipe', 'id', {str_or_none}),
            'title': ('recipe', 'title'),
            'description': ('recipe', 'topnote', {clean_html}),
            'timestamp': ('recipe', 'publishedAt'),
            'creator': ('recipe', 'contentAttribution', 'cardByline'),
            'upload_date': ('meta', 'jsonLD', 'video', 'uploadDate', {unified_strdate}),
            'formats': ('recipe', 'videoSrc', {url_or_none}),
        })

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            info.get('formats'), info.get('id'), 'mp4', entry_protocol='m3u8_native', m3u8_id='hls')

        thumbnails = []
        for image in traverse_obj(json_obj, ('recipe', 'image', 'crops', 'recipe', ...)):
            if not url_or_none(image):
                continue
            thumbnails.append({
                'url': image,
            })

        return {
            'id': info.get('id'),
            'title': info.get('title'),

Review comment (refactor):
it's ok to make this fatal. `_search_nextjs_data` already is, and we have nothing to extract w/o this variable. I'd also use a var name like `next_data`
```suggestion
        next_data = self._search_nextjs_data(webpage, page_id)['props']['pageProps']
```

Code after:
            entries.append(merge_dicts(self._extract_content_from_block(block), common_info))

        if len(entries) > 1:
            return self.playlist_result(entries, page_id, **common_info)

        return {
            'id': page_id,
            **entries[0],
        }


class NYTimesCookingIE(NYTimesBaseIE):
    IE_NAME = 'NYTimesCookingGuide'
    _VALID_URL = r'https?://cooking\.nytimes\.com/guides/(?P<id>[\w-]+)'
    _TESTS = [{
        'url': 'https://cooking.nytimes.com/guides/13-how-to-cook-a-turkey',
        'info_dict': {
            'id': '13-how-to-cook-a-turkey',
            'title': 'How to Cook a Turkey',
            'description': 'md5:726cfd3f9b161bdf5c279879e8050ca0',
        },
        'playlist_count': 2,
    }, {
        # single video example
        'url': 'https://cooking.nytimes.com/guides/50-how-to-make-mac-and-cheese',
        'md5': '64415805fe0b8640fce6b0b9def5989a',
        'info_dict': {
            'id': '100000005835845',
            'ext': 'mp4',
            'title': 'How to Make Mac and Cheese',
            'description': 'md5:b8f2f33ec1fb7523b21367147c9594f1',
            'duration': 9.51,
            'creator': 'Alison Roman',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.*\.jpg',
        },
    }, {
        'url': 'https://cooking.nytimes.com/guides/20-how-to-frost-a-cake',
        'md5': '64415805fe0b8640fce6b0b9def5989a',
        'info_dict': {
            'id': '20-how-to-frost-a-cake',
            'title': 'How to Frost a Cake',
            'description': 'md5:a31fe3b98a8ce7b98aae097730c269cd',
        },
        'playlist_count': 8,
    }]

    def _real_extract(self, url):
        page_id = self._match_id(url)
        webpage = self._download_webpage(url, page_id)
        title = self._html_search_meta(['og:title', 'twitter:title'], webpage)
        description = self._html_search_meta(['og:description', 'twitter:description'], webpage)