@@ -45,7 +45,7 @@ def __init__(self):
45
45
self ._timeout = 15 # 每个请求的超时(不包含下载响应体的用时)
46
46
self ._max_size = 100 # 单个文件大小上限 MB
47
47
self ._upload_delay = (0 , 0 ) # 文件上传延时
48
- self ._host_url = 'https://pan.lanzous .com'
48
+ self ._host_url = 'https://pan.lanzoui .com'
49
49
self ._doupload_url = 'https://pc.woozooo.com/doupload.php'
50
50
self ._account_url = 'https://pc.woozooo.com/account.php'
51
51
self ._mydisk_url = 'https://pc.woozooo.com/mydisk.php'
@@ -58,20 +58,36 @@ def __init__(self):
58
58
disable_warnings (InsecureRequestWarning ) # 全局禁用 SSL 警告
59
59
60
60
def _get (self , url , ** kwargs ):
61
- try :
62
- kwargs .setdefault ('timeout' , self ._timeout )
63
- kwargs .setdefault ('headers' , self ._headers )
64
- return self ._session .get (url , verify = False , ** kwargs )
65
- except (ConnectionError , requests .RequestException ):
66
- return None
61
+ for possible_url in self ._all_possible_urls (url ):
62
+ try :
63
+ kwargs .setdefault ('timeout' , self ._timeout )
64
+ kwargs .setdefault ('headers' , self ._headers )
65
+ return self ._session .get (possible_url , verify = False , ** kwargs )
66
+ except (ConnectionError , requests .RequestException ):
67
+ logger .debug (f"Get { possible_url } failed, try another domain" )
68
+
69
+ return None
67
70
68
71
def _post (self , url , data , ** kwargs ):
69
- try :
70
- kwargs .setdefault ('timeout' , self ._timeout )
71
- kwargs .setdefault ('headers' , self ._headers )
72
- return self ._session .post (url , data , verify = False , ** kwargs )
73
- except (ConnectionError , requests .RequestException ):
74
- return None
72
+ for possible_url in self ._all_possible_urls (url ):
73
+ try :
74
+ kwargs .setdefault ('timeout' , self ._timeout )
75
+ kwargs .setdefault ('headers' , self ._headers )
76
+ return self ._session .post (possible_url , data , verify = False , ** kwargs )
77
+ except (ConnectionError , requests .RequestException ):
78
+ logger .debug (f"Post to { possible_url } ({ data } ) failed, try another domain" )
79
+
80
+ return None
81
+
82
+ @staticmethod
83
+ def _all_possible_urls (url : str ) -> List [str ]:
84
+ """蓝奏云的主域名有时会挂掉, 此时尝试切换到备用域名"""
85
+ available_domains = [
86
+ 'lanzoui.com' , # 鲁ICP备15001327号-6, 2020-06-09, SEO 排名最低
87
+ 'lanzoux.com' , # 鲁ICP备15001327号-5, 2020-06-09
88
+ 'lanzous.com' # 主域名, 备案异常, 部分地区已经无法访问
89
+ ]
90
+ return [url .replace ('lanzous.com' , d ) for d in available_domains ]
75
91
76
92
def ignore_limits (self ):
77
93
"""解除官方限制"""
0 commit comments