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

Code before:
            'description': 'md5:1218e575eeaff75f48ed978261fa2068',
        },
        'playlist_mincount': 200,
    }]

    _PAGE_SIZE = 30

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

        webpage = self._download_webpage(url, podcast_id, fatal=False)
        metadata = self._extract_metadata(webpage, podcast_id)

        def page_func(page_num):
            api_response = self._download_json(
                f'https://api.tunein.com/profiles/{podcast_id}/contents', podcast_id,
                note=f'Downloading page {page_num + 1}', query={
                    'filter': 't:free',
                    'offset': page_num * self._PAGE_SIZE,
                    'limit': self._PAGE_SIZE,
                })

            return [
                self.url_result(
                    f'https://tunein.com/podcasts/{podcast_id}?topicId={episode["GuideId"][1:]}',
                    ie=TuneInPodcastEpisodeIE, video_title=episode.get('Title'))
                for episode in api_response['Items']]

        entries = OnDemandPagedList(page_func, self._PAGE_SIZE)
        return self.playlist_result(
            entries, playlist_id=podcast_id, playlist_title=traverse_obj(metadata, ('profiles', podcast_id, 'title')),
            playlist_description=traverse_obj(metadata, ('profiles', podcast_id, 'description')))


class TuneInPodcastEpisodeIE(TuneInBaseIE):
    _VALID_URL = TuneInBaseIE._VALID_URL_BASE + r'/podcasts/(?:[^?&]+-)?(?P<podcast_id>p\d+)/?\?topicId=(?P<id>\w\d+)'

    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019/?topicId=236404354',
        'info_dict': {
            'id': 't236404354',
            'title': '#351 \u2013 MrBeast: Future of YouTube, Twitter, TikTok, and Instagram',
            'description': 'md5:f88893125d7bd1be313865923d6b31b9',
            'thumbnail': 're:^https?://[^?&]+/p1153019',
            'timestamp': 1673458571,
            'upload_date': '20230111',
            'series_id': 'p1153019',
            'series': 'Lex Fridman Podcast',
            'ext': 'mp3',
        },
    }]

Review comment (suggestion):
```suggestion
                self.url_result(
                    f'https://tunein.com/podcasts/{podcast_id}?topicId={episode["GuideId"][1:]}',
                    TuneInPodcastEpisodeIE, title=episode.get('Title'))
```

Code after:
            'description': 'md5:1218e575eeaff75f48ed978261fa2068',
        },
        'playlist_mincount': 200,
    }]

    _PAGE_SIZE = 30

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

        webpage = self._download_webpage(url, podcast_id, fatal=False)
        metadata = self._extract_metadata(webpage, podcast_id)

        def page_func(page_num):
            api_response = self._download_json(
                f'https://api.tunein.com/profiles/{podcast_id}/contents', podcast_id,
                note=f'Downloading page {page_num + 1}', query={
                    'filter': 't:free',
                    'offset': page_num * self._PAGE_SIZE,
                    'limit': self._PAGE_SIZE,
                })

            return [
                self.url_result(
                    f'https://tunein.com/podcasts/{podcast_id}?topicId={episode["GuideId"][1:]}',
                    TuneInPodcastEpisodeIE, title=episode.get('Title'))
                for episode in api_response['Items']]

        entries = OnDemandPagedList(page_func, self._PAGE_SIZE)
        return self.playlist_result(
            entries, playlist_id=podcast_id, title=traverse_obj(metadata, ('profiles', podcast_id, 'title')),
            description=traverse_obj(metadata, ('profiles', podcast_id, 'description')))


class TuneInPodcastEpisodeIE(TuneInBaseIE):
    _VALID_URL = TuneInBaseIE._VALID_URL_BASE + r'/podcasts/(?:[^?&]+-)?(?P<podcast_id>p\d+)/?\?topicId=(?P<id>\w\d+)'

    _TESTS = [{
        'url': 'https://tunein.com/podcasts/Technology-Podcasts/Artificial-Intelligence-p1153019/?topicId=236404354',
        'info_dict': {
            'id': 't236404354',
            'title': '#351 \u2013 MrBeast: Future of YouTube, Twitter, TikTok, and Instagram',
            'description': 'md5:e1734db6f525e472c0c290d124a2ad77',
            'thumbnail': 're:^https?://[^?&]+/p1153019',
            'timestamp': 1673458571,
            'upload_date': '20230111',
            'series_id': 'p1153019',
            'series': 'Lex Fridman Podcast',
            'ext': 'mp3',
        },
    }]