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

Code before:
            if mobj is None:
                raise ExtractorError('Could not get video ID; visit the URL manually and use the redirection URL')
            url = mobj.group()
            return {
                '_type': 'url',
                'url': url
            }

        # Sometimes the siteurl is an alias, we get the real one via HTTP
        # redirection (method HEAD does not work here)
        url = self._request_webpage(
            url, None, note='Resolving final URL',
            errnote='Could not resolve final URL').geturl()
        mobj = re.match(self._VALID_URL, url)
        subdomain = mobj.group('subdomain')
        siteurl = mobj.group('site_1') or mobj.group('site_2')
        video_id = mobj.group('id_1') or mobj.group('id_2') or mobj.group('id_3')

        try:
            stream = self._download_json(
                'https://%s.webex.com/webappng/api/v1/recordings/%s/stream' % (subdomain, video_id),
                video_id, query={
                    'siteurl': siteurl
                })
        except ExtractorError:
            self.raise_login_required()

        video_id = stream.get('recordUUID') or video_id

        formats = [{
            'format_id': 'video',
            'url': stream['fallbackPlaySrc'],
            'ext': 'mp4',
            'vcodec': 'avc1.640028',
            'acodec': 'mp4a.40.2',
        }]
        if stream.get('preventDownload') is False:
            mp4url = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['mp4URL'])
            if mp4url is not None:
                formats.append({
                    'format_id': 'video',
                    'url': mp4url,
                    'ext': 'mp4',
                    'vcodec': 'avc1.640028',
                    'acodec': 'mp4a.40.2',
                })
            audiourl = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['audioURL'])
            if audiourl is not None:
                formats.append({
                    'format_id': 'audio',
                    'url': audiourl,

Review comment (suggestion):
Instead of going through a try/except, you can set fatal=False and raise error if stream is None

also, use `raise_login_required(method='cookies')` to give a better error message

Code after:
        video_id = stream.get('recordUUID') or video_id

        formats = [{
            'format_id': 'video',
            'url': stream['fallbackPlaySrc'],
            'ext': 'mp4',
            'vcodec': 'avc1.640028',
            'acodec': 'mp4a.40.2',
        }]
        if stream.get('preventDownload') is False:
            mp4url = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['mp4URL'])
            if mp4url:
                formats.append({
                    'format_id': 'video',
                    'url': mp4url,
                    'ext': 'mp4',
                    'vcodec': 'avc1.640028',
                    'acodec': 'mp4a.40.2',
                })
            audiourl = try_get(stream, lambda x: x['downloadRecordingInfo']['downloadInfo']['audioURL'])
            if audiourl:
                formats.append({
                    'format_id': 'audio',
                    'url': audiourl,
                    'ext': 'mp3',
                    'vcodec': 'none',
                    'acodec': 'mp3',
                })
        self._sort_formats(formats)

        return {
            'id': video_id,
            'title': stream['recordName'],
            'description': stream.get('description'),
            'uploader': stream.get('ownerDisplayName'),
            'uploader_id': stream.get('ownerUserName') or stream.get('ownerId'),  # mail or id
            'timestamp': unified_timestamp(stream.get('createTime')),
            'duration': int_or_none(stream.get('duration'), 1000),
            'webpage_url': 'https://%s.webex.com/recordingservice/sites/%s/recording/playback/%s' % (subdomain, siteurl, video_id),
            'formats': formats,
        }