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

Code before:
        }
    }]

    def _extract_episode(self, podcast, episode):
        return {
            'id': str(episode.get('id')),
            'title': episode.get('title'),
            'description': episode.get('description'),
            'url': episode.get('audio_url'),
            'thumbnail': episode.get('image_url'),
            'duration': str_to_int(episode.get('length')),
            'timestamp': unified_timestamp(episode.get('air_date')),
            'rating': float_or_none(episode.get('rating')),
            'categories': list(set(traverse_obj(podcast, (('summary', None), 'categories', ..., 'text')))),
            'tags': traverse_obj(podcast, ('tags', ..., 'text')),
            'series': podcast.get('title'),
        }

    def _real_extract(self, url):
        podcast_id, episode_id = self._match_valid_url(url).group('podcast_id', 'id')
        podcast = self._download_json(self._API_BASE + 'podcasts/%s' % podcast_id, podcast_id)
        episode = self._download_json(self._API_BASE + 'episodes/%s' % episode_id, episode_id)
        return self._extract_episode(podcast, episode)


class PodchaserFeedIE(PodchaserIE):
    IE_NAME = 'Podchaser:feed'
    _VALID_URL = PodchaserIE._VALID_URL_BASE + r'(?P<id>\d+)'
    _TESTS = [{
        'url': 'https://www.podchaser.com/podcasts/the-bone-zone-28853',
        'info_dict': {
            'id': '28853',
            'title': 'The Bone Zone',
            'description': 'Podcast by The Bone Zone',
        },
        'playlist_count': 275
    }, {
        'url': 'https://www.podchaser.com/podcasts/sean-carrolls-mindscape-scienc-699349/episodes',
        'info_dict': {
            'id': '699349',
            'title': 'Sean Carroll\'s Mindscape: Science, Society, Philosophy, Culture, Arts, and Ideas',
            'description': 'md5:2cbd8f4749891a84dc8235342e0b5ff1'
        },
        'playlist_mincount': 225
    }]
    _PAGE_SIZE = 100

    def _fetch_page(self, podcast_id, podcast, page):
        params = {
            'start': page * self._PAGE_SIZE,
            'count': self._PAGE_SIZE,

Review comment (refactor):
Extractors should only inherit from a base extractor. Like:
```py
class PodchaserBaseIE(InfoExtractor):
    def _extract_episode(...): ...

class PodchaserIE(PodchaserBaseIE):
    ...

class PodchaserFeedIE(PodchaserBaseIE):
    ...
```

But here, inheritence isn't even really needed. `_extract_episode`, `_VALID_URL_BASE`, `_API_BASE` can be moved to module level instead since none of them rely on `cls`/`self`

Code after:
        }
    }, {
        'url': 'https://www.podchaser.com/podcasts/the-bone-zone-28853',
        'info_dict': {
            'id': '28853',
            'title': 'The Bone Zone',
            'description': 'Podcast by The Bone Zone',
        },
        'playlist_count': 275
    }, {
        'url': 'https://www.podchaser.com/podcasts/sean-carrolls-mindscape-scienc-699349/episodes',
        'info_dict': {
            'id': '699349',
            'title': 'Sean Carroll\'s Mindscape: Science, Society, Philosophy, Culture, Arts, and Ideas',
            'description': 'md5:2cbd8f4749891a84dc8235342e0b5ff1'
        },
        'playlist_mincount': 225
    }]

    @staticmethod
    def _parse_episode(episode, podcast):
        return {
            'id': str(episode.get('id')),
            'title': episode.get('title'),
            'description': episode.get('description'),
            'url': episode.get('audio_url'),
            'thumbnail': episode.get('image_url'),
            'duration': str_to_int(episode.get('length')),
            'timestamp': unified_timestamp(episode.get('air_date')),
            'rating': float_or_none(episode.get('rating')),
            'categories': list(set(traverse_obj(podcast, (('summary', None), 'categories', ..., 'text')))),
            'tags': traverse_obj(podcast, ('tags', ..., 'text')),
            'series': podcast.get('title'),
        }

    def _call_api(self, path, *args, **kwargs):
        return self._download_json(f'https://api.podchaser.com/{path}', *args, **kwargs)

    def _fetch_page(self, podcast_id, podcast, page):
        json_response = self._call_api(
            'list/episode', podcast_id,
            headers={'Content-Type': 'application/json;charset=utf-8'},
            data=json.dumps({
                'start': page * self._PAGE_SIZE,
                'count': self._PAGE_SIZE,
                'sort_order': 'SORT_ORDER_RECENT',
                'filters': {
                    'podcast_id': podcast_id
                },
                'options': {}
            }).encode())