Skip to content

Commit

Permalink
chore: 自动上传蓝奏云
Browse files Browse the repository at this point in the history
  • Loading branch information
jing332 committed Jan 29, 2024
1 parent eaeb3eb commit eda8d21
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 9 deletions.
98 changes: 98 additions & 0 deletions .github/scripts/lzy_web.py
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 23 additions & 8 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,16 @@ jobs:
needs: go-lib
strategy:
matrix:
product: [ { name: "App原版", value: app }, { name: "Dev共存版", value: dev } ]
product: [ { name: "App原版", value: app, lzyId: "9493563" }, { name: "Dev共存版", value: dev, lzyId: "7381570" } ]

fail-fast: false
runs-on: ubuntu-latest
env:
product: ${{ matrix.product.value }}
product_name: ${{matrix.product.value}}
product_name: ${{ matrix.product.value }}
lzy_folder_id: ${{ matrix.product.lzyId }}
ylogin: ${{ secrets.LANZOU_ID }}
phpdisk_info: ${{ secrets.LANZOU_PSD }}
outputs_dir: "${{ github.workspace }}/app/build/outputs"
ver_name: ""

Expand Down Expand Up @@ -85,15 +88,27 @@ jobs:
- name: Init environment variable
run: |
echo "ver_name=$(grep -m 1 'versionName' ${{ env.outputs_dir }}/apk/${{ env.product }}/release/output-metadata.json | cut -d\" -f4)" >> $GITHUB_ENV
echo "apk_path=${{env.outputs_dir}}/apk/${{ env.product }}/release/*${{ env.ver_name }}.apk" > $GITHUB_ENV
# - name: Upload Mappings to Artifact
# uses: actions/upload-artifact@v3
# with:
# name: mappings_${{ env.product }}_${{ env.ver_name }}
# path: ${{ env.outputs_dir }}/mapping/*/*.txt
# - name: Upload Mappings to Artifact
# uses: actions/upload-artifact@v3
# with:
# name: mappings_${{ env.product }}_${{ env.ver_name }}
# path: ${{ env.outputs_dir }}/mapping/*/*.txt

- name: Upload APK To Artifact
uses: actions/upload-artifact@v3
with:
name: "TTS-Server_${{ env.product }}_${{ env.ver_name }}"
path: ${{env.outputs_dir}}/apk/${{ env.product }}/release/*${{ env.ver_name }}.apk
path: ${{ env.apk_path }}

- name: Upload APK To Lanzouyun
run: |
python3 $GITHUB_WORKSPACE/.github/scripts/lzy_web.py "${{ env.apk_path }}" "${{ env.lzy_folder_id }}"
echo "app: https://jing332.lanzn.com/b09jpjd2d"
echo "dev: https://jing332.lanzn.com/b09ig9qla"
echo "密码PWD: 1234"
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dependencies {
implementation 'com.squareup.okhttp3:okhttp:4.11.0'
implementation 'com.github.liangjingkanji:Net:3.6.4'

implementation 'me.rosuh:AndroidFilePicker:0.8.3'
implementation 'me.rosuh:AndroidFilePicker:1.0.1'
implementation 'com.louiscad.splitties:splitties-systemservices:3.0.0'

implementation 'cn.hutool:hutool-crypto:5.8.19'
Expand Down

0 comments on commit eda8d21

Please sign in to comment.