Skip to content

Commit 92fbe2e

Browse files
committed
fix #65,#68,#69
1 parent b49dd2f commit 92fbe2e

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
## `v2.6.6`
3838

3939
- 修复 pickle 库反序列化导致内存溢出的问题[#65](https://github.com/zaxtyson/LanZouCloud-API/issues/65)
40+
- 更换为最新域名, 防止解析失败[#68](https://github.com/zaxtyson/LanZouCloud-API/pull/68)
4041

4142
## `v2.6.5`
4243

lanzou/api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from lanzou.api.core import LanZouCloud
22

3-
version = '2.6.5.1'
3+
version = '2.6.6'
44

55
__all__ = ['utils', 'types', 'models', 'LanZouCloud', 'version']

lanzou/api/core.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(self):
4545
self._timeout = 15 # 每个请求的超时(不包含下载响应体的用时)
4646
self._max_size = 100 # 单个文件大小上限 MB
4747
self._upload_delay = (0, 0) # 文件上传延时
48-
self._host_url = 'https://pan.lanzoui.com'
48+
self._host_url = 'https://pan.lanzouo.com'
4949
self._doupload_url = 'https://pc.woozooo.com/doupload.php'
5050
self._account_url = 'https://pc.woozooo.com/account.php'
5151
self._mydisk_url = 'https://pc.woozooo.com/mydisk.php'
@@ -83,11 +83,11 @@ def _post(self, url, data, **kwargs):
8383
def _all_possible_urls(url: str) -> List[str]:
8484
"""蓝奏云的主域名有时会挂掉, 此时尝试切换到备用域名"""
8585
available_domains = [
86-
'lanzoui.com', # 鲁ICP备15001327号-6, 2020-06-09, SEO 排名最低
87-
'lanzoux.com', # 鲁ICP备15001327号-5, 2020-06-09
88-
'lanzous.com' # 主域名, 备案异常, 部分地区已经无法访问
86+
'lanzouw.com', # 鲁ICP备15001327号-7, 2021-09-02
87+
'lanzoui.com', # 鲁ICP备15001327号-6, 2020-06-09
88+
'lanzoux.com' # 鲁ICP备15001327号-5, 2020-06-09
8989
]
90-
return [url.replace('lanzous.com', d) for d in available_domains]
90+
return [url.replace('lanzouo.com', d) for d in available_domains]
9191

9292
def ignore_limits(self):
9393
"""解除官方限制"""
@@ -1046,14 +1046,13 @@ def down_file_by_url(self, share_url, pwd='', save_path='./Download', *, callbac
10461046
f.seek(-512, os.SEEK_END)
10471047
last_512_bytes = f.read()
10481048
file_info = un_serialize(last_512_bytes)
1049-
# Python3.6 序列化时默认使用 pickle 第三版协议,
1050-
# 导致计算时文件尾部多写了 5 字节, 保险期起见处理一下
1049+
# Python3.7 序列化时默认使用 pickle 第三版协议,
1050+
# 导致计算时文件尾部多写了 5 字节, 应该都是用3.8, 保险期起见处理一下
10511051
if not file_info:
10521052
is_protocol_3 = True
10531053
f.seek(-517, os.SEEK_END)
10541054
last_517_bytes = f.read()
10551055
file_info = un_serialize(last_517_bytes)
1056-
10571056

10581057
# 大文件的记录文件也可以反序列化出 name,但是没有 padding 字段
10591058
if file_info is not None and 'padding' in file_info:
@@ -1069,6 +1068,7 @@ def down_file_by_url(self, share_url, pwd='', save_path='./Download', *, callbac
10691068
# 截断最后 512 字节隐藏信息, 还原文件
10701069
with open(new_file_path, 'rb+') as f:
10711070
truncate_size = 517 if is_protocol_3 else 512
1071+
logger.debug(f"Truncate last {truncate_size} bytes of file")
10721072
f.seek(-truncate_size, os.SEEK_END)
10731073
f.truncate()
10741074
file_path = new_file_path # 保存文件重命名后真实路径

lanzou/api/utils.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ def is_name_valid(filename: str) -> bool:
7878

7979
def is_file_url(share_url: str) -> bool:
8080
"""判断是否为文件的分享链接"""
81-
base_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[six].com/.+' # 子域名可个性化设置或者不存在
82-
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[six].com/i[a-zA-Z0-9]{5,}/?' # 普通用户 URL 规则
81+
base_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/.+' # 子域名可个性化设置或者不存在
82+
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/i[a-zA-Z0-9]{5,}/?' # 普通用户 URL 规则
8383
if not re.fullmatch(base_pat, share_url):
8484
return False
8585
elif re.fullmatch(user_pat, share_url):
@@ -95,8 +95,8 @@ def is_file_url(share_url: str) -> bool:
9595

9696
def is_folder_url(share_url: str) -> bool:
9797
"""判断是否为文件夹的分享链接"""
98-
base_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[six].com/.+'
99-
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[six].com/(/s/)?b[a-zA-Z0-9]{7,}/?'
98+
base_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/.+'
99+
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/(/s/)?b[a-zA-Z0-9]{7,}/?'
100100
if not re.fullmatch(base_pat, share_url):
101101
return False
102102
elif re.fullmatch(user_pat, share_url):
@@ -198,7 +198,7 @@ def let_me_upload(file_path):
198198
chunk = in_f.read(4096)
199199
# 构建文件 "报尾" 保存真实文件名,大小 512 字节
200200
# 追加数据到文件尾部,并不会影响文件的使用,无需修改即可分享给其他人使用,自己下载时则会去除,确保数据无误
201-
# protocol=4py3.8默认), 序列化后空字典占 42 字节
201+
# protocol=4(py3.8默认), 序列化后空字典占 42 字节
202202
padding = 512 - len(file_name.encode('utf-8')) - 42
203203
data = {'name': file_name, 'padding': b'\x00' * padding}
204204
data = pickle.dumps(data, protocol=4)

0 commit comments

Comments
 (0)