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

Code before:
            "title": "QUELLES SONT LES CONSÉQUENCES DE L'HYPERSEXUALISATION DE LA SOCIÉTÉ ?",
            'display_id': 'k0srjLSkga8.webm',
            'release_date': '20180403',
            'creator': 'Virginie Vota',
            'release_year': 2018,
            'upload_date': '20230318',
            'uploader': 'admin@altcensored.com',
            'description': 'md5:0b38a8fc04103579d5c1db10a247dc30',
            'timestamp': 1679161343,
            'track': 'k0srjLSkga8',
            'duration': 926.09,
            'thumbnail': 'https://archive.org/download/youtube-k0srjLSkga8/youtube-k0srjLSkga8.thumbs/k0srjLSkga8_000925.jpg',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        res = self.url_result('https://archive.org/details/youtube-%s' % video_id, ArchiveOrgIE)
        # Extractor indirection doesn't allow merging info from the original extractor.
        # Youtube view count or thumbnail extracted from altcensored can't be merge back
        # into underlying archive.org info json
        return res


class AltCensoredChannelIE(InfoExtractor):
    _VALID_URL = r'https?://(?:www\.)altcensored\.com/channel/(?P<id>[^/?#]+)'
    _PAGE_SIZE = 24
    _TESTS = [{
        'url': 'https://www.altcensored.com/channel/UCFPTO55xxHqFqkzRZHu4kcw',
        'info_dict': {
            'title': 'Virginie Vota Channel (91 Censored Videos)',
            'id': 'UCFPTO55xxHqFqkzRZHu4kcw',
        },
        'playlist_count': 91
    }]

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

        webpage = self._download_webpage(url, channel_id, note='Download channel info',
                                         errnote='Unable to get channel info')
        title = self._html_search_meta('og:title', webpage)
        page_count = int(self._html_search_regex(r'<a href="/channel/\w+/page/(\d+)">(?:\1)</a>', webpage, 'page count'))

        def page_func(page_num):
            webpage = self._download_webpage(
                'https://altcensored.com/channel/%s/page/%d' % (channel_id, page_num + 1),
                channel_id, note='Download page #%d' % (page_num + 1),
                errnote='Unable to get page #%d' % (page_num + 1),
            )


Review comment (suggestion):
We also need to exclude the list of all channels and the table view
```suggestion
    _VALID_URL = r'https?://(?:www\.)altcensored\.com/channel/(?!page|table)(?P<id>[^/?#]+)'
```

Code after:
        'info_dict': {
            'id': 'youtube-k0srjLSkga8',
            'ext': 'webm',
            'title': "QUELLES SONT LES CONSÉQUENCES DE L'HYPERSEXUALISATION DE LA SOCIÉTÉ ?",
            'display_id': 'k0srjLSkga8.webm',
            'release_date': '20180403',
            'creator': 'Virginie Vota',
            'release_year': 2018,
            'upload_date': '20230318',
            'uploader': 'admin@altcensored.com',
            'description': 'md5:0b38a8fc04103579d5c1db10a247dc30',
            'timestamp': 1679161343,
            'track': 'k0srjLSkga8',
            'duration': 926.09,
            'thumbnail': 'https://archive.org/download/youtube-k0srjLSkga8/youtube-k0srjLSkga8.thumbs/k0srjLSkga8_000925.jpg',
            'view_count': int,
            'categories': ['News & Politics'],
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        return {
            '_type': 'url_transparent',
            'url': f'https://archive.org/details/youtube-{video_id}',
            'ie_key': ArchiveOrgIE.ie_key(),
            'view_count': str_to_int(self._html_search_regex(
                r'YouTube Views:(?:\s|&nbsp;)*([\d,]+)', webpage, 'view count', default=None)),
            'categories': self._html_search_regex(
                r'<a href="/category/\d+">\s*\n?\s*([^<]+)</a>',
                webpage, 'category', default='').split() or None,
        }


class AltCensoredChannelIE(InfoExtractor):
    IE_NAME = 'altcensored:channel'
    _VALID_URL = r'https?://(?:www\.)?altcensored\.com/channel/(?!page|table)(?P<id>[^/?#]+)'
    _PAGE_SIZE = 24
    _TESTS = [{
        'url': 'https://www.altcensored.com/channel/UCFPTO55xxHqFqkzRZHu4kcw',
        'info_dict': {
            'title': 'Virginie Vota',
            'id': 'UCFPTO55xxHqFqkzRZHu4kcw',
        },
        'playlist_count': 91
    }, {
        'url': 'https://altcensored.com/channel/UC9CcJ96HKMWn0LZlcxlpFTw',
        'info_dict': {
            'title': 'yukikaze775',