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

Code before:
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        # Extract the JSON
        json_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['ssr_data_showreel']

        # Get the broadcast URL and the recording hash.
        # The full URL is {broadcast_url}/{recording_hash}.mp3
        broadcast_url = json_info.get('broadcast_url')
        recording_hash = json_info.get('recording_hash')
        url = broadcast_url + recording_hash + ".mp3"

        # Get broadcast title
        broadcast_title = json_info.get('broadcast_title') or self._og_search_title(webpage)

        # Get dates
        start_date = json_info.get('start_date')
        if 'start_date' != '':
            start_date = start_date.replace('Z', '')

        end_date = json_info.get('end_date')
        if 'end_date' != '':
            end_date = end_date.replace('Z', '')

        # Get broadcast date
        upload_date = None
        if start_date is not None:
            upload_date = start_date.split('T')[0].replace('-', '')

        # Get author (AKA show host)
        uploader = json_info.get('user_name')

        # Get the co-hosts/guests
        if uploader != '':
            guests = [uploader]
        else:
            guests = []

        guests_json = json_info.get('guests_json')
        if guests_json != '':
            for guest in self._parse_json(json_info['guests_json'], video_id):
                guests.append(guest['name'])

        # Parse the duration of the stream
        parsed_duration = None
        if start_date != '' and end_date != '':
            duration = datetime.fromisoformat(end_date) - datetime.fromisoformat(start_date)
            parsed_duration = int(parse_duration(str(duration)))

Review comment (bug):
Please correct me if i'm wrong, i think `start_date` and `end_date` can parsed with `parse_iso8601` from `utils`

Code after:
            'duration': 7918,
            'cast': ['Devonanustart', 'Phonelosers'],
            'description': '',
            'categories': ['prank'],
            'tags': ['prank call', 'prank'],
            'upload_date': '20220825'
        }
    }]

    def _real_extract(self, url):
        video_id, display_id = self._match_valid_url(url).group('id', 'display_id')

        webpage = self._download_webpage(url, video_id)
        json_info = self._search_nextjs_data(webpage, video_id)['props']['pageProps']['ssr_data_showreel']

        uploader = json_info.get('user_name')
        guests_json = self._parse_json(json_info.get('guests_json') or '{}', video_id)
        start_date = parse_iso8601(json_info.get('start_date'))

        return {
            'id': video_id,
            'title': json_info.get('broadcast_title') or self._og_search_title(webpage),
            'display_id': display_id,
            'url': f'{json_info["broadcast_url"]}{json_info["recording_hash"]}.mp3',
            'timestamp': start_date,
            'uploader': uploader,
            'channel_id': json_info.get('user_id'),
            'duration': try_call(lambda: parse_iso8601(json_info['end_date']) - start_date),
            'cast': list(filter(None, [uploader] + traverse_obj(guests_json, (..., 'name')))),
            'description': json_info.get('broadcast_description'),
            'categories': [json_info.get('broadcast_category')],
            'tags': self._parse_json(json_info.get('broadcast_tags') or '{}', video_id)
        }