Compare commits

...

25 Commits

Author SHA1 Message Date
ringus1 19a5841e82
Merge 3302588c77 into 5904853ae5 2024-05-08 14:52:02 +02: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
bashonly 3302588c77
Merge branch 'yt-dlp:master' into pr/fb_parsedata_error 2024-02-15 17:02:42 -06:00
ringus1 163533ee17 PR changes 2024-02-13 12:03:07 +01:00
ringus1 88ac2d3915 Flake fix 2024-02-05 11:46:58 +01:00
ringus1 eb0cfc7420 Raising error only if video parsing fails 2024-02-05 11:45:23 +01:00
ringus1 0a8b675da9 Move getting cookies before making first request 2024-02-01 09:56:34 +01:00
ringus1 5143f916f3 PR fixes - clear up messages 2024-02-01 08:14:23 +01:00
ringus1 8f0d32fa83 Simplify login error check 2024-01-31 17:04:09 +01:00
ringus1 8e01382707 Fix props getter 2024-01-31 16:54:26 +01:00
ringus1 94f85add47 Merge branch 'fb_parsedata_error' of https://github.com/ringus1/yt-dlp into fb_parsedata_error 2024-01-31 16:38:20 +01:00
ringus1 18b4296aa3 MR fixes 2024-01-31 16:38:02 +01:00
bashonly 6ef07d4ec9
Merge branch 'master' into fb_parsedata_error 2024-01-31 08:53:05 -06:00
ringus1 821ac9c0b8 More messages for account suspension 2024-01-24 21:52:46 +01:00
ringus1 4916a77720 Add one more case when account is locked 2024-01-24 12:22:09 +01:00
ringus1 c22e4bd29f Fix double quotes 2024-01-15 13:05:53 +01:00
ringus1 6a04a4aaec Detect mobile number checkpoint 2024-01-15 10:43:10 +01:00
ringus1 1bd55358a0 Flake fix 2024-01-12 15:04:27 +01:00
ringus1 6542c5124c Formatting 2024-01-12 14:48:46 +01:00
ringus1 f1ed988c5f One more exception handling 2024-01-11 17:01:20 +01:00
ringus1 6be151fed7 Handle removed content 2024-01-11 16:02:41 +01:00
ringus1 4f58aabe67 Add better login handling 2024-01-11 14:39:52 +01:00
ringus1 fcff2c5cd0 Adding potential fix 2024-01-10 16:11:45 +01:00
4 changed files with 81 additions and 19 deletions

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

@ -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

@ -445,7 +445,9 @@ def _perform_login(self, username, password):
try:
login_results = self._download_webpage(request, None,
note='Logging in', errnote='unable to fetch login page')
if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
if 'Your Request Couldn' in login_results:
self.raise_login_required('Failed to login with credentials', method='cookies')
elif re.search(r'<form[^>]*name="login"[^<]*</form>', login_results):
error = self._html_search_regex(
r'(?s)<div[^>]+class=(["\']).*?login_error_box.*?\1[^>]*><div[^>]*>.*?</div><div[^>]*>(?P<error>.+?)</div>',
login_results, 'login error', default=None, group='error')
@ -478,13 +480,41 @@ def _perform_login(self, username, password):
return
def _extract_from_url(self, url, video_id):
cookies = self._get_cookies(url)
# user passed logged-in cookies or attempted to login
login_data = cookies.get('c_user') and cookies.get('xs')
logged_in = False
webpage = self._download_webpage(
url.replace('://m.facebook.com/', '://www.facebook.com/'), video_id)
sjs_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall(
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)]
if login_data:
logged_in = get_first(sjs_data, (
'require', ..., ..., ..., '__bbox', 'define',
lambda _, v: 'CurrentUserInitialData' in v, ..., 'ACCOUNT_ID'), default='0') != '0'
if logged_in and (info := get_first(sjs_data, ('require', ..., ..., ..., '__bbox', 'require', ..., ..., ...,
'__bbox', 'result', 'data', (('ufac_client', 'state',
(('set_contact_point_state_renderer', 'title'),
('intro_state_renderer', 'header_title'))),
('epsilon_checkpoint', 'screen', 'title'))))):
if any(content in info for content in ['days left to appeal', 'suspended your account']):
raise ExtractorError('Your account is suspended', expected=True)
if 'Enter mobile number' == info:
raise ExtractorError('Facebook is requiring mobile number confirmation', expected=True)
if 'your account has been locked' in info:
raise ExtractorError('Your account has been locked', expected=True)
if props := get_first(sjs_data, (
'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., 'rootView',
lambda _, v: v['title'].startswith('This content isn\'t available'))):
raise ExtractorError(
f'Content unavailable. Facebook said: {props.get("body") or props["title"]}', expected=True)
def extract_metadata(webpage):
post_data = [self._parse_json(j, video_id, fatal=False) for j in re.findall(
r'data-sjs>({.*?ScheduledServerJS.*?})</script>', webpage)]
post = traverse_obj(post_data, (
post = traverse_obj(sjs_data, (
..., 'require', ..., ..., ..., '__bbox', 'require', ..., ..., ..., '__bbox', 'result', 'data'), expected_type=dict) or []
media = traverse_obj(post, (..., 'attachments', ..., lambda k, v: (
k == 'media' and str(v['id']) == video_id and v['__typename'] == 'Video')), expected_type=dict)
@ -795,6 +825,10 @@ def parse_attachment(attachment, key='media'):
video_data = extract_from_jsmods_instances(tahoe_js_data)
if not video_data:
if not login_data:
raise ExtractorError('Cannot parse data. Try logging in.', expected=True)
if not logged_in:
raise ExtractorError('Failed to login with provided data.', expected=True)
raise ExtractorError('Cannot parse data')
if len(video_data) > 1:

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(