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

Code before:
            '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',
            'yt_views': 30402,
            'category': 'News & Politics',
        }
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        # Use most data from archive.org (extractor indirection)
        # But try first to gather a couple of useful information from altcensored
        webpage = self._download_webpage(url, video_id)
        yt_views = int_or_none(self._html_search_regex(
            r'YouTube Views:.*?([0-9,.]+)', webpage, 'view count', default='0').replace(',', ''))
        category = self._html_search_regex(r'<a href="/category/.*?\n\s+([^<]+)', webpage, 'category')
        # Hardcoded (very unlikely to need a change in a foreseeable future)
        res = self.url_result(f'https://archive.org/details/youtube-{video_id}', ArchiveOrgIE, url_transparent=True,
                              yt_views=yt_views, category=category)
        return res


class AltCensoredChannelIE(InfoExtractor):
    _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',
            'id': 'UC9CcJ96HKMWn0LZlcxlpFTw',
        },
        'playlist_count': 4
    }]

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

        webpage = self._download_webpage(url, channel_id, note='Download channel info',

Review comment (suggestion):
We can directly return res instead of creating a single use variable. We should also use the proper variable names for the info dict.
```suggestion
        return self.url_result(f'https://archive.org/details/youtube-{video_id}', ArchiveOrgIE, url_transparent=True,
                               view_count=yt_views, categories=[category])
```

Code after:
            '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',
            'id': 'UC9CcJ96HKMWn0LZlcxlpFTw',
        },
        'playlist_count': 4
    }]