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

Code before:
                if len(embedded_urls) == 1:
                    return self.url_result(embedded_urls[0], ie=None, video_id=page_id)
                return self.playlist_result(
                    [self.url_result(u, ie=None) for u in embedded_urls],
                    page_id,
                    json_data.get('title', 'MSN Playlist'),
                    display_id
                )
            # If we have both direct and embedded, append embedded as additional entries
            for embed_url in embedded_urls:
                formats.append({'url': embed_url, 'format_id': 'embedded'})

        # Raise error if no formats found
        if not formats:
            raise ExtractorError('No video formats or embeds found', expected=True)

        # Extract metadata
        title = (
            json_data.get('title') or
            self._html_search_meta(('og:title', 'title'), webpage, default=None) or
            f'MSN video {page_id}'
        )
        description = json_data.get('description') or self._html_search_meta('description', webpage, default=None)
        duration = int_or_none(video_metadata.get('duration'))
        uploader = video_metadata.get('uploader') or self._html_search_meta('author', webpage, default=None)
        uploader_id = video_metadata.get('uploaderId')

        # Return result
        return {
            'id': page_id,
            'display_id': display_id,
            'title': unescapeHTML(title),
            'description': unescapeHTML(description) if description else None,
            'duration': duration,
            'uploader': uploader,
            'uploader_id': uploader_id,
            'formats': formats,
        }

    def _extract_embedded_urls(self, webpage, video_id):
        """Extract URLs of embedded videos (e.g., YouTube, Dailymotion) from the webpage."""
        embed_urls = []
        # Use re.findall to extract all iframe src attributes
        iframe_matches = re.findall(r'<iframe[^>]+src=["\'](.*?)["\']', webpage)
        for iframe_src in iframe_matches:
            embed_url = url_or_none(iframe_src)
            if embed_url and any(host in embed_url for host in ('youtube.com', 'dailymotion.com', 'nbcsports.com')):
                embed_urls.append(embed_url)
        # Optional debug: Uncomment to inspect found URLs
        # self._downloader.to_screen(f"Found embedded URLs: {embed_urls}")
        return embed_urls

Review comment (suggestion):
Inline below and use `traverse_obj`. For the title you should also not create a fallback title yourself, the core code will handle that.

Code after:
            'tags': ['topthink', 'top think', 'personal growth'],
            'timestamp': 1722711620,
            'upload_date': '20240803',
            'playable_in_embed': True,
            'availability': 'public',
            'live_status': 'not_live',
        },
    }, {
        # Article with social embed
        'url': 'https://www.msn.com/en-in/news/techandscience/watch-earth-sets-and-rises-behind-moon-in-breathtaking-blue-ghost-video/ar-AA1zKoAc',
        'info_dict': {
            'id': 'AA1zKoAc',
            'title': 'Watch: Earth sets and rises behind Moon in breathtaking Blue Ghost video',
            'description': 'md5:0ad51cfa77e42e7f0c46cf98a619dbbf',
            'uploader': 'India Today',
            'uploader_id': 'AAyFWG',
            'tags': 'count:11',
            'timestamp': 1740485034,
            'upload_date': '20250225',
            'release_timestamp': 1740484875,
            'release_date': '20250225',
            'modified_timestamp': 1740488561,
            'modified_date': '20250225',
        },
        'playlist_count': 1,
    }]

    def _real_extract(self, url):
        locale, display_id, page_id = self._match_valid_url(url).group('locale', 'display_id', 'id')

        json_data = self._download_json(
            f'https://assets.msn.com/content/view/v2/Detail/{locale}/{page_id}', page_id)

        common_metadata = traverse_obj(json_data, {
            'title': ('title', {str}),
            'description': (('abstract', ('body', {clean_html})), {str}, filter, any),
            'timestamp': ('createdDateTime', {parse_iso8601}),
            'release_timestamp': ('publishedDateTime', {parse_iso8601}),
            'modified_timestamp': ('updatedDateTime', {parse_iso8601}),
            'thumbnail': ('thumbnail', 'image', 'url', {url_or_none}),
            'duration': ('videoMetadata', 'playTime', {int_or_none}),
            'tags': ('keywords', ..., {str}),
            'uploader': ('provider', 'name', {str}),
            'uploader_id': ('provider', 'id', {str}),
        })

        page_type = json_data['type']
        source_url = traverse_obj(json_data, ('sourceHref', {url_or_none}))
        if page_type == 'video':
            if traverse_obj(json_data, ('thirdPartyVideoPlayer', 'enabled')) and source_url:
                return self.url_result(source_url)