Compare commits

..

7 Commits

Author SHA1 Message Date
Raphaël Droz
6a2a913e7e
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 11:08:04 -03:00
Raphaël Droz
b4866129f7
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 11:07:11 -03:00
Raphaël Droz
079dcb77ee
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 11:00:52 -03:00
Raphaël Droz
a0b78ac304
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 10:59:38 -03:00
Raphaël Droz
20c4bdf5e7
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 10:59:06 -03:00
Raphaël Droz
6ab829d919
case where a channel has a single page
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 10:58:21 -03:00
Raphaël Droz
4530c2d36c
Update yt_dlp/extractor/altcensored.py
Co-authored-by: sepro <4618135+seproDev@users.noreply.github.com>
2023-11-12 10:56:33 -03:00

View File

@ -33,7 +33,7 @@ class AltCensoredIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
res = self.url_result('https://archive.org/details/youtube-%s' % video_id, ArchiveOrgIE) res = self.url_result(f'https://archive.org/details/youtube-{video_id}', ArchiveOrgIE)
# Extractor indirection doesn't allow merging info from the original extractor. # Extractor indirection doesn't allow merging info from the original extractor.
# Youtube view count or thumbnail extracted from altcensored can't be merge back # Youtube view count or thumbnail extracted from altcensored can't be merge back
# into underlying archive.org info json # into underlying archive.org info json
@ -41,7 +41,7 @@ class AltCensoredIE(InfoExtractor):
class AltCensoredChannelIE(InfoExtractor): class AltCensoredChannelIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)altcensored\.com/channel/(?P<id>[^/?#]+)' _VALID_URL = r'https?://(?:www\.)altcensored\.com/channel/(?!page|table)(?P<id>[^/?#]+)'
_PAGE_SIZE = 24 _PAGE_SIZE = 24
_TESTS = [{ _TESTS = [{
'url': 'https://www.altcensored.com/channel/UCFPTO55xxHqFqkzRZHu4kcw', 'url': 'https://www.altcensored.com/channel/UCFPTO55xxHqFqkzRZHu4kcw',
@ -57,20 +57,20 @@ class AltCensoredChannelIE(InfoExtractor):
webpage = self._download_webpage(url, channel_id, note='Download channel info', webpage = self._download_webpage(url, channel_id, note='Download channel info',
errnote='Unable to get channel info') errnote='Unable to get channel info')
title = self._html_search_meta('og:title', webpage) title = self._html_search_meta('altcen_title', webpage, 'title', fatal=False)
page_count = int(self._html_search_regex(r'<a href="/channel/\w+/page/(\d+)">(?:\1)</a>', webpage, 'page count')) page_count = int_or_none(self._html_search_regex(
r'<a[^>]+href="/channel/\w+/page/(\d+)">(?:\1)</a>', webpage, 'page count', default='1'))
def page_func(page_num): def page_func(page_num):
page_num += 1
webpage = self._download_webpage( webpage = self._download_webpage(
'https://altcensored.com/channel/%s/page/%d' % (channel_id, page_num + 1), f'https://altcensored.com/channel/{channel_id}/page/{page_num}',
channel_id, note='Download page #%d' % (page_num + 1), channel_id, note=f'Downloading page {page_num}')
errnote='Unable to get page #%d' % (page_num + 1),
)
items = re.findall(r'<a[^>]+href="(/watch\?v=[^"]+)', webpage) items = re.findall(r'<a[^>]+href="(/watch\?v=[^"]+)', webpage)
# deduplicate consecutive items (multiple <a> per video) return [self.url_result(urljoin('https://www.altcensored.com', path), AltCensoredIE)
items = [self.url_result('https://www.altcensored.com' + key, AltCensoredIE) for key, _group in groupby(items)] for path in orderedSet(items)]
return items
entries = InAdvancePagedList(page_func, page_count, self._PAGE_SIZE) return self.playlist_result(
return self.playlist_result(entries, playlist_id=channel_id, playlist_title=title) InAdvancePagedList(page_func, page_count, self._PAGE_SIZE),
playlist_id=channel_id, playlist_title=title)