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

Code before:
class WistiaBaseIE(InfoExtractor):
    _VALID_ID_REGEX = r'(?P<id>[a-z0-9]{10})'
    _VALID_URL_BASE = r'https?://(?:\w+\.)?wistia\.(?:net|com)/(?:embed/)?'
    _EMBED_BASE_URL = 'http://fast.wistia.net/embed/'

    def _download_embed_config(self, config_type, config_id, referer):
        base_url = self._EMBED_BASE_URL + '%s/%s' % (config_type, config_id)
        embed_config = self._download_json(
            base_url + '.json', config_id, headers={
                'Referer': referer if referer.startswith('http') else base_url,  # Some videos require this.
            })

        error = traverse_obj(embed_config, 'error')
        if error:
            raise ExtractorError(
                f'Error while getting the playlist: {error}', expected=True)

        return embed_config

    def _extract_media(self, embed_config):
        data = embed_config['media']
        video_id = data['hashedId']
        title = data['name']

        def get_real_ext(url):
            res = self._request_webpage(HEADRequest(url), None, note=False, errnote=False)
            if res:
                meta_ext = res.headers.get('x-amz-meta-name', '').rpartition('.')[2]
                if meta_ext:
                    return meta_ext
                content_type = res.headers.get('content-type')
                if content_type in ('video/mp4', 'video/quicktime'):
                    return 'mp4'
                elif content_type == 'image/png':
                    return 'png'
                elif content_type == 'image/jpeg':
                    return 'jpg'
            return 'bin'

        formats = []
        thumbnails = []
        for a in data['assets']:
            aurl = a.get('url')
            if not aurl:
                continue
            astatus = a.get('status')
            atype = a.get('type')
            if (astatus is not None and astatus != 2) or atype in ('preview', 'storyboard'):
                continue
            elif atype in ('still', 'still_image'):
                thumbnails.append({

Review comment (suggestion):
note=errnote=False creates a complete lack of feedback. I recommend keeping a note

Also, we need `fatal=False`

Code after:


class WistiaBaseIE(InfoExtractor):
    _VALID_ID_REGEX = r'(?P<id>[a-z0-9]{10})'
    _VALID_URL_BASE = r'https?://(?:\w+\.)?wistia\.(?:net|com)/(?:embed/)?'
    _EMBED_BASE_URL = 'http://fast.wistia.net/embed/'

    def _download_embed_config(self, config_type, config_id, referer):
        base_url = self._EMBED_BASE_URL + '%s/%s' % (config_type, config_id)
        embed_config = self._download_json(
            base_url + '.json', config_id, headers={
                'Referer': referer if referer.startswith('http') else base_url,  # Some videos require this.
            })

        error = traverse_obj(embed_config, 'error')
        if error:
            raise ExtractorError(
                f'Error while getting the playlist: {error}', expected=True)

        return embed_config

    def _get_real_ext(self, url):
        ext = determine_ext(url, default_ext='bin')
        if ext == 'bin':
            urlh = self._request_webpage(
                HEADRequest(url), None, note='Checking media extension',
                errnote='HEAD request returned error', fatal=False)
            if urlh:
                ext = urlhandle_detect_ext(urlh, default='bin')
        return 'mp4' if ext == 'mov' else ext

    def _extract_media(self, embed_config):
        data = embed_config['media']
        video_id = data['hashedId']
        title = data['name']

        formats = []
        thumbnails = []
        for a in data['assets']:
            aurl = a.get('url')
            if not aurl:
                continue
            astatus = a.get('status')
            atype = a.get('type')
            if (astatus is not None and astatus != 2) or atype in ('preview', 'storyboard'):
                continue
            elif atype in ('still', 'still_image'):
                thumbnails.append({
                    'url': aurl.replace('.bin', f'.{self._get_real_ext(aurl)}'),
                    'width': int_or_none(a.get('width')),
                    'height': int_or_none(a.get('height')),