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

Code before:
            'title': 'O Homem Que Mordeu o Cão',
        },
        'playlist_mincount': 19
    }, {
        'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
        'info_dict': {
            'id': 'as-minhas-coisas-favoritas',
            'title': 'As Minhas Coisas Favoritas',
        },
        'playlist_mincount': 131
    }]

    def _fetch_page(self, podcast, season, page):
        page += 1
        url = urljoin('https://radiocomercial.pt/podcasts/', podcast + (f'/t{season}' if season else '') + f'/{page}')
        playlist_id = join_nonempty(podcast, season, delim='_')
        webpage = self._download_webpage(url, playlist_id, note=f'Downloading page: {page}')

        episodes = set(traverse_obj(get_elements_html_by_class('tm-ouvir-podcast', webpage),
                                    (..., {extract_attributes}, 'href')))
        for entry in episodes:
            yield self.url_result(urljoin('https://radiocomercial.pt', entry), RadioComercialIE)

    def _real_extract(self, url):
        podcast, season = self._match_valid_url(url).group('id', 'season')
        webpage = self._download_webpage(url, podcast)

        name = try_call(lambda: get_element_text_and_html_by_tag('h1', webpage)[0])
        title = name if name == season else join_nonempty(name, season, delim=' - Temporada ')

        return self.playlist_result(OnDemandPagedList(functools.partial(self._fetch_page, podcast, season),
                                                      self._PAGE_SIZE), podcast, title)


Review comment (suggestion):
The playlist id should include the season if there is one. Using only `podcast` isn't correct; e.g. season 1 would share the same id with season 2, and any single season would share the same id with the complete series. Constructing the `playlist_id` here also lets us pass it to the page func

We also need to use `utils.update_url` to strip any possible query/fragment from the URL so that we can pass it to the page func and our f-string in that function will work
```suggestion
        podcast, season = self._match_valid_url(url).group('id', 'season')
        playlist_id = join_nonempty(podcast, season, delim='_')
        url = update_url(url, query=None, fragment=None)
        webpage = self._download_webpage(url, playlist_id)
```

Code after:
    }, {
        'url': 'https://radiocomercial.pt/podcasts/as-minhas-coisas-favoritas',
        'info_dict': {
            'id': 'as-minhas-coisas-favoritas',
            'title': 'As Minhas Coisas Favoritas',
        },
        'playlist_mincount': 131
    }, {
        'url': 'https://radiocomercial.pt/podcasts/tnt-todos-no-top/t2023',
        'info_dict': {
            'id': 'tnt-todos-no-top_t2023',
            'title': 'TNT - Todos No Top - Temporada 2023',
        },
        'playlist_mincount': 39
    }]

    def _entries(self, url, playlist_id):
        for page in itertools.count(1):
            try:
                webpage = self._download_webpage(
                    f'{url}/{page}', playlist_id, f'Downloading page {page}')
            except ExtractorError as e:
                if isinstance(e.cause, HTTPError) and e.cause.status == 404:
                    break
                raise

            episodes = get_elements_html_by_class('tm-ouvir-podcast', webpage)
            if not episodes:
                break
            for url_path in traverse_obj(episodes, (..., {extract_attributes}, 'href')):
                episode_url = urljoin(url, url_path)
                if RadioComercialIE.suitable(episode_url):
                    yield episode_url

    def _real_extract(self, url):
        podcast, season = self._match_valid_url(url).group('id', 'season')
        playlist_id = join_nonempty(podcast, season, delim='_t')
        url = update_url(url, query=None, fragment=None)
        webpage = self._download_webpage(url, playlist_id)

        name = try_call(lambda: get_element_text_and_html_by_tag('h1', webpage)[0])
        title = name if name == season else join_nonempty(name, season, delim=' - Temporada ')

        return self.playlist_from_matches(
            self._entries(url, playlist_id), playlist_id, title, ie=RadioComercialIE)