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

Code before:
            '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,
    }]

    def _real_extract(self, url):
        host, playlist_id = self._match_valid_url(url).group('host', 'id')
        playlist_info = self.call_api(host, playlist_id, '', 'video-playlists', note='Downloading playlist information', fatal=False)

        playlist_title = playlist_info.get('displayName')
        playlist_description = playlist_info.get('description')
        playlist_timestamp = unified_timestamp(playlist_info.get('createdAt'))
        channel = try_get(playlist_info, lambda x: x['ownerAccount']['name'])
        channel_id = try_get(playlist_info, lambda x: x['ownerAccount']['id'])
        thumbnail = playlist_info.get('thumbnailPath')
        thumbnail = f'https://{host}{thumbnail}'

        entries = OnDemandPagedList(functools.partial(
            self.fetch_page, host, playlist_id, 'video-playlists'), self._PAGE_SIZE)

        return self.playlist_result(
            entries, playlist_id, playlist_title, playlist_description,
            timestamp=playlist_timestamp, channel=channel, channel_id=channel_id, thumbnail=thumbnail)


class PeerTubeChannelIE(PeerTubeBaseIE, InfoExtractor):
    IE_NAME = 'PeerTube:Channel'
    _VALID_URL = r'(?x)https?://(?P<host>%s)/(?P<type>[ac])/(?P<id>[^/]+)/(videos|video-channels)' % PeerTubeIE._INSTANCES_RE
    _TESTS = [{
        'url': 'https://peertube2.cpy.re/a/chocobozzz/videos',
        'info_dict': {

Review comment (suggestion):
Seems same as channelIE except type is hardcoded to `video-playlists`

Code after:
            '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': {
            'id': 'bf54d359-cfad-4935-9d45-9d6be93f63e8',
            'timestamp': 1519917377,
            'title': 'Les vidéos de Framasoft',
        },
        'playlist_mincount': 345,
    }, {
        'url': 'https://peertube2.cpy.re/c/blender_open_movies@video.blender.org/videos',
        'info_dict': {
            'id': 'blender_open_movies@video.blender.org',
            'timestamp': 1542287810,
            'title': 'Official Blender Open Movies',
        },
        'playlist_mincount': 11,
    }]
    _API_BASE = 'https://%s/api/v1/%s/%s%s'
    _PAGE_SIZE = 30

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

    def fetch_page(self, host, id, type, page):
        page += 1
        video_data = self.call_api(
            host, id,
            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)

    def _extract_playlist(self, host, type, id):
        info = self.call_api(host, id, '', type, note='Downloading playlist information', fatal=False)