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

Code before:
        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:
                video_id = traverse_obj(block_json, ('sourceId'), get_all=False)
                media_title = traverse_obj(block_json, ('promotionalHeadline'), get_all=False) or art_title
                media_description = traverse_obj(block_json, ('summary'), get_all=False)
                uploader = traverse_obj(block_json, ('bylines', ..., 'renderedRepresentation'), get_all=False)
                duration = float_or_none(traverse_obj(block_json, ('duration'), get_all=False))
                publication_date = traverse_obj(block_json, ('firstPublished'))
                timestamp = parse_iso8601(publication_date) if publication_date else None

                media_content = traverse_obj(block_json, ('renditions', ...))
                formats, subtitles = self._extract_media_from_json(video_id, media_content)

                thumbnails = []
                for image in traverse_obj(block_json, ('promotionalMedia', 'crops', ..., 'renditions', ...), get_all=True):
                    image_url = image.get('url')
                    if not image_url:
                        continue
                    thumbnails.append({
                        'url': image_url,
                        'width': int_or_none(image.get('width')),
                        'height': int_or_none(image.get('height')),
                    })

                entries.append({
                    'id': video_id,
                    'title': media_title,
                    'description': media_description,
                    'timestamp': timestamp,
                    'upload_date': unified_strdate(publication_date),
                    'uploader': uploader,
                    'creator': creator,
                    'duration': int_or_none(duration, 1000),
                    'formats': formats,
                    'subtitles': subtitles,
                    'thumbnails': thumbnails})

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

        block_json = blocks_json.pop()
        media_id = traverse_obj(block_json, ('sourceId'), get_all=False)
        publication_date = traverse_obj(
            block_json, ('firstPublished')) or traverse_obj(article_json, ('firstPublished'))
        timestamp = parse_iso8601(publication_date) if publication_date else None
        duration = int_or_none(traverse_obj(
            block_json, ('duration'), get_all=False), 1000) or traverse_obj(block_json, ('length'), get_all=False)

Review comment (refactor):
This URL still works too, although it redirects to `https://archive.nytimes.com/www.nytimes.com/news/minute/2014/03/17/times-minute-whats-next-in-crimea/?_php=true&_php=true&_r=1&_type=blogs&_type=blogs`

We'll probably need to add a new `NYTimesArchive` extractor for this, which can be a separate PR. Just noting it here so that it's not forgotten

Code after:
            'description': 'md5:93603dada88ddbda9395632fdc5da260',
            'timestamp': 1398631707,  # FIXME
            'upload_date': '20140427',  # FIXME
            'creator': 'Brett Weiner',
            'thumbnail': r're:https?://\w+\.nyt.com/images/.+\.jpg',
            'duration': 419,
        },
    }, {
        'url': 'http://www.nytimes.com/video/travel/100000003550828/36-hours-in-dubai.html',
        'only_matching': True,
    }]

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

        return self._extract_video(video_id)


class NYTimesArticleIE(NYTimesBaseIE):
    _VALID_URL = r'https?://(?:www\.)?nytimes\.com/\d{4}/\d{2}/\d{2}/(?!books|podcasts)[^/?#]+/(?:\w+/)?(?P<id>[^./?#]+)(?:\.html)?'
    _TESTS = [{
        'url': 'http://www.nytimes.com/2015/04/14/business/owner-of-gravity-payments-a-credit-card-processor-is-setting-a-new-minimum-wage-70000-a-year.html?_r=0',
        'md5': '3eb5ddb1d6f86254fe4f233826778737',
        'info_dict': {
            'id': '100000003628438',
            'ext': 'mp4',
            'title': 'One Company’s New Minimum Wage: $70,000 a Year',
            'description': 'md5:89ba9ab67ca767bb92bf823d1f138433',
            'timestamp': 1429047468,
            'upload_date': '20150414',
            '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,
        },
    }, {