-
Notifications
You must be signed in to change notification settings - Fork 10k
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] add support for Sina Weibo #15079
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good in general, just some comments for minor issues
youtube_dl/extractor/weibo.py
Outdated
'Accept-Language': 'en,zh-CN;q=0.9,zh;q=0.8', | ||
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36', | ||
'Upgrade-Insecure-Requests': '1', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are all of these necessary? I think youtube-dl defaults suffice.
youtube_dl/extractor/weibo.py
Outdated
'Upgrade-Insecure-Requests': '1', | ||
} | ||
# to get Referer url for genvisitor | ||
webpage, urlh = self._download_webpage_handle(url, video_id, headers=headers, note="first visit the page") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use _ (underline) instead of webpage if the value is not used.
youtube_dl/extractor/weibo.py
Outdated
|
||
data = urlencode({ | ||
"cb": "gen_callback", | ||
"fp": '{"os":"2","browser":"Gecko57,0,0,0","fonts":"undefined","screenInfo":"1440*900*24","plugins":""}', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use json.dumps instead
youtube_dl/extractor/weibo.py
Outdated
'Referer': visitor_url, | ||
} | ||
|
||
r_genvisitor = request.Request( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use data
and headers
parameters of _download_webpage instead.
youtube_dl/extractor/weibo.py
Outdated
data=data, | ||
headers=headers, | ||
) | ||
webpage, urlh = self._download_webpage_handle(r_genvisitor, video_id, note="gen visitor") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use _download_webpage is urlh is not used. And note should be meaningful for typical users.
youtube_dl/extractor/weibo.py
Outdated
'Accept-Encoding': 'gzip, deflate, br', | ||
'Accept-Language': 'en,zh-CN;q=0.9,zh;q=0.8', | ||
'Upgrade-Insecure-Requests': '1', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue
youtube_dl/extractor/weibo.py
Outdated
'Upgrade-Insecure-Requests': '1', | ||
} | ||
# to get Referer url for genvisitor | ||
webpage, urlh = self._download_webpage_handle(url, video_id, headers=headers, note="visit the page") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue for urlh
youtube_dl/extractor/weibo.py
Outdated
'url': page_info['media_info']['stream_url'], | ||
'format': 'mp4', | ||
} | ||
formats = [format] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just use 'url' in the final dict if there's only one format
youtube_dl/extractor/weibo.py
Outdated
'format': 'mp4', | ||
} | ||
formats = [format] | ||
uploader = weibo_info['status']['user']['screen_name'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an optional field; use .get
idiom. Check https://github.com/rg3/youtube-dl/blob/master/README.md#mandatory-and-optional-metafields
youtube_dl/extractor/weibo.py
Outdated
'title': title, | ||
'uploader': uploader, | ||
'formats': formats | ||
# TODO more properties (see youtube_dl/extractor/common.py) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
@yan12125 when can you do a further review over the new changes? |
jsonp stuffs are still there, and in some cases _download_webpage_handle can be changed to _download_webpage |
@yan12125 Sorry, missed your reply. Changed them |
@yan12125 I think the travis-ci erros are not related to my code. |
I've restarted the build. |
Thanks for the extractor! Do you want to be listed in AUTHORS? If so under what name? |
Cool, please list me under name:
Yang Hongbo
Thanks
发自我的 iPhone
… 在 2018年1月9日,18:16,Chih-Hsuan Yen ***@***.***> 写道:
Thanks for the extractor! Do you want to be listed in AUTHORS? If so under what name?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Done :) |
Please follow the guide below
x
into all the boxes [ ] relevant to your pull request (like that [x])Before submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
add support for downloading video from Sina Weibo (Weibo.com), both URL from desktop site or mobile site