Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zaxtyson committed Apr 2, 2022
1 parent 044b7f1 commit cbf11e4
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 95 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
.vscode
__pycache__
dist
build
161 changes: 94 additions & 67 deletions README.md

Large diffs are not rendered by default.

51 changes: 51 additions & 0 deletions inno_setup.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
; 用于打包 exe 安装程序
; Inno Setup: https://zaxtyson.lanzouf.com/iVTrC02i5lzc

#define MyAppName "蓝奏云控制台"
#define MyAppVersion "2.6.7"
#define MyAppPublisher "zaxtyson"
#define MyAppURL "https://github.com/zaxtyson/LanZouCloud-CMD"

#define MyAppExeName "lanzou-cmd.exe"
#define PackSourceDir "C:\Users\zaxtyson\PycharmProjects\LanZouCloud-CMD\dist\lanzou-cmd"
#define PackOutputDir "C:\Users\zaxtyson\PycharmProjects\LanZouCloud-CMD\dist"
#define PackOutputAppName "lanzou-cmd_x64_v2.6.7"

[Setup]
AppId={{27D10ED2-13D0-420D-A602-39D1386872D0}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\lanzou
DisableDirPage=no
DisableProgramGroupPage=yes
PrivilegesRequired=lowest
OutputDir={#PackOutputDir}
OutputBaseFilename={#PackOutputAppName}
SetupIconFile={#PackSourceDir}\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "{#PackSourceDir}\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
Source: "{#PackSourceDir}\user.dat"; DestDir: "{app}"; Flags: ignoreversion; Permissions: users-modify

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

[UninstallDelete]
Type: filesandordirs; Name: "{app}"
2 changes: 1 addition & 1 deletion lanzou/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lanzou.api.core import LanZouCloud

version = '2.6.6'
version = '2.6.7.1'

__all__ = ['utils', 'types', 'models', 'LanZouCloud', 'version']
12 changes: 10 additions & 2 deletions lanzou/api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _all_possible_urls(url: str) -> List[str]:
available_domains = [
'lanzouw.com', # 鲁ICP备15001327号-7, 2021-09-02
'lanzoui.com', # 鲁ICP备15001327号-6, 2020-06-09
'lanzoux.com' # 鲁ICP备15001327号-5, 2020-06-09
'lanzoux.com' # 鲁ICP备15001327号-5, 2020-06-09
]
return [url.replace('lanzouo.com', d) for d in available_domains]

Expand Down Expand Up @@ -512,6 +512,14 @@ def get_file_info_by_url(self, share_url, pwd='') -> FileDetail:
if len(sign) < 20: # 此时 sign 保存在变量里面, 变量名是 sign 匹配的字符
sign = re.search(rf"var {sign}\s*=\s*'(.+?)';", first_page).group(1)
post_data = {'action': 'downprocess', 'sign': sign, 'ves': 1}
# 某些特殊情况 share_url 会出现 webpage 参数, post_data 需要更多参数
# https://github.com/zaxtyson/LanZouCloud-API/issues/74
if "?webpage=" in share_url:
ajax_data = re.search(r"var ajaxdata\s*=\s*'(.+?)';", first_page).group(1)
web_sign = re.search(r"var websign\s*=\s*'(.+?)';", first_page).group(1)
web_sign_key = re.search(r"var websignkey\s*=\s*'(.+?)';", first_page).group(1)
post_data = {'action': 'downprocess', 'signs': ajax_data, 'sign': sign, 'ves': 1,
'websign': web_sign, 'websignkey': web_sign_key}
link_info = self._post(self._host_url + '/ajaxm.php', post_data)
if not link_info:
return FileDetail(LanZouCloud.NETWORK_ERROR, name=f_name, time=f_time, size=f_size, desc=f_desc,
Expand Down Expand Up @@ -1048,7 +1056,7 @@ def down_file_by_url(self, share_url, pwd='', save_path='./Download', *, callbac
file_info = un_serialize(last_512_bytes)
# Python3.7 序列化时默认使用 pickle 第三版协议,
# 导致计算时文件尾部多写了 5 字节, 应该都是用3.8, 保险期起见处理一下
if not file_info:
if not file_info:
is_protocol_3 = True
f.seek(-517, os.SEEK_END)
last_517_bytes = f.read()
Expand Down
34 changes: 17 additions & 17 deletions lanzou/api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,18 @@ def is_name_valid(filename: str) -> bool:
def is_file_url(share_url: str) -> bool:
"""判断是否为文件的分享链接"""
base_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/.+' # 子域名可个性化设置或者不存在
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/i[a-zA-Z0-9]{5,}/?' # 普通用户 URL 规则
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/i[a-zA-Z0-9]{5,}(\?webpage=[a-zA-Z0-9]+?)?/?' # 普通用户 URL 规则
if not re.fullmatch(base_pat, share_url):
return False
elif re.fullmatch(user_pat, share_url):
if re.fullmatch(user_pat, share_url):
return True
else: # VIP 用户的 URL 很随意
try:
html = requests.get(share_url, headers=headers).text
html = remove_notes(html)
return True if re.search(r'class="fileinfo"|id="file"|文件描述', html) else False
except (requests.RequestException, Exception):
return False
# VIP 用户的 URL 很随意
try:
html = requests.get(share_url, headers=headers).text
html = remove_notes(html)
return True if re.search(r'class="fileinfo"|id="file"|文件描述', html) else False
except (requests.RequestException, Exception):
return False


def is_folder_url(share_url: str) -> bool:
Expand All @@ -99,15 +99,15 @@ def is_folder_url(share_url: str) -> bool:
user_pat = r'https?://[a-zA-Z0-9-]*?\.?lanzou[a-z].com/(/s/)?b[a-zA-Z0-9]{7,}/?'
if not re.fullmatch(base_pat, share_url):
return False
elif re.fullmatch(user_pat, share_url):
if re.fullmatch(user_pat, share_url):
return True
else: # VIP 用户的 URL 很随意
try:
html = requests.get(share_url, headers=headers).text
html = remove_notes(html)
return True if re.search(r'id="infos"', html) else False
except (requests.RequestException, Exception):
return False
# VIP 用户的 URL 很随意
try:
html = requests.get(share_url, headers=headers).text
html = remove_notes(html)
return True if re.search(r'id="infos"', html) else False
except (requests.RequestException, Exception):
return False


def un_serialize(data: bytes):
Expand Down
2 changes: 1 addition & 1 deletion lanzou/cmder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from lanzou.cmder.config import config

version = '2.6.5'
version = '2.6.7'

__all__ = ['cmder', 'utils', 'version', 'config']
4 changes: 3 additions & 1 deletion lanzou/cmder/browser_cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ def __init__(self, cookie_file=None, domain_name="", key_file=None):
'~/.config/microsoft-edge-dev/Default/Cookies'
],
'windows_cookies': [
# Chromium Edge on Windows11
{'env': 'APPDATA', 'path': '..\\Local\\Microsoft\\Edge\\User Data\\Default\\Network\\Cookies'},
{'env': 'APPDATA', 'path': '..\\Local\\Microsoft\\Edge\\User Data\\Default\\Cookies'},
{'env': 'LOCALAPPDATA', 'path': 'Microsoft\\Edge\\User Data\\Default\\Cookies'},
{'env': 'APPDATA', 'path': 'Microsoft\\Edge\\User Data\\Default\\Cookies'}
Expand Down Expand Up @@ -679,7 +681,7 @@ def load_with_keys(domain_name="", keys: list = None) -> (dict, str):
"""
cookie = {}
browser = ""
for cookie_fn in [chrome, chromium, opera, edge, firefox]:
for cookie_fn in [edge, firefox]:
try:
cookie.clear()
for c in cookie_fn(domain_name=domain_name):
Expand Down
5 changes: 4 additions & 1 deletion lanzou/cmder/cmder.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ def __init__(self):
self._prompt = '> '
self._disk = LanZouCloud()
self._is_login = False
# self._disk.ignore_limits()
self._task_mgr = global_task_mgr
self._dir_list = FolderList()
self._file_list = FileList()
Expand All @@ -48,6 +47,10 @@ def __init__(self):
self._disk.set_max_size(config.max_size)
self._disk.set_upload_delay(config.upload_delay)

if ignore_limit():
"""Please take responsibility for your own actions"""
self._disk.ignore_limits()

@staticmethod
def clear():
clear_screen()
Expand Down
13 changes: 8 additions & 5 deletions lanzou/cmder/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def why_error(code):
return '未知错误'


def ignore_limit():
return os.path.exists(".ignore_limit")


def set_console_style():
"""设置命令行窗口样式"""
if os.name != 'nt':
Expand Down Expand Up @@ -86,6 +90,7 @@ def completer(typed, rank):
def print_logo():
"""输出logo"""
clear_screen()
ext_msg = "Unlimited " if ignore_limit() else ""
logo_str = f"""
_ ______ _____ _ _
| | |___ / / __ \ | | |
Expand All @@ -94,7 +99,7 @@ def print_logo():
| |___| (_| | | | | / /__| (_) | |_| | \__/\ | (_) | |_| | (_| |
\_____/\____|_| |_|\_____/\___/ \____|\____/_|\___/ \____|\____|
--------------------------------------------------------------------
Github: https://github.com/zaxtyson/LanZouCloud-CMD (Version: {version})
Github: https://github.com/zaxtyson/LanZouCloud-CMD ({ext_msg}Version: {version})
--------------------------------------------------------------------
"""
print(logo_str)
Expand Down Expand Up @@ -171,12 +176,10 @@ def check_update():
print(f"\n程序可以更新 v{version} -> \033[1;32m{tag_name}\033[0m")
print(f"\n# 更新说明\n\n{msg}")
print(f"\n# Windows 更新\n")
print(f"蓝奏云: https://www.lanzous.com/b0f14h1od")
print(f"蓝奏云: https://zaxtyson.lanzouf.com/b0f14h1od")
print(f"Github: {update_url}")
print(f"国内加速: https://github.91chifun.workers.dev/{update_url}")
print("\n# Linux 更新\n")
print("git clone https://hub.fastgit.org/zaxtyson/LanZouCloud-CMD.git")
input("python3.8 -m pip install -r requirements.txt")
print("git pull --rebase")
else:
print("\n(*/ω\*) 暂无新版本发布~")
print("但项目可能已经更新,建议去项目主页看看")
Expand Down

0 comments on commit cbf11e4

Please sign in to comment.