From 7be6eb9284c8ceb0be0e944ee3022045d6abb1dd Mon Sep 17 00:00:00 2001 From: cxfksword <718792+cxfksword@users.noreply.github.com> Date: Sat, 16 Dec 2023 15:33:23 +0800 Subject: [PATCH] tweak: revert back cn domain --- .github/workflows/publish.yaml | 31 ++++++++++++------------------- README.md | 8 +++++++- scripts/generate_manifest.py | 21 ++++++++++++--------- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 4b46487..8c7324b 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -44,30 +44,23 @@ jobs: dotnet publish --nologo --no-restore --configuration=Release --framework=net6.0 -p:Version=${{steps.vars.outputs.VERSION}} ${{ env.project }} mkdir -p artifacts zip -j ./artifacts/${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ./Jellyfin.Plugin.Danmu/bin/Release/net6.0/Jellyfin.Plugin.Danmu.dll - cp ./doc/logo.png ./artifacts/logo.png - name: Generate manifest - run: cd artifacts && python3 ../scripts/generate_manifest.py ${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ${GITHUB_REF#refs/*/} - - name: Deploy to jellyfin release repo - uses: peaceiris/actions-gh-pages@v3 - with: - personal_token: ${{ secrets.PAT }} - external_repository: cxfksword/jellyfin-release - destination_dir: ${{ env.artifact }} - publish_branch: master - publish_dir: ./artifacts - keep_files: true + run: python3 ./scripts/generate_manifest.py ./artifacts/${{ env.artifact }}_${{steps.vars.outputs.VERSION}}.zip ${GITHUB_REF#refs/*/} + env: + CN_DOMAIN: ${{ vars.CN_DOMAIN }} - name: Publish release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ./artifacts/${{ env.artifact }}_*.zip tag: ${{ github.ref }} + overwrite: true + file_glob: true + - name: Publish manifest + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./manifest*.json + tag: "manifest" + overwrite: true file_glob: true - # - name: Publish manifest - # uses: svenstaro/upload-release-action@v2 - # with: - # repo_token: ${{ secrets.GITHUB_TOKEN }} - # file: ./artifacts/manifest*.json - # tag: "manifest" - # overwrite: true - # file_glob: true diff --git a/README.md b/README.md index cab3d71..63c22f6 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,13 @@ jellyfin弹幕自动下载插件,已支持的弹幕来源:b站,弹弹play 只支持最新的`jellyfin 10.8.x`版本 -添加插件存储库:https://jellyfin-plugin-release.pages.dev/danmu/manifest.json +添加插件存储库: + +国内加速:https://mirror.ghproxy.com/https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest_cn.json + +国外访问:https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest.json + +> 如果都无法访问,可以直接从 [Release](https://github.com/cxfksword/jellyfin-plugin-metashark/releases) 页面下载,并解压到 jellyfin 插件目录中使用 ## 如何使用 diff --git a/scripts/generate_manifest.py b/scripts/generate_manifest.py index f7dd14b..435fc2c 100755 --- a/scripts/generate_manifest.py +++ b/scripts/generate_manifest.py @@ -18,7 +18,7 @@ def generate_manifest(): "overview": "jellyfin弹幕下载插件", "owner": "cxfksword", "category": "Metadata", - "imageUrl": "https://jellyfin-plugin-release.pages.dev/danmu/logo.png", + "imageUrl": "https://github.com/cxfksword/jellyfin-plugin-danmu/raw/main/doc/logo.png", "versions": [] }] @@ -27,7 +27,7 @@ def generate_version(filepath, version, changelog): 'version': f"{version}.0", 'changelog': changelog, 'targetAbi': '10.8.0.0', - 'sourceUrl': f'https://jellyfin-plugin-release.pages.dev/danmu/danmu_{version}.0.zip', + 'sourceUrl': f'https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/v{version}/danmu_{version}.0.zip', 'checksum': md5sum(filepath), 'timestamp': datetime.now().strftime('%Y-%m-%dT%H:%M:%S') } @@ -47,7 +47,7 @@ def main(): # 解析旧 manifest try: - with urlopen('https://raw.githubusercontent.com/cxfksword/jellyfin-release/master/danmu/manifest.json') as f: + with urlopen('https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/manifest/manifest.json') as f: manifest = json.load(f) except HTTPError as err: if err.code == 404: @@ -62,12 +62,15 @@ def main(): with open('manifest.json', 'w') as f: json.dump(manifest, f, indent=2) - # # 国内加速 - # with open('manifest_cn.json', 'w') as f: - # manifest_cn = json.dumps(manifest, indent=2) - # manifest_cn = re.sub('https://github.com/cxfksword/jellyfin-plugin-danmu/raw/main/doc/logo.png', "https://jellyfin-plugin-release.pages.dev/danmu/logo.png", manifest_cn) - # manifest_cn = re.sub('https://github.com/cxfksword/jellyfin-plugin-danmu/releases/download/v[0-9.]+', "https://jellyfin-plugin-release.pages.dev/danmu", manifest_cn) - # f.write(manifest_cn) + # 国内加速 + cn_domain = 'https://mirror.ghproxy.com/' + if 'CN_DOMAIN' in os.environ: + cn_domain = os.environ["CN_DOMAIN"] + cn_domain = cn_domain.rstrip('/') + with open('manifest_cn.json', 'w') as f: + manifest_cn = json.dumps(manifest, indent=2) + manifest_cn = re.sub('https://github.com', f'{cn_domain}/https://github.com', manifest_cn) + f.write(manifest_cn) if __name__ == '__main__':