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

Code before:
        },
        'playlist_count': 20,
    }]

    def _entries(self, url_base, video_id):
        skip = 0
        while True:
            playlist_info = self._download_json(f'{url_base}&$skip={skip}', video_id, f'Downloading entries {skip}')
            items = traverse_obj(playlist_info, (
                'results', ..., 'url', {lambda x: self.url_result(f'https://learn.microsoft.com/en-us{x}')}))
            yield from items
            skip += len(items)
            if skip >= playlist_info['count'] or not items:
                break

    def _real_extract(self, url):
        video_type, 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 slug:
            if video_type == 'events':
                return self.url_result(
                    self._search_regex(r'<meta\s+name="externalVideoUrl"\s+content="([^"]+)"', webpage, 'videoUrl'), url_transparent=True, **metainfo, **{
                        'timestamp': parse_iso8601(self._search_regex(
                            r'<meta\s+name="startDate"\s+content="([^"]+)"', webpage, 'date', default=None)),
                    })
            else:
                entry_id = self._search_regex(r'<meta name="entryId" content="([^"]+)"', webpage, 'entryId')
                video_info = self._download_json(
                    f'https://learn.microsoft.com/api/video/public/v1/entries/{entry_id}', video_id)
                return {
                    'id': entry_id,
                    'formats': self._extract_ism(video_info['publicVideo']['adaptiveVideoUrl'], video_id),
                    'subtitles': self._sub_to_dict(traverse_obj(video_info, ('publicVideo', 'captions', ..., {
                        'tag': ('language', {str}),
                        'url': ('url', {url_or_none}),
                    }))),
                    **metainfo,
                    **traverse_obj(video_info, {
                        'timestamp': ('createTime', {parse_iso8601}),
                        'thumbnails': ('publicVideo', 'thumbnailOtherSizes', ..., {lambda x: {'url': x}}),
                    }),
                }
        else:
            url_base = f'https://learn.microsoft.com/api/contentbrowser/search/{video_type}/{series}/{"sessions" if video_type == "events" else "episodes"}?locale=en-us'

Review comment (suggestion):
We cuold use early exit here:
```py
if not slug:
    url_base = ...
    return self._playlist_result(...)

if video_type == 'events':
    return self.url_result(...)

entry_id = ...
...
```

Code after:
            if skip >= playlist_info.get('count', 0) or not url_paths:
                break

    def _real_extract(self, url):
        playlist_id, playlist_type = self._match_valid_url(url).group('id', 'type')
        webpage = self._download_webpage(url, playlist_id)

        metainfo = {
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
        }
        sub_type = 'episodes' if playlist_type == 'shows' else 'sessions'

        url_base = f'https://learn.microsoft.com/api/contentbrowser/search/{playlist_type}/{playlist_id}/{sub_type}'
        return self.playlist_result(self._entries(url_base, playlist_id), playlist_id, **metainfo)


class MicrosoftLearnEpisodeIE(MicrosoftMediusBaseIE):
    _VALID_URL = r'https?://learn\.microsoft\.com/(?:[\w-]+/)?shows/[\w-]+/(?P<id>[^?#/]+)'
    _TESTS = [{
        'url': 'https://learn.microsoft.com/en-us/shows/bash-for-beginners/what-is-the-difference-between-a-terminal-and-a-shell-2-of-20-bash-for-beginners/',
        'info_dict': {
            'id': 'd44e1a03-a0e5-45c2-9496-5c9fa08dc94c',
            'ext': 'ismv',
            'title': 'What is the Difference Between a Terminal and a Shell? (Part 2 of 20)',
            'description': 'md5:7bbbfb593d21c2cf2babc3715ade6b88',
            'timestamp': 1676339547,
            'upload_date': '20230214',
            'thumbnail': r're:https://learn\.microsoft\.com/video/media/.*\.png',
            'subtitles': 'count:14',
        },
    }]

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

        entry_id = self._html_search_meta('entryId', webpage, 'entryId', fatal=True)
        video_info = self._download_json(
            f'https://learn.microsoft.com/api/video/public/v1/entries/{entry_id}', video_id)
        return {
            'id': entry_id,
            'formats': self._extract_ism(video_info['publicVideo']['adaptiveVideoUrl'], video_id),
            'subtitles': self._sub_to_dict(traverse_obj(video_info, (
                'publicVideo', 'captions', lambda _, v: url_or_none(v['url']), {
                    'tag': ('language', {str}),
                    'url': 'url',
                }))),
            'title': self._og_search_title(webpage),
            'description': self._og_search_description(webpage),
            **traverse_obj(video_info, {