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

Code before:
            'id': 'build-2022',
            'title': 'Microsoft Build 2022 - Events',
            'description': 'md5:c16b43848027df837b22c6fbac7648d3',
        },
        'playlist_count': 201,
    }]

    def _real_extract(self, url):
        series, slug = self._match_valid_url(url).groups()
        video_id = slug or series
        webpage = self._download_webpage(url, video_id)

        metainfo = {
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
        }

        if not slug:
            url_base = f'https://learn.microsoft.com/api/contentbrowser/search/events/{series}/sessions'
            return self.playlist_result(self._entries(url_base, video_id), video_id, **metainfo)

        return self.url_result(
            self._search_regex(r'<meta\s+name="externalVideoUrl"\s+content="([^"]+)"', webpage, 'videoUrl'),
            url_transparent=True, ie=MicrosoftMediusIE, **metainfo, timestamp=parse_iso8601(self._search_regex(
                r'<meta\s+name="startDate"\s+content="([^"]+)"', webpage, 'date', default=None)),
        )


class MicrosoftBuildIE(InfoExtractor):
    _VALID_URL = [
        r'https?://build\.microsoft\.com/[\w\-]+/sessions/(?P<id>[0-9a-f\-]+)',
        r'https?://build\.microsoft\.com/[\w\-]+/(?P<id>sessions)/?(?:[?#]|$)',
    ]

    _TESTS = [{
        'url': 'https://build.microsoft.com/en-US/sessions/b49feb31-afcd-4217-a538-d3ca1d171198?source=sessions',
        'info_dict': {
            'id': 'aee55fb5-fcf9-4b38-b764-a3527cb57554',
            'ext': 'ismv',
            'title': 'Microsoft Build opening keynote',
            'description': 'md5:d38338f336ef4b6ef9ad2a7466a76655',
            'timestamp': 1716307200,
            'upload_date': '20240521',
            'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
        },
    }, {
        'url': 'https://build.microsoft.com/en-US/sessions',
        'info_dict': {
            'id': 'sessions',
        },
        'playlist_mincount': 418,

Review comment (refactor):
```suggestion
class MicrosoftLearnSessionIE(InfoExtractor):
    _VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w\-]+/)?events/[\w\-]+/(?P<id>[^?#/]+)'
    _TESTS = [{
        'url': 'https://learn.microsoft.com/en-us/events/build-2022/ts01-rapidly-code-test-ship-from-secure-cloud-developer-environments',
        'info_dict': {
            'id': '9640d86c-f513-4889-959e-5dace86e7d2b',
            'ext': 'ismv',
            'title': 'Rapidly code, test and ship from secure cloud developer environments - Events',
            'description': 'md5:f26c1a85d41c1cffd27a0279254a25c3',
            'timestamp': 1653408600,
            'upload_date': '20220524',
            'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        metainfo = {
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
            'timestamp': parse_iso8601(self._search_regex(
                r'<meta\s+name="startDate"\s+content="([^"]+)"', webpage, 'date', default=None)),
        }

        return self.url_result(
            self._search_regex(r'<meta\s+name="externalVideoUrl"\s+content="([^"]+)"', webpage, 'videoUrl'),
            url_transparent=True, ie=MicrosoftMediusIE, **metainfo)
```

Code after:
            'timestamp': 1653408600,
            'upload_date': '20220524',
            'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
        },
    }]

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

        metainfo = {
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
            'timestamp': parse_iso8601(self._html_search_meta('startDate', webpage, 'startDate')),
        }

        return self.url_result(
            self._html_search_meta('externalVideoUrl', webpage, 'videoUrl', fatal=True),
            url_transparent=True, ie=MicrosoftMediusIE, **metainfo)


class MicrosoftBuildIE(InfoExtractor):
    _VALID_URL = [
        r'https?://build\.microsoft\.com/[\w-]+/sessions/(?P<id>[\da-f-]+)',
        r'https?://build\.microsoft\.com/[\w-]+/(?P<id>sessions)/?(?:[?#]|$)',
    ]

    _TESTS = [{
        'url': 'https://build.microsoft.com/en-US/sessions/b49feb31-afcd-4217-a538-d3ca1d171198?source=sessions',
        'info_dict': {
            'id': 'aee55fb5-fcf9-4b38-b764-a3527cb57554',
            'ext': 'ismv',
            'title': 'Microsoft Build opening keynote',
            'description': 'md5:d38338f336ef4b6ef9ad2a7466a76655',
            'timestamp': 1716307200,
            'upload_date': '20240521',
            'thumbnail': r're:https://mediusimg\.event\.microsoft\.com/video-\d+/thumbnail\.jpg.*',
        },
    }, {
        'url': 'https://build.microsoft.com/en-US/sessions',
        'info_dict': {
            'id': 'sessions',
        },
        'playlist_mincount': 418,
    }]

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

        entries = [
            self.url_result(