From 59a238d3729af841026c9c248c9f0957899b611a Mon Sep 17 00:00:00 2001 From: Naga Resst Date: Sat, 23 Nov 2024 18:05:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/auto-update.yaml | 47 +++++++++++++++++++----------- Data/format_item.py | 6 ++-- Paissa.py | 4 +-- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/.github/workflows/auto-update.yaml b/.github/workflows/auto-update.yaml index 9bb9de5..ba8601d 100644 --- a/.github/workflows/auto-update.yaml +++ b/.github/workflows/auto-update.yaml @@ -2,37 +2,50 @@ name: Auto Check and Update Patch Data on: workflow_dispatch: - inputs: - Patch_version: - description: 'Please input the version of FF14 Patch' - required: true schedule: - cron: '0 15 * * 2' jobs: build: runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - # 指定要检出的仓库,默认为当前仓库 - repository: thewakingsands/ffxiv-datamining-cn - # 指定要检出的分支,默认为默认分支 - ref: master - - - name: List files in the repository - run: git tag --list 'patch-.*' - - name: Setup Python if: steps.changes.outputs.version == 'true' uses: actions/setup-python@v4 with: python-version: '3.8' + - name: Check FFXIX CN Patch Code Version + id: check_version + run: | + output=$(git ls-remote https://github.com/thewakingsands/ffxiv-datamining-cn |grep "patch" |awk -F "-" '{print $2}'| tail -1) + echo "::set-output name=patch_version::$output" + - name: Install dependencies - if: steps.changes.outputs.version == 'true' run: | python -m pip install --upgrade pip pip install requests + + - name: Run Python script + run: | + python format_item.py + path: ./Paissa/Data + env: + FFXIV_PATCH_VERSION: {{step.check_version.outputs.patch_version}} + + - name: Configure Git user + run: | + git config --global user.name 'Naga Resst' + git config --global user.email 'nagaresst@live.com' + + - name: Add and commit changes + run: | + git add . + git commit -m 'Update Patch Data' + + - name: Push changes + run: | + git push + env: + GITHUB_TOKEN: ${{ secrets.GIT_KEY }} + diff --git a/Data/format_item.py b/Data/format_item.py index 9b615be..17301cb 100644 --- a/Data/format_item.py +++ b/Data/format_item.py @@ -20,9 +20,9 @@ """ 下载数据文件到本地 """ -patch_version = os.popen("git tag --list 'patch-.*'|tail -1") +patch_version = os.environ['FFXIV_PATCH_VERSION'] -Download_addres = f'https://raw.githubusercontent.com/thewakingsands/ffxiv-datamining-cn/patch-{patch_version}/Item.csv' +Download_addres = f'https://raw.githubusercontent.com/thewakingsands/ffxiv-datamining-cn/master/Item.csv' item_data = requests.get(Download_addres, timeout=9, verify=False) print('拆包数据下载成功,准备保存到本地') with open("Item.csv", "w", encoding='UTF-8') as code: @@ -94,7 +94,7 @@ def get_item_details(item_id): """ 数据写入磁盘 """ -version = {'data-version': '7.0'} +version = {'data-version': patch_version} version.update(item_out_list) with open('item.Pdt', 'w', encoding='utf8') as item_data: diff --git a/Paissa.py b/Paissa.py index e3c5ade..45cbaf4 100644 --- a/Paissa.py +++ b/Paissa.py @@ -42,7 +42,7 @@ data_version = data_json['data-version'] logger.info("本地数据版本 {}".format(data_version)) except: - data_version = None + data_version = 0 logger.error("本地数据版本检查失败") if version_online['program'] != program_version: @@ -62,7 +62,7 @@ except: logger.warning("主程序更新失败") -if version_online['data'] != data_version: +if float(version_online['data']) > float(data_version): market_filter = False try: data_zip = get('https://paissa-data.oss-cn-hongkong.aliyuncs.com/item.zip', timeout=7, proxies=proxies).content