parent
26b0948b89
commit
b995df065a
@ -1,60 +0,0 @@ |
|||||||
#!/usr/bin/env bash |
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin |
|
||||||
export PATH |
|
||||||
# -------------------------------------------------------------- |
|
||||||
# 系统: ALL |
|
||||||
# 项目: 蓝奏云上传文件 |
|
||||||
# 版本: 1.0.3 |
|
||||||
# 作者: XIU2 |
|
||||||
# 官网: https://shell.xiu2.xyz |
|
||||||
# 项目: https://github.com/XIU2/Shell |
|
||||||
# -------------------------------------------------------------- |
|
||||||
|
|
||||||
USERNAME="admin" # 蓝奏云用户名 |
|
||||||
COOKIE_PHPDISK_INFO="$LANZOU_PSD" # Cookie 中 phpdisk_info 的值 |
|
||||||
COOKIE_YLOGIN="$LANZOU_ID" # Cookie 中 ylogin 的值 |
|
||||||
|
|
||||||
UA="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.7.3670.199 Safari/537.36" |
|
||||||
HEADER_CHECK_LOGIN="User-Agent: ${UA} |
|
||||||
Referer: https://up.woozooo.com/mydisk.php?item=files&action=index&u=${USERNAME} |
|
||||||
Accept-Language: zh-CN,zh;q=0.9" |
|
||||||
|
|
||||||
URL_ACCOUNT="https://pc.woozooo.com/account.php" |
|
||||||
URL_UPLOAD="https://up.woozooo.com/fileup.php" |
|
||||||
|
|
||||||
INFO="[信息]" && ERROR="[错误]" && TIP="[注意]" |
|
||||||
|
|
||||||
# 检查是否已登录 |
|
||||||
_CHECK_LOGIN() { |
|
||||||
if [[ "${COOKIE_PHPDISK_INFO}" = "" || "${COOKIE_PHPDISK_INFO}" = "XXX" ]]; then |
|
||||||
_NOTICE "ERROR" "请指定 Cookie 中 phpdisk_info 的值!" |
|
||||||
fi |
|
||||||
if [[ "${COOKIE_YLOGIN}" = "" || "${COOKIE_YLOGIN}" = "XXX" ]]; then |
|
||||||
_NOTICE "ERROR" "请指定 Cookie 中 ylogin 的值!" |
|
||||||
fi |
|
||||||
|
|
||||||
HTML_CHECK_LOGIN=$(curl -s --http1.1 -b "ylogin=${COOKIE_YLOGIN};phpdisk_info=${COOKIE_PHPDISK_INFO}" -H "${HEADER_CHECK_LOGIN}" "${URL_ACCOUNT}"|grep "登录") |
|
||||||
[[ ! -z "${HTML_CHECK_LOGIN}" ]] && _NOTICE "ERROR" "Cookie 已失效,请更新!" |
|
||||||
} |
|
||||||
|
|
||||||
# 上传文件 |
|
||||||
_UPLOAD() { |
|
||||||
[[ $(du "${NAME_FILE}"|awk '{print $1}') -gt 100000000 ]] && _NOTICE "ERROR" "${NAME}文件大于 100MB!" |
|
||||||
HTML_UPLOAD=$(curl --connect-timeout 120 -m 5000 --retry 2 -s -b "ylogin=${COOKIE_YLOGIN};phpdisk_info=${COOKIE_PHPDISK_INFO}" -H "${URL_UPLOAD}" -F "task=1" -F "id=WU_FILE_0" -F "folder_id=${FOLDER_ID}" -F "name=${NAME}" -F "upload_file=@${NAME_FILE}" "${URL_UPLOAD}"|grep '\\u4e0a\\u4f20\\u6210\\u529f') |
|
||||||
[[ -z "${HTML_UPLOAD}" ]] && _NOTICE "ERROR" "${NAME}文件上传失败!" |
|
||||||
echo -e "${INFO} 文件上传成功![$(date -u -d '+8 hour' '+%Y-%m-%d %H:%M:%S')]" |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
NAME="$1" # 文件名 |
|
||||||
NAME_FILE="$2" # 文件路径 |
|
||||||
FOLDER_ID="$3" # 上传文件夹ID |
|
||||||
if [[ -z "${NAME}" ]]; then |
|
||||||
echo -e "${ERROR} 未指定文件名!" && exit 1 |
|
||||||
elif [[ -z "${NAME_FILE}" ]]; then |
|
||||||
echo -e "${ERROR} 未指定文件路径!" && exit 1 |
|
||||||
elif [[ -z "${FOLDER_ID}" ]]; then |
|
||||||
echo -e "${ERROR} 未指定上传文件夹ID!" && exit 1 |
|
||||||
fi |
|
||||||
_CHECK_LOGIN |
|
||||||
_UPLOAD |
|
@ -0,0 +1,119 @@ |
|||||||
|
import requests, os, datetime, sys |
||||||
|
|
||||||
|
|
||||||
|
class lzyCloud(object): |
||||||
|
def __init__(self): |
||||||
|
self._session = requests.Session() |
||||||
|
self._timeout = 30 # 每个请求的超时(不包含下载响应体的用时) |
||||||
|
self._doupload_url = 'https://pc.woozooo.com/doupload.php' |
||||||
|
self._account_url = 'https://pc.woozooo.com/account.php' |
||||||
|
self._cookies = None |
||||||
|
self._headers = { |
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36 Edg/89.0.774.45', |
||||||
|
'Accept-Language': 'zh-CN,zh;q=0.9', |
||||||
|
'Referer': 'https://pc.woozooo.com/account.php?action=login' |
||||||
|
} |
||||||
|
# disable_warnings(InsecureRequestWarning) # 全局禁用 SSL 警告 |
||||||
|
|
||||||
|
# 日志打印 |
||||||
|
def _log(self, msg): |
||||||
|
utc_time = datetime.datetime.utcnow() |
||||||
|
china_time = utc_time + datetime.timedelta(hours=8) |
||||||
|
print(f"[{china_time.strftime('%Y.%m.%d %H:%M:%S')}] {msg}") |
||||||
|
|
||||||
|
# get请求 |
||||||
|
def _get(self, url, **kwargs): |
||||||
|
try: |
||||||
|
kwargs.setdefault('timeout', self._timeout) |
||||||
|
kwargs.setdefault('headers', self._headers) |
||||||
|
return self._session.get(url, verify=True, **kwargs) |
||||||
|
except (ConnectionError, requests.RequestException): |
||||||
|
return None |
||||||
|
|
||||||
|
# post请求 |
||||||
|
def _post(self, url, data, **kwargs): |
||||||
|
try: |
||||||
|
kwargs.setdefault('timeout', self._timeout) |
||||||
|
kwargs.setdefault('headers', self._headers) |
||||||
|
return self._session.post(url, data, verify=True, **kwargs) |
||||||
|
except (ConnectionError, requests.RequestException): |
||||||
|
return None |
||||||
|
|
||||||
|
# 通过cookie登录 |
||||||
|
def login_by_cookie(self, cookies: dict) -> bool: |
||||||
|
self._cookies = cookies |
||||||
|
self._session.cookies.update(self._cookies) |
||||||
|
res = self._get(self._account_url) |
||||||
|
if not res: |
||||||
|
self._log('登录失败,请重试') |
||||||
|
return False |
||||||
|
if '网盘用户登录' in res.text: |
||||||
|
self._log('登录失败,请更新Cookie') |
||||||
|
return False |
||||||
|
else: |
||||||
|
self._log('登录成功') |
||||||
|
return True |
||||||
|
|
||||||
|
# 上传文件 |
||||||
|
def _upload_file(self, file_dir, folder_id): |
||||||
|
file_name = os.path.basename(file_dir) |
||||||
|
self._headers['Referer'] = 'https://up.woozooo.com/mydisk.php?item=files&action=index&u=' + self._cookies.get( |
||||||
|
"ylogin") |
||||||
|
data = { |
||||||
|
"task": "1", |
||||||
|
"folder_id": folder_id, |
||||||
|
"id": "WU_FILE_0", |
||||||
|
"name": file_name, |
||||||
|
} |
||||||
|
files = {'upload_file': (file_name, open(file_dir, "rb"), 'application/octet-stream')} |
||||||
|
res = self._post(self._doupload_url, data=data, files=files).json() |
||||||
|
self._log(f"{file_dir} -> {res['info']}") |
||||||
|
return res['zt'] == 1 |
||||||
|
|
||||||
|
# 上传文件夹内的文件 |
||||||
|
def _upload_folder(self, folder_dir, folder_id): |
||||||
|
file_list = os.listdir(folder_dir) |
||||||
|
for file in file_list: |
||||||
|
path = os.path.join(folder_dir, file) |
||||||
|
if os.path.isfile(path): |
||||||
|
self._upload_file(path, folder_id) |
||||||
|
else: |
||||||
|
self._upload_folder(path, folder_id) |
||||||
|
|
||||||
|
# 上传文件/文件夹内的文件 |
||||||
|
def upload(self, dir, folder_id): |
||||||
|
if dir is None: |
||||||
|
self._log('请指定上传的文件路径') |
||||||
|
return |
||||||
|
if folder_id is None: |
||||||
|
self._log('请指定蓝奏云的文件夹id') |
||||||
|
return |
||||||
|
if os.path.isfile(dir): |
||||||
|
self._upload_file(dir, str(folder_id)) |
||||||
|
else: |
||||||
|
self._upload_folder(dir, str(folder_id)) |
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__': |
||||||
|
argv = sys.argv[1:] |
||||||
|
if len(argv) != 2: |
||||||
|
print('参数错误,请以这种格式重新尝试\npython lzy_web.py 需上传的路径 蓝奏云文件夹id') |
||||||
|
# 需上传的路径 |
||||||
|
upload_path = argv[0] |
||||||
|
# 蓝奏云文件夹id |
||||||
|
lzy_folder_id = argv[1] |
||||||
|
|
||||||
|
# Cookie 中 phpdisk_info 的值 |
||||||
|
phpdisk_info = os.environ.get('phpdisk_info') |
||||||
|
# Cookie 中 ylogin 的值 |
||||||
|
ylogin = os.environ.get('ylogin') |
||||||
|
|
||||||
|
# 小饼干 |
||||||
|
cookie = { |
||||||
|
'ylogin': ylogin, |
||||||
|
'phpdisk_info': phpdisk_info |
||||||
|
} |
||||||
|
|
||||||
|
lzy = lzyCloud() |
||||||
|
if lzy.login_by_cookie(cookie): |
||||||
|
lzy.upload(upload_path, lzy_folder_id) |
File diff suppressed because one or more lines are too long
@ -1,3 +1,3 @@ |
|||||||
<!DOCTYPE html><html lang="en" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="favicon.ico" /><![endif]--><title>Legado Bookshelf</title><link href="css/about.dbe575e1.css" rel="prefetch"><link href="css/detail.b4324411.css" rel="prefetch"><link href="js/about.4300b5ad.js" rel="prefetch"><link href="js/about~detail.c1b29cbc.js" rel="prefetch"><link href="js/detail.4d0609e7.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.ad4ff18f.css" rel="preload" as="style"><link href="js/app.acf50eba.js" rel="preload" as="script"><link href="js/chunk-vendors.1042cf7f.js" rel="preload" as="script"><link href="css/chunk-vendors.ad4ff18f.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="img/icons/favicon-16x16.png"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="yd-web-tool"><link rel="apple-touch-icon" href="img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><style>body::-webkit-scrollbar { |
<!DOCTYPE html><html lang="en" style="padding: 0;height:100%"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><!--[if IE]><link rel="icon" href="favicon.ico" /><![endif]--><title>Legado Bookshelf</title><link href="css/about.dbe575e1.css" rel="prefetch"><link href="css/detail.79c91c30.css" rel="prefetch"><link href="js/about.32f651f9.js" rel="prefetch"><link href="js/about~detail.c1b29cbc.js" rel="prefetch"><link href="js/detail.0cc184f2.js" rel="prefetch"><link href="css/app.e4c919b7.css" rel="preload" as="style"><link href="css/chunk-vendors.ad4ff18f.css" rel="preload" as="style"><link href="js/app.3f3311a5.js" rel="preload" as="script"><link href="js/chunk-vendors.305d5536.js" rel="preload" as="script"><link href="css/chunk-vendors.ad4ff18f.css" rel="stylesheet"><link href="css/app.e4c919b7.css" rel="stylesheet"><link rel="icon" type="image/png" sizes="32x32" href="img/icons/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="img/icons/favicon-16x16.png"><link rel="manifest" href="manifest.json"><meta name="theme-color" content="#4DBA87"><meta name="apple-mobile-web-app-capable" content="no"><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="apple-mobile-web-app-title" content="yd-web-tool"><link rel="apple-touch-icon" href="img/icons/apple-touch-icon-152x152.png"><link rel="mask-icon" href="img/icons/safari-pinned-tab.svg" color="#4DBA87"><meta name="msapplication-TileImage" content="img/icons/msapplication-icon-144x144.png"><meta name="msapplication-TileColor" content="#000000"></head><style>body::-webkit-scrollbar { |
||||||
display: none; |
display: none; |
||||||
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.1042cf7f.js"></script><script src="js/app.acf50eba.js"></script></body></html> |
}</style><body style="margin: 0;height:100%"><noscript><strong>We're sorry but yd-web-tool doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="js/chunk-vendors.305d5536.js"></script><script src="js/app.3f3311a5.js"></script></body></html> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue