Compare commits

...

5 Commits

Author SHA1 Message Date
Dong Heon Hee b7268e2ee7
Merge f2767e2ce0 into 5904853ae5 2024-05-07 00:19:50 +09:00
bashonly 5904853ae5
[ie/crunchyroll] Support browser impersonation (#9857)
Closes #7442
Authored by: bashonly
2024-05-05 23:15:32 +00:00
Chris Caruso c8bf48f3a8
[ie/cbc.ca:player] Improve `_VALID_URL` (#9866)
Closes #9825
Authored by: carusocr
2024-05-05 23:02:24 +00:00
The-MAGI 351368cb9a
[ie/youporn] Fix extractor (#8827)
Closes #7967
Authored by: The-MAGI
2024-05-05 22:57:38 +00:00
hui1601 f2767e2ce0
[ie/CHZZK] Support download channel videos 2024-02-14 23:31:29 +09:00
5 changed files with 129 additions and 15 deletions

View File

@ -350,6 +350,7 @@
from .chilloutzone import ChilloutzoneIE
from .chzzk import (
CHZZKLiveIE,
CHZZKChannelIE,
CHZZKVideoIE,
)
from .cinemax import CinemaxIE

View File

@ -151,7 +151,7 @@ def _real_extract(self, url):
class CBCPlayerIE(InfoExtractor):
IE_NAME = 'cbc.ca:player'
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/(?:video/)?|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
_TESTS = [{
'url': 'http://www.cbc.ca/player/play/2683190193',
'md5': '64d25f841ddf4ddb28a235338af32e2c',
@ -277,6 +277,28 @@ class CBCPlayerIE(InfoExtractor):
'location': 'Canada',
'media_type': 'Full Program',
},
}, {
'url': 'https://www.cbc.ca/player/play/video/1.7194274',
'md5': '188b96cf6bdcb2540e178a6caa957128',
'info_dict': {
'id': '2334524995812',
'ext': 'mp4',
'title': '#TheMoment a rare white spirit moose was spotted in Alberta',
'description': 'md5:18ae269a2d0265c5b0bbe4b2e1ac61a3',
'timestamp': 1714788791,
'duration': 77.678,
'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/201/543/THE_MOMENT.jpg',
'uploader': 'CBCC-NEW',
'chapters': 'count:0',
'upload_date': '20240504',
'categories': 'count:3',
'series': 'The National',
'tags': 'count:15',
'creators': ['encoder'],
'location': 'Canada',
'media_type': 'Excerpt',
},
}, {
'url': 'cbcplayer:1.7159484',
'only_matching': True,

View File

@ -87,6 +87,91 @@ def _real_extract(self, url):
}
def _make_vod_result(data):
assert isinstance(data, dict)
if not data.get('videoId'):
return
return {
'_type': 'url_transparent',
'id': data.get('videoId'),
'title': data.get('videoTitle'),
'url': f'https://chzzk.naver.com/video/{data.get("videoNo")}',
'thumbnail': data.get('thumbnailImageUrl'),
'timestamp': data.get('publishDateAt'),
'view_count': data.get('readCount'),
'duration': data.get('duration'),
'age_limit': 19 if data.get('adult') else 0,
'was_live': True if data.get('videoType') == 'REPLAY' else False,
}
class CHZZKChannelIE(InfoExtractor):
IE_NAME = 'chzzk:channel'
_VALID_URL = r'https?://chzzk\.naver\.com/(?P<id>[\da-f]{32})'
_TESTS = [{
'note': 'Both video and replay included',
'url': 'https://chzzk.naver.com/68f895c59a1043bc5019b5e08c83a5c5',
'info_dict': {
'id': '68f895c59a1043bc5019b5e08c83a5c5',
'channel_id': '68f895c59a1043bc5019b5e08c83a5c5',
'description': '나는 머찐 라디유 나는 머찐 라디유' * 26 + '나는 라디유',
'channel': '라디유radiyu',
'title': '라디유radiyu',
'channel_is_verified': False,
},
'playlist_mincount': 4,
}, {
'note': 'Video list paging',
'url': 'https://chzzk.naver.com/2d4aa2f79b0a397d032c479ef1b37a67',
'info_dict': {
'id': '2d4aa2f79b0a397d032c479ef1b37a67',
'channel_id': '2d4aa2f79b0a397d032c479ef1b37a67',
'description': '',
'channel': '진짜후추',
'title': '진짜후추',
'channel_is_verified': False,
},
'playlist_mincount': 86,
}]
def _real_extract(self, url):
channel_id = self._match_id(url)
# even if channel got banned, the video list is still available. but downloading videos leads to error
channel_meta = self._download_json(
f'https://api.chzzk.naver.com/service/v1/channels/{channel_id}', channel_id,
note='Downloading channel info', errnote='Unable to download channel info')
if channel_meta.get('code') != 200:
raise ExtractorError('The channel is not available: %s(%s)' % (
channel_meta.get("message"), channel_meta.get("code")), expected=True)
channel_meta = channel_meta.get('content')
if not channel_meta or not channel_meta.get('channelId'):
raise ExtractorError('The channel does not exist', expected=True)
total_count = 0
videos = []
current_count = 0
while current_count <= total_count:
videos_page = self._download_json(
f'https://api.chzzk.naver.com/service/v1/channels/{channel_id}/videos', channel_meta['channelName'],
query={'sortType': 'LATEST', 'pagingType': 'PAGE', 'size': 18, 'videoType': '', 'page': current_count},
note='Downloading videos page(%s/%s)' % (current_count + 1, total_count + 1), errnote='Unable to download videos page')
if videos_page.get('code') != 200:
raise ExtractorError('Unable to download videos page: %s(%s){videos_page.get("message")}' % (
videos_page.get("message"), videos_page.get("code")), expected=True)
videos_page = videos_page['content']
videos.extend(map(_make_vod_result, videos_page['data']))
total_count = videos_page['totalPages']
current_count += 1
if len(videos) != total_count:
self.to_screen('Warning: The total count of videos is not equal to the actual count: %s != %s' % (len(videos), total_count))
return self.playlist_result(
videos, channel_id, channel_meta['channelName'], channel_meta['channelDescription'],
channel=channel_meta['channelName'], channel_id=channel_id, channel_is_verified=channel_meta['verifiedMark'],
)
class CHZZKVideoIE(InfoExtractor):
IE_NAME = 'chzzk:video'
_VALID_URL = r'https?://chzzk\.naver\.com/video/(?P<id>\d+)'

View File

@ -53,15 +53,19 @@ def _set_auth_info(self, response):
CrunchyrollBaseIE._AUTH_EXPIRY = time_seconds(seconds=traverse_obj(response, ('expires_in', {float_or_none}), default=300) - 10)
def _request_token(self, headers, data, note='Requesting token', errnote='Failed to request token'):
try: # TODO: Add impersonation support here
try:
return self._download_json(
f'{self._BASE_URL}/auth/v1/token', None, note=note, errnote=errnote,
headers=headers, data=urlencode_postdata(data))
headers=headers, data=urlencode_postdata(data), impersonate=True)
except ExtractorError as error:
if not isinstance(error.cause, HTTPError) or error.cause.status != 403:
raise
if target := error.cause.response.extensions.get('impersonate'):
raise ExtractorError(f'Got HTTP Error 403 when using impersonate target "{target}"')
raise ExtractorError(
'Request blocked by Cloudflare; navigate to Crunchyroll in your browser, '
'Request blocked by Cloudflare. '
'Install the required impersonation dependency if possible, '
'or else navigate to Crunchyroll in your browser, '
'then pass the fresh cookies (with --cookies-from-browser or --cookies) '
'and your browser\'s User-Agent (with --user-agent)', expected=True)

View File

@ -72,15 +72,15 @@ class YouPornIE(InfoExtractor):
'id': '16290308',
'age_limit': 18,
'categories': [],
'description': 'md5:00ea70f642f431c379763c17c2f396bc',
'description': str, # TODO: detect/remove SEO spam description in ytdl backport
'display_id': 'tinderspecial-trailer1',
'duration': 298.0,
'ext': 'mp4',
'upload_date': '20201123',
'uploader': 'Ersties',
'tags': [],
'thumbnail': 'https://fi1.ypncdn.com/202011/23/16290308/original/8/tinderspecial-trailer1-8(m=eaAaaEPbaaaa).jpg',
'timestamp': 1606089600,
'thumbnail': r're:https://.+\.jpg',
'timestamp': 1606147564,
'title': 'Tinder In Real Life',
'view_count': int,
}
@ -88,11 +88,17 @@ class YouPornIE(InfoExtractor):
def _real_extract(self, url):
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
definitions = self._download_json(
f'https://www.youporn.com/api/video/media_definitions/{video_id}/', display_id or video_id)
self._set_cookie('.youporn.com', 'age_verified', '1')
webpage = self._download_webpage(f'https://www.youporn.com/watch/{video_id}', video_id)
definitions = self._search_json(r'\bplayervars\s*:', webpage, 'player vars', video_id)['mediaDefinitions']
def get_format_data(data, f):
return traverse_obj(data, lambda _, v: v['format'] == f and url_or_none(v['videoUrl']))
def get_format_data(data, stream_type):
info_url = traverse_obj(data, (lambda _, v: v['format'] == stream_type, 'videoUrl', {url_or_none}, any))
if not info_url:
return []
return traverse_obj(
self._download_json(info_url, video_id, f'Downloading {stream_type} info JSON', fatal=False),
lambda _, v: v['format'] == stream_type and url_or_none(v['videoUrl']))
formats = []
# Try to extract only the actual master m3u8 first, avoiding the duplicate single resolution "master" m3u8s
@ -123,10 +129,6 @@ def get_format_data(data, f):
f['height'] = height
formats.append(f)
webpage = self._download_webpage(
'http://www.youporn.com/watch/%s' % video_id, display_id,
headers={'Cookie': 'age_verified=1'})
title = self._html_search_regex(
r'(?s)<div[^>]+class=["\']watchVideoTitle[^>]+>(.+?)</div>',
webpage, 'title', default=None) or self._og_search_title(