feat(project): 初始化项目结构和配置

This commit is contained in:
2026-06-10 04:09:02 +08:00
parent 2d301cf1c3
commit 45f883b772
1815 changed files with 315166 additions and 0 deletions
+92
View File
@@ -0,0 +1,92 @@
#!/usr/bin/env bash
#分支Stable Dev Beta
branch=$1
#api 最大偏移
max_offset=$2
[ -z $1 ] && branch=Stable
[ -z $2 ] && max_offset=3
[ -z $GITHUB_ENV ] && echo "Error: Unexpected github workflow environment" && exit
offset=0
function fetch_version() {
# 获取最新cronet版本
lastest_cronet_version=`curl -s "https://chromiumdash.appspot.com/fetch_releases?channel=$branch&platform=Android&num=1&offset=$offset" | jq .[0].version -r`
echo "lastest_cronet_version: $lastest_cronet_version"
#lastest_cronet_version=100.0.4845.0
lastest_cronet_main_version=${lastest_cronet_version%%\.*}.0.0.0
check_version_exit
}
function check_version_exit() {
# 检查版本是否存在
local jar_url="https://storage.googleapis.com/chromium-cronet/android/$lastest_cronet_version/Release/cronet/cronet_api.jar"
statusCode=$(curl -s -I -w %{http_code} "$jar_url" -o /dev/null)
if [ $statusCode == "404" ]; then
echo "storage.googleapis.com return 404 for cronet $lastest_cronet_version"
if [[ $max_offset > $offset ]]; then
offset=$(expr $offset + 1)
echo "retry with offset $offset"
fetch_version
else
exit
fi
fi
}
function version_compare() {
# 版本号比较 本地版本小于远程版本时返回0
local local_version=$1
local remote_version=$2
if [[ $local_version == $remote_version ]]; then
return 1
fi
if [[ $(printf '%s\n' "$1" "$2" | sort -V | head -n1) == $remote_version ]]; then
return 1
else
return 0
fi
}
# 添加变量到github env
function write_github_env_variable() {
echo "$1=$2" >> $GITHUB_ENV
}
function sync_proguard_rules() {
local raw_github_git="https://raw.githubusercontent.com/chromium/chromium/$lastest_cronet_version"
local proguard_paths=(
components/cronet/android/cronet_combined_impl_native_proguard_golden.cfg
)
local proguard_rules_path="$GITHUB_WORKSPACE/app/cronet-proguard-rules.pro"
rm -f $proguard_rules_path
echo "fetch cronet proguard rules from upstream $raw_github_git"
for path in ${proguard_paths[@]}
do
echo "fetching $path ..."
curl "$raw_github_git/$path" >> $proguard_rules_path
done
}
##########
# 获取本地cronet版本
path=$GITHUB_WORKSPACE/gradle.properties
current_cronet_version=`cat $path | grep CronetVersion | sed s/CronetVersion=//`
echo "current_cronet_version: $current_cronet_version"
echo "fetch $branch release info from https://chromiumdash.appspot.com ..."
fetch_version
if version_compare $current_cronet_version $lastest_cronet_version; then
# 更新gradle.properties
sed -i s/CronetVersion=.*/CronetVersion=$lastest_cronet_version/ $path
sed -i s/CronetMainVersion=.*/CronetMainVersion=$lastest_cronet_main_version/ $path
# 更新cronet_proguard_rules.pro
sync_proguard_rules
# 更新cronet版本
sed -i "s/## cronet版本: .*/## cronet版本: $lastest_cronet_version/" $GITHUB_WORKSPACE/app/src/main/assets/updateLog.md
# 生成pull request信息
write_github_env_variable PR_TITLE "Bump cronet from $current_cronet_version to $lastest_cronet_version"
write_github_env_variable PR_BODY "Changes in the [Git log](https://chromium.googlesource.com/chromium/src/+log/$current_cronet_version..$lastest_cronet_version)"
# 生成cronet flag
write_github_env_variable cronet ok
fi
+98
View File
@@ -0,0 +1,98 @@
import requests, os, datetime, sys
# Cookie 中 phpdisk_info 的值
cookie_phpdisk_info = os.environ.get('phpdisk_info')
# Cookie 中 ylogin 的值
cookie_ylogin = os.environ.get('ylogin')
# 请求头
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'
}
# 小饼干
cookie = {
'ylogin': cookie_ylogin,
'phpdisk_info': cookie_phpdisk_info
}
# 日志打印
def log(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}")
# 检查是否已登录
def login_by_cookie():
url_account = "https://pc.woozooo.com/account.php"
if cookie['phpdisk_info'] is None:
log('ERROR: 请指定 Cookie 中 phpdisk_info 的值!')
return False
if cookie['ylogin'] is None:
log('ERROR: 请指定 Cookie 中 ylogin 的值!')
return False
res = requests.get(url_account, headers=headers, cookies=cookie, verify=True)
if '网盘用户登录' in res.text:
log('ERROR: 登录失败,请更新Cookie')
return False
else:
log('登录成功')
return True
# 上传文件
def upload_file(file_dir, folder_id):
file_name = os.path.basename(file_dir)
url_upload = "https://up.woozooo.com/fileup.php"
headers['Referer'] = f'https://up.woozooo.com/mydisk.php?item=files&action=index&u={cookie_ylogin}'
post_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 = requests.post(url_upload, data=post_data, files=files, headers=headers, cookies=cookie, timeout=120).json()
log(f"{file_dir} -> {res['info']}")
return res['zt'] == 1
# 上传文件夹内的文件
def upload_folder(folder_dir, folder_id):
file_list = sorted(os.listdir(folder_dir), reverse=True)
for file in file_list:
path = os.path.join(folder_dir, file)
if os.path.isfile(path):
upload_file(path, folder_id)
else:
upload_folder(path, folder_id)
# 上传
def upload(dir, folder_id):
if dir is None:
log('ERROR: 请指定上传的文件路径')
return
if folder_id is None:
log('ERROR: 请指定蓝奏云的文件夹id')
return
if os.path.isfile(dir):
upload_file(dir, str(folder_id))
else:
upload_folder(dir, str(folder_id))
if __name__ == '__main__':
argv = sys.argv[1:]
if len(argv) != 2:
log('ERROR: 参数错误,请以这种格式重新尝试\npython lzy_web.py 需上传的路径 蓝奏云文件夹id')
# 需上传的路径
upload_path = argv[0]
# 蓝奏云文件夹id
lzy_folder_id = argv[1]
if login_by_cookie():
upload(upload_path, lzy_folder_id)
+47
View File
@@ -0,0 +1,47 @@
import os, sys, telebot
# 上传文件
def upload_file(tb, chat_id, file_dir):
doc = open(file_dir, 'rb')
tb.send_document(chat_id, doc)
# 上传文件夹内的文件
def upload_folder(tb, chat_id, folder_dir):
file_list = sorted(os.listdir(folder_dir))
for file in file_list:
path = os.path.join(folder_dir, file)
if os.path.isfile(path):
upload_file(tb, chat_id, path)
else:
upload_folder(tb, chat_id, path)
# 上传
def upload(tb, chat_id, dir):
if tb is None:
log('ERROR: 输入正确的token')
return
if chat_id is None:
log('ERROR: 输入正确的chat_id')
return
if dir is None:
log('ERROR: 请指定上传的文件路径')
return
if os.path.isfile(dir):
upload_file(tb, chat_id, dir)
else:
upload_folder(tb, chat_id, dir)
if __name__ == '__main__':
argv = sys.argv[1:]
if len(argv) != 3:
log('ERROR: 参数错误,请以这种格式重新尝试\npython tg_bot.py $token $chat_id 待上传的路径')
# Token
TOKEN = argv[0]
# chat_id
chat_id = argv[1]
# 待上传文件的路径
upload_path = argv[2]
#创建连接
tb = telebot.TeleBot(TOKEN)
#开始上传
upload(tb, chat_id, upload_path)