New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
weibo broken #8445
Labels
patch-available
There is patch available that should fix this issue. Someone needs to make a PR with it
site-bug
Issue with a specific website
Comments
I am not sure of the importance of the diff --git a/yt_dlp/extractor/weibo.py b/yt_dlp/extractor/weibo.py
index b0c3052b6..425e679be 100644
--- a/yt_dlp/extractor/weibo.py
+++ b/yt_dlp/extractor/weibo.py
@@ -26,16 +26,16 @@ def _update_visitor_cookies(self, video_id):
data=urlencode_postdata({
'cb': 'gen_callback',
'fp': '{"os":"2","browser":"Gecko57,0,0,0","fonts":"undefined","screenInfo":"1440*900*24","plugins":""}',
- }))
+ }))['data']
self._download_webpage(
'https://passport.weibo.com/visitor/visitor', video_id,
note='Running first-visit callback to get guest cookies',
query={
'a': 'incarnate',
- 't': visitor_data['data']['tid'],
+ 't': visitor_data['tid'],
'w': 2,
- 'c': '%03d' % visitor_data['data']['confidence'],
+ 'c': '%03d' % visitor_data.get('confidence', 1),
'cb': 'cross_domain',
'from': 'weibo',
'_rand': random.random(), cc @c-basalt |
bashonly
added
needs-testing
Patch needs testing
and removed
triage
Untriaged issue
labels
Oct 28, 2023
@bashonly That also works on my end, and it seems that weibo is relaxed about all other query params except for diff --git a/yt_dlp/extractor/weibo.py b/yt_dlp/extractor/weibo.py
index b0c3052b6..9a7e3b0d9 100644
--- a/yt_dlp/extractor/weibo.py
+++ b/yt_dlp/extractor/weibo.py
@@ -18,24 +18,30 @@
class WeiboBaseIE(InfoExtractor):
- def _update_visitor_cookies(self, video_id):
+ def _update_visitor_cookies(self, visitor_url, video_id):
+ chrome_ver = self._search_regex(
+ r'Chrome/(\d+)', traverse_obj(self._downloader.params, ('http_headers', 'User-Agent', {str})),
+ 'user agent version', default='90')
visitor_data = self._download_json(
'https://passport.weibo.com/visitor/genvisitor', video_id,
note='Generating first-visit guest request',
+ headers={'Referer': visitor_url},
transform_source=strip_jsonp,
data=urlencode_postdata({
'cb': 'gen_callback',
- 'fp': '{"os":"2","browser":"Gecko57,0,0,0","fonts":"undefined","screenInfo":"1440*900*24","plugins":""}',
- }))
+ 'fp': f'{{"os":"1","browser":"Chrome{chrome_ver},0,0,0","fonts":"undefined","screenInfo":"1920*1080*24","plugins":""}}',
+ }))['data']
self._download_webpage(
'https://passport.weibo.com/visitor/visitor', video_id,
note='Running first-visit callback to get guest cookies',
+ headers={'Referer': visitor_url},
query={
'a': 'incarnate',
- 't': visitor_data['data']['tid'],
- 'w': 2,
- 'c': '%03d' % visitor_data['data']['confidence'],
+ 't': visitor_data['tid'],
+ 'w': 3 if visitor_data.get('new_tid') else 2,
+ 'c': '%03d' % visitor_data.get('confidence', 100),
+ 'gc': '',
'cb': 'cross_domain',
'from': 'weibo',
'_rand': random.random(),
@@ -44,7 +50,7 @@ def _update_visitor_cookies(self, video_id):
def _weibo_download_json(self, url, video_id, *args, fatal=True, note='Downloading JSON metadata', **kwargs):
webpage, urlh = self._download_webpage_handle(url, video_id, *args, fatal=fatal, note=note, **kwargs)
if urllib.parse.urlparse(urlh.url).netloc == 'passport.weibo.com':
- self._update_visitor_cookies(video_id)
+ self._update_visitor_cookies(urlh.url, video_id)
webpage = self._download_webpage(url, video_id, *args, fatal=fatal, note=note, **kwargs)
return self._parse_json(webpage, video_id, fatal=fatal) |
bashonly
added
patch-available
There is patch available that should fix this issue. Someone needs to make a PR with it
and removed
needs-testing
Patch needs testing
labels
Oct 28, 2023
9 tasks
aalsuwaidi
pushed a commit
to aalsuwaidi/yt-dlp
that referenced
this issue
Apr 21, 2024
Closes yt-dlp#8445 Authored by: c-basalt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
patch-available
There is patch available that should fix this issue. Someone needs to make a PR with it
site-bug
Issue with a specific website
DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE
Checklist
Region
Albania
Provide a description that is worded well enough to be understood
weibo broken
Provide verbose output that clearly demonstrates the problem
yt-dlp -vU <your command line>
)'verbose': True
toYoutubeDL
params instead[debug] Command-line config
) and insert it belowComplete Verbose Output
The text was updated successfully, but these errors were encountered: