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

Code before:


class PeerTubeBaseIE(InfoExtractor):
    _API_BASE = 'https://%s/api/v1/%s/%s%s'
    _PAGE_SIZE = 30

    def call_api(self, host, name, path, base, note=None, **kwargs):
        return self._download_json(
            self._API_BASE % (host, base, name, path), name,
            note=note, **kwargs)

    def fetch_page(self, host, uuid, type, page):
        page += 1
        video_data = self.call_api(
            host, uuid,
            f'/videos?sort=-createdAt&start={self._PAGE_SIZE * (page - 1)}&count={self._PAGE_SIZE}&nsfw=both',
            type, note=f'Downloading page {page}').get('data', [])
        for video in video_data:
            shortUUID = video.get('shortUUID') or try_get(video, lambda x: x['video']['shortUUID'])
            video_title = video.get('name') or try_get(video, lambda x: x['video']['name'])
            yield self.url_result(
                f'https://{host}/w/{shortUUID}', PeerTubeIE.ie_key(),
                video_id=shortUUID, video_title=video_title)


class PeerTubePlaylistIE(PeerTubeBaseIE, InfoExtractor):
    IE_NAME = 'PeerTube:Playlist'
    _VALID_URL = r'''(?x)
                    (?:
                        https?://(?P<host>%s)/w/p/
                    )
                    (?P<id>%s)
                    ''' % (PeerTubeIE._INSTANCES_RE, PeerTubeIE._UUID_RE)
    _TESTS = [{
        'url': 'https://peertube.tux.ovh/w/p/3af94cba-95e8-4b74-b37a-807ab6d82526',
        'info_dict': {
            'id': '3af94cba-95e8-4b74-b37a-807ab6d82526',
            'description': 'playlist',
            'timestamp': 1611171863,
            'title': 'playlist',
        },
        'playlist_mincount': 6,
    }, {
        'url': 'https://peertube.tux.ovh/w/p/wkyqcQBnsvFxtUB2pkYc1e',
        'info_dict': {
            'id': 'wkyqcQBnsvFxtUB2pkYc1e',
            'description': 'Cette liste de vidéos contient uniquement les jeux qui peuvent être terminés en une seule vidéo.',
            'title': 'Let\'s Play',
            'timestamp': 1604147331,
        },
        'playlist_mincount': 6,

Review comment (suggestion):
```suggestion
class PeerTubePlaylistIE(PeerTubeBaseIE):
```
same below

Code after:


class PeerTubePlaylistIE(InfoExtractor):
    IE_NAME = 'PeerTube:Playlist'
    _TYPES = {
        'a': 'accounts',
        'c': 'video-channels',
        'w/p': 'video-playlists',
    }
    _VALID_URL = r'''(?x)
                        https?://(?P<host>%s)/(?P<type>(?:%s))/
                    (?P<id>[^/]+)
                    ''' % (PeerTubeIE._INSTANCES_RE, '|'.join(_TYPES.keys()))
    _TESTS = [{
        'url': 'https://peertube.tux.ovh/w/p/3af94cba-95e8-4b74-b37a-807ab6d82526',
        'info_dict': {
            'id': '3af94cba-95e8-4b74-b37a-807ab6d82526',
            'description': 'playlist',
            'timestamp': 1611171863,
            'title': 'playlist',
        },
        'playlist_mincount': 6,
    }, {
        'url': 'https://peertube.tux.ovh/w/p/wkyqcQBnsvFxtUB2pkYc1e',
        'info_dict': {
            'id': 'wkyqcQBnsvFxtUB2pkYc1e',
            'description': 'Cette liste de vidéos contient uniquement les jeux qui peuvent être terminés en une seule vidéo.',
            'title': 'Let\'s Play',
            'timestamp': 1604147331,
        },
        'playlist_mincount': 6,
    }, {
        'url': 'https://peertube.debian.social/w/p/hFdJoTuyhNJVa1cDWd1d12',
        'info_dict': {
            'id': 'hFdJoTuyhNJVa1cDWd1d12',
            'description': 'Diversas palestras do Richard Stallman no Brasil.',
            'title': 'Richard Stallman no Brasil',
            'timestamp': 1599676222,
        },
        'playlist_mincount': 9,
    }, {
        'url': 'https://peertube2.cpy.re/a/chocobozzz/videos',
        'info_dict': {
            'id': 'chocobozzz',
            'timestamp': 1553874564,
            'title': 'chocobozzz',
        },
        'playlist_mincount': 2,
    }, {
        'url': 'https://framatube.org/c/bf54d359-cfad-4935-9d45-9d6be93f63e8/videos',
        'info_dict': {