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

Code before:

    def _real_extract(self, url):
        video_uuid = self._match_id(url)
        metadata = self._download_json(self._VIDEO_METADATA_URL % video_uuid, video_uuid)

        video_id = None
        title = None
        for section in metadata.get('sections', {}):
            if section.get('type') == 'Player':
                video_id = section.get('video')
            if section.get('type') == 'VideoDetail':
                title = section.get('name')
                description = section.get('description')

        if not video_id:
            raise ExtractorError('Video ID not found in metadata')
        if not title:
            raise ExtractorError('Title not found in metadata')

        return {
            '_type': 'url_transparent',
            'url': self._BC_URL % video_id,
            'ie_key': 'BrightcoveNew',
            'title': title,
            'description': description,
        }


class NetAppCollectionIE(NetAppBaseIE):
    _VALID_URL = r'https?://media\.netapp\.com/collection/(?P<id>[0-9a-f-]+)'
    _TESTS = [{
        'url': 'https://media.netapp.com/collection/9820e190-f2a6-47ac-9c0a-98e5e64234a4',
        'info_dict': {
            'title': 'Featured sessions',
            'id': '9820e190-f2a6-47ac-9c0a-98e5e64234a4',
        },
        'playlist_count': 4,
    }]

    def _entries(self, metadata):
        for item in metadata.get('items', {}):
            video_id = item.get('brightcoveVideoId')
            yield {
                '_type': 'url_transparent',
                'url': self._BC_URL % video_id,
                'ie_key': 'BrightcoveNew',
                'title': item.get('name'),
            }

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

Review comment (refactor):
And then we can inline the metadata extraction 
```suggestion
        return self.url_result(
            self._BC_URL_TMPL.format(brightcove_video_id), BrightcoveNewIE, brightcove_video_id,
            url_transparent=True,
            **traverse_obj(metadata, ('sections', lambda _, v: v['type'] == 'VideoDetail', any, {
                'title': ('name', {str}),
                'description': ('description', {str}),
                'timestamp': ('createdAt', {parse_iso8601}),
            })))
```

Code after:
            'timestamp': 1758213949,
            'upload_date': '20250918',
        },
    }, {
        'url': 'https://media.netapp.com/video-detail/45593e5d-cf1c-5996-978c-c9081906e69f/unleash-ai-innovation-with-your-data-with-the-netapp-platform',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_uuid = self._match_id(url)
        metadata = self._download_json(
            f'https://api.media.netapp.com/client/detail/{video_uuid}', video_uuid)

        brightcove_video_id = traverse_obj(metadata, (
            'sections', lambda _, v: v['type'] == 'Player', 'video', {str}, any, {require('brightcove video id')}))

        video_item = traverse_obj(metadata, ('sections', lambda _, v: v['type'] == 'VideoDetail', any))

        return self.url_result(
            self._BC_URL.format(brightcove_video_id), BrightcoveNewIE, brightcove_video_id,
            url_transparent=True, **self._parse_metadata(video_item))


class NetAppCollectionIE(NetAppBaseIE):
    _VALID_URL = r'https?://media\.netapp\.com/collection/(?P<id>[0-9a-f-]+)'
    _TESTS = [{
        'url': 'https://media.netapp.com/collection/9820e190-f2a6-47ac-9c0a-98e5e64234a4',
        'info_dict': {
            'title': 'Featured sessions',
            'id': '9820e190-f2a6-47ac-9c0a-98e5e64234a4',
        },
        'playlist_count': 4,
    }]

    def _entries(self, metadata):
        for item in traverse_obj(metadata, ('items', lambda _, v: v['brightcoveVideoId'])):
            brightcove_video_id = item['brightcoveVideoId']
            yield self.url_result(
                self._BC_URL.format(brightcove_video_id), BrightcoveNewIE, brightcove_video_id,
                url_transparent=True, **self._parse_metadata(item))

    def _real_extract(self, url):
        collection_uuid = self._match_id(url)
        metadata = self._download_json(
            f'https://api.media.netapp.com/client/collection/{collection_uuid}', collection_uuid)

        return self.playlist_result(self._entries(metadata), collection_uuid, playlist_title=metadata.get('name'))