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

Code before:
        'playlist_mincount': 50
    }]

    def _real_extract(self, url):
        username, story_id = self._match_valid_url(url).groups()

        story_info_url = f'{username}/{story_id}/?__a=1' if username == 'highlights' else f'{username}/?__a=1'
        story_info = self._download_json(f'https://www.instagram.com/stories/{story_info_url}', story_id, headers={
            'X-IG-App-ID': 936619743392459,
            'X-ASBD-ID': 198387,
            'X-IG-WWW-Claim': 0,
            'X-Requested-With': 'XMLHttpRequest',
            'Referer': url,
        })
        user_id = story_info['user']['id']
        highlight_title = traverse_obj(story_info, ('highlight', 'title'))

        story_info_url = user_id if username != 'highlights' else f'highlight:{story_id}'
        videos = self._download_json(f'https://i.instagram.com/api/v1/feed/reels_media/?reel_ids={story_info_url}', story_id, headers={
            'X-IG-App-ID': 936619743392459,
            'X-ASBD-ID': 198387,
            'X-IG-WWW-Claim': 0,
        })['reels']
        entites = []

        videos = traverse_obj(videos, (f'highlight:{story_id}', 'items')) or traverse_obj(videos, (str(user_id), 'items'))
        for video_info in videos:
            formats = []
            if isinstance(video_info, list):
                video_info = video_info[0]
            vcodec = video_info.get('video_codec')
            dash_manifest_raw = video_info.get('video_dash_manifest')
            videos_list = video_info.get('video_versions')
            if not (dash_manifest_raw or videos_list):
                continue
            for format in videos_list:
                formats.append({
                    'url': format.get('url'),
                    'width': format.get('width'),
                    'height': format.get('height'),
                    'vcodec': vcodec,
                })
            if dash_manifest_raw:
                formats.extend(self._parse_mpd_formats(self._parse_xml(dash_manifest_raw, story_id), mpd_id='dash'))
            self._sort_formats(formats)
            thumbnails = []
            thumbnails_list = traverse_obj(video_info, ('image_versions2', 'candidates')) or []
            for thumbnail in thumbnails_list:
                thumbnails.append({
                    'url': thumbnail.get('url'),
                    'width': thumbnail.get('width'),

Review comment (suggestion):
```suggestion
        videos = traverse_obj(videos, (f'highlight:{story_id}', 'items'), (str(user_id), 'items'))
```

Code after:
        'playlist_mincount': 50
    }]

    def _real_extract(self, url):
        username, story_id = self._match_valid_url(url).groups()

        story_info_url = f'{username}/{story_id}/?__a=1' if username == 'highlights' else f'{username}/?__a=1'
        story_info = self._download_json(f'https://www.instagram.com/stories/{story_info_url}', story_id, headers={
            'X-IG-App-ID': 936619743392459,
            'X-ASBD-ID': 198387,
            'X-IG-WWW-Claim': 0,
            'X-Requested-With': 'XMLHttpRequest',
            'Referer': url,
        })
        user_id = story_info['user']['id']
        highlight_title = traverse_obj(story_info, ('highlight', 'title'))

        story_info_url = user_id if username != 'highlights' else f'highlight:{story_id}'
        videos = self._download_json(f'https://i.instagram.com/api/v1/feed/reels_media/?reel_ids={story_info_url}', story_id, headers={
            'X-IG-App-ID': 936619743392459,
            'X-ASBD-ID': 198387,
            'X-IG-WWW-Claim': 0,
        })['reels']
        entites = []

        videos = traverse_obj(videos, (f'highlight:{story_id}', 'items'), (str(user_id), 'items'))
        for video_info in videos:
            formats = []
            if isinstance(video_info, list):
                video_info = video_info[0]
            vcodec = video_info.get('video_codec')
            dash_manifest_raw = video_info.get('video_dash_manifest')
            videos_list = video_info.get('video_versions')
            if not (dash_manifest_raw or videos_list):
                continue
            for format in videos_list:
                formats.append({
                    'url': format.get('url'),
                    'width': format.get('width'),
                    'height': format.get('height'),
                    'vcodec': vcodec,
                })
            if dash_manifest_raw:
                formats.extend(self._parse_mpd_formats(self._parse_xml(dash_manifest_raw, story_id), mpd_id='dash'))
            self._sort_formats(formats)
            thumbnails = [{
                'url': thumbnail.get('url'),
                'width': thumbnail.get('width'),
                'height': thumbnail.get('height')
            } for thumbnail in traverse_obj(video_info, ('image_versions2', 'candidates')) or []]
            entites.append({