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

Code before:
            'description': 'Official Recording of Senate Proceedings from the Australian Parliament',
            'thumbnail': 'https://aphbroadcasting-prod.z01.azurefd.net/vod-storage/vod-logos/SenateParlview06.jpg',
            'upload_date': '20250326',
            'uploader': 'Australian Parliament House',
        },
        'params': {
            'skip_download': True,
        },
    }, {
        'url': 'https://www.aph.gov.au/News_and_Events/Watch_Read_Listen/ParlView/video/3406614',
        'only_matching': True,
    }]
    _API_URL = 'https://vodapi.aph.gov.au/api/search/parlview/%s'

    def _real_extract(self, url):
        video_id = self._match_id(url)
        api_data = self._download_json(self._API_URL % video_id, video_id)
        if not api_data:
            self.raise_no_formats('Failed to retrieve API data')

        if not api_data.get('wasSuccessful'):
            self.raise_no_formats('API request was not successful')

        video_details = api_data.get('videoDetails')
        if not video_details:
            self.raise_no_formats('No video details found')

        files_data = video_details.get('files')
        if not files_data:
            self.raise_no_formats('No files data found')

        file_info = files_data.get('file')
        if not file_info:
            self.raise_no_formats('No file information found')

        m3u8_url = file_info.get('url')
        if not m3u8_url:
            self.raise_no_formats('No M3U8 URL found')

        formats = self._extract_m3u8_formats(m3u8_url, video_id, 'mp4', 'm3u8_native')

        # Parse duration from duration string (format: "HH:MM:SS:FF")
        duration_str = file_info.get('duration')
        duration = None
        if duration_str:
            # Convert "HH:MM:SS:FF" to seconds (ignoring frames)
            try:
                time_parts = duration_str.split(':')
                if len(time_parts) >= 3:
                    hours = int(time_parts[0])
                    minutes = int(time_parts[1])

Review comment (refactor):
At this point the error isn't just a lack of formats, so `raise ExtractorError(...)` is more appropriate. If a useful message is included when not `wasSuccesful`, it could be spliced into the raised error message.
```suggestion
        video_details = traverse_obj(api_data, ('videoDetails', {dict}))
        if not video_details:
            raise ExtractorError('API request was not successful',
                                 expected=traverse_obj(api_data, ('wasSuccessful', {bool})) is False)
```

Code after:
            'description': 'Official Recording of Senate Proceedings from the Australian Parliament',
            'thumbnail': 'https://aphbroadcasting-prod.z01.azurefd.net/vod-storage/vod-logos/SenateParlview06.jpg',
            'upload_date': '20250325',
            'duration': 17999,
            'timestamp': 1742939400,
        },
        'params': {
            'skip_download': True,
        },
    }, {
        'url': 'https://www.aph.gov.au/News_and_Events/Watch_Read_Listen/ParlView/video/SV1394.dv',
        'info_dict': {
            'id': 'SV1394.dv',
            'ext': 'mp4',
            'title': 'Senate Select Committee on Uranium Mining and Milling [Part 1]',
            'description': 'Official Recording of Senate Committee Proceedings from the Australian Parliament',
            'thumbnail': 'https://aphbroadcasting-prod.z01.azurefd.net/vod-storage/vod-logos/CommitteeThumbnail06.jpg',
            'upload_date': '19960822',
            'duration': 14765,
            'timestamp': 840754200,
        },
        'params': {
            'skip_download': True,
        },
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        video_details = self._download_json(
            f'https://vodapi.aph.gov.au/api/search/parlview/{video_id}', video_id)['videoDetails']

        formats, subtitles = self._extract_m3u8_formats_and_subtitles(
            video_details['files']['file']['url'], video_id, 'mp4')

        DURATION_RE = re.compile(r'(?P<duration>\d+:\d+:\d+):\d+')

        return {
            'id': video_id,
            'formats': formats,
            'subtitles': subtitles,
            **traverse_obj(video_details, {
                'title': (('parlViewTitle', 'title'), {str}, any),
                'description': ('parlViewDescription', {str}),
                'duration': ('files', 'file', 'duration', {DURATION_RE.fullmatch}, 'duration', {parse_duration}),
                'timestamp': ('recordingFrom', {parse_iso8601}),
                'thumbnail': ('thumbUrl', {url_or_none}),
            }),
        }