Merge pull request #14 from fengyuecanzhu/dev

update actions
master
fengyuecanzhu 3 years ago committed by GitHub
commit f47f5397b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 99
      .github/scripts/lzy.py
  2. 75
      .github/workflows/reader.yml
  3. 3
      app/src/test/java/Test.java
  4. 3
      app/version_code.properties

@ -0,0 +1,99 @@
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,
verify=True).json()
log(f"{file_dir} -> {res['info']}")
return res['zt'] == 1
# 上传文件夹内的文件
def upload_folder(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):
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)

@ -1,8 +1,6 @@
name: Android CI
name: Auto build and delay
on:
release:
types: [ published ]
push:
branches:
- master
@ -10,6 +8,15 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
# 登录蓝奏云后在控制台运行document.cookie
ylogin: ${{ secrets.LANZOU_ID }}
phpdisk_info: ${{ secrets.LANZOU_PSD }}
# 蓝奏云里的文件夹ID
LANZOU_FOLDER_ID: '2226473'
LANZOU_SHARE_URL: 'https://fycz.lanzoui.com/b00nu1f8d'
# 是否上传到artifact
UPLOAD_ARTIFACT: 'true'
steps:
- uses: actions/checkout@v2
# 获取打包秘钥
@ -28,5 +35,65 @@ jobs:
- name: Upload App To Artifact
uses: actions/upload-artifact@v2
with:
name: fyreader apk
name: FYReader-apk
path: ${{ github.workspace }}/app/build/outputs/apk/release/*.apk
- name: Prepare config
id: config
run: |
echo "获取是否需要创建release并获取配置"
source ${{ github.workspace }}/app/version_code.properties
version=$VERSION_CODE
hun=$(expr ${version} / 100)
ten=$(expr ${version} / 10)
ten=$(expr ${ten} % 10)
one=$(expr ${version} % 10)
versionN=$hun.$ten.$one
echo ::set-output name=need_create_release::"$NEED_CREATE_RELEASE"
echo ::set-output name=version_name::"$versionN"
if [[ $NEED_CREATE_RELEASE == "true" ]];then
echo ::set-env name=LANZOU_FOLDER_ID::"1608604"
echo ::set-env name=LANZOU_SHARE_URL::"https://fycz.lanzoui.com/b00ngso7e"
fi
path="$GITHUB_WORKSPACE/app/build/outputs/apk/release"
files=$(ls $path)
for f in $files
do
if [[ $f == *"apk" ]]; then
file=$f
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 文件:$file"
break
fi
done
echo ::set-output name=file_name::"$file"
echo ::set-output name=file_path::"$path/$file"
- name: Create Release
id: create_release
if: ${{ steps.config.outputs.need_create_release == "true" }}
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TZ: Asia/Shanghai
with:
tag_name: ${{ steps.config.outputs.version_name }}
release_name: FYReader_${{ steps.config.outputs.version_name }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload_release_asset
if: ${{ steps.config.outputs.need_create_release == "true" && steps.create_release.outputs.upload_url }}
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.config.outputs.file_path }}
asset_name: FYReader_${{ steps.config.outputs.version_name }}.apk
asset_content_type: application/vnd.android.package-archive
- name: Upload App To Lanzou
if: ${{ env.ylogin }}
run: |
python3 $GITHUB_WORKSPACE/.github/scripts/lzy.py "${{ steps.config.outputs.file_path }}" "$LANZOU_FOLDER_ID"
echo "[$(date -u -d '+8 hour' '+%Y.%m.%d %H:%M:%S')] 分享链接: $LANZOU_SHARE_URL"

@ -3,13 +3,10 @@ import org.seimicrawler.xpath.JXDocument;
import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import xyz.fycz.myreader.ai.MatrixUtil;
import xyz.fycz.myreader.model.sourceAnalyzer.BaseAnalyzer;
import xyz.fycz.myreader.util.utils.FileUtils;
import xyz.fycz.myreader.util.utils.GsonUtils;
import xyz.fycz.myreader.util.utils.NetworkUtils;
/**

@ -1,2 +1,3 @@
#Fri Jun 18 21:45:31 CST 2021
VERSION_CODE=213
VERSION_CODE=214
NEED_CREATE_RELEASE=true

Loading…
Cancel
Save