-
Notifications
You must be signed in to change notification settings - Fork 57
/
baiduyun
executable file
·40 lines (35 loc) · 1.41 KB
/
baiduyun
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# coding: utf-8
from __future__ import print_function, unicode_literals
import sys
from bdy.baiduyun import BaiduYun
from bdy import utils
verify = True
if __name__ == "__main__":
try:
if len(sys.argv) > 1 and '--no-check-certificate' in sys.argv:
verify = False
oauth_info = utils.read_oauth_info()
if not utils.oauth_check(oauth_info, verify):
client_id = utils.get_config("apikey")
oa_url = "https://openapi.baidu.com/oauth/2.0/authorize?client_id={client_id}" \
"&response_type=token&redirect_uri=oob" \
"&scope=netdisk".format(client_id=client_id)
oa_result_base = utils.get_config("oa_result")
if len(sys.argv) > 1 and '-b' in sys.argv:
from bdy import oauth_browser
oauth_result = oauth_browser.get_oa_info(oa_url, oa_result_base)
else:
from bdy import oauth_ui
oauth_result = oauth_ui.get_oa_info(oa_url, oa_result_base)
oauth_info = utils.get_oauth_result(oauth_result)
if not utils.oauth_check(oauth_info):
print("登录错误")
exit()
utils.save_oauth_info(oauth_info)
print("获取数据成功")
bdy = BaiduYun(oauth_info, verify)
utils.menu(bdy)
except Exception as exc:
print(exc)
exit()