[
  {
    "path": ".github/dependabot.yml",
    "content": "# To get started with Dependabot version updates, you'll need to specify which\n# package ecosystems to update and where the package manifests are located.\n# Please see the documentation for all configuration options:\n# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates\n\nversion: 2\nupdates:\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\"\n"
  },
  {
    "path": ".github/scripts/upload.py",
    "content": "import os\nimport json\nimport requests\n\napiAddress = \"http://127.0.0.1:8081/\"\nTELEGRAM_TOKEN = os.getenv(\"TELEGRAM_TOKEN\", \"\")\nCHAT_ID = os.environ.get(\"CHAT_ID\", \"\")\nurlPrefix = apiAddress + \"bot\" + TELEGRAM_TOKEN\n\ndef get_caption() -> str:\n    with open(\"caption.txt\", \"r\", encoding=\"utf-8\") as f:\n        return f.read()\n\ndef genFileDirectory(path):\n    files = {}\n    media = []\n    for root, dirs, file_name_dic in os.walk(path):\n        for fileName in sorted(file_name_dic):\n            files[fileName] = open(path + \"/\" + fileName, \"rb\")\n            media.append(dict(type='document', media=f'attach://{fileName}'))\n    media[-1]['caption'] = get_caption()\n    media[-1]['parse_mode'] = \"Markdown\"\n    return media, files\n\ndef sendAPKs(path):\n    media, files = genFileDirectory(path)\n    parma = {\n        \"chat_id\": CHAT_ID,\n        \"media\": json.dumps(media)\n    }\n    response = requests.post(urlPrefix + \"/sendMediaGroup\", params=parma, files=files)\n    print(response.json())\n\nif __name__ == \"__main__\":\n    apk_path = \"./apk\"\n    sendAPKs(apk_path)\n"
  },
  {
    "path": ".github/workflows/test.yml",
    "content": "name: Test\n\non:\n  schedule:\n    - cron: 59 */8 * * *\n  workflow_dispatch:\n    inputs:\n      rebuild:\n        description: '忽略构建记录以重新构建'\n        required: false\n        type: boolean\n      donotpublish:\n        description: '构建后不提交发布新版'\n        required: false\n        type: boolean\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    strategy:\n      fail-fast: false\n      matrix:\n        include:\n          - userName: q215613905\n            repoName: TVBoxOS\n            branchName: main\n          - userName: takagen99\n            repoName: Box\n            branchName: main\n            java_ver: 17\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n        with:\n          fetch-depth: 0\n      - name: Check New Commit\n        run: |\n          upStream=https://github.com/${{ matrix.userName }}/${{ matrix.repoName }}\n          echo \"upStream=$upStream\" >> $GITHUB_ENV\n          commit=$(curl -sL $upStream/commits/${{ matrix.branchName }} |grep -o \"/${{ matrix.userName }}/${{ matrix.repoName }}/commit/[a-z0-9]\\+\" |head -1 | cut -d\\/ -f5)\n          if [[ -z \"${commit}\" ]]; then\n            commit=$(curl -s \"https://api.github.com/repos/${{ matrix.userName }}/${{ matrix.repoName }}/commits/${{ matrix.branchName }}?per_page=1\" | jq -r '.sha' )\n          fi\n          if ! grep -q \"$commit\" README.md || [ \"${{ inputs.rebuild }}\" == \"true\" ]; then\n            echo \"commit=$commit\" >> $GITHUB_ENV\n            echo \"commitS=${commit:0:7}\" >> $GITHUB_ENV\n          fi\n          echo \"commit=$commit\"\n      - name: Checkout Source Code\n        if: ${{ env.commit }}\n        run: |\n          git clone ${{ env.upStream }} TVBoxOSC\n          cd TVBoxOSC\n          git checkout ${{ env.commit }}\n          echo \"tag=$(git log --date=format:'%Y%m%d-%H%M' --pretty=format:%cd ${{ env.commitS }} -1)\" >> $GITHUB_ENV\n      - name: Extra Modify\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          echo '修改VersionName'\n          if [ \"${{ matrix.userName }}\" == \"takagen99\" ]; then\n            # 进行 sed 修改\n            sed -i 's/\\.concat(buildTime())/ +\\\"${{ env.tag }}\\\"/g' app/build.gradle \n            # 目前关于页面没有合并我的分支\n            sed -i \"/android:text=/s#=\\\"#=\\\"${{ env.tag }}\\\\\\\\n\\\\\\\\n#\" app/src/main/res/layout/dialog_about.xml\n          else\n             sed -i \"/versionName/s#[0-9a-zA-Z_\\.\\'\\\"-]\\+\\$#\\'${{ env.tag }}\\'#\" app/build.gradle\n             sed -i \"/android:text=/s#=\\\"#=\\\"${{ env.tag }}\\\\\\\\n\\\\\\\\n#\" app/src/main/res/layout/dialog_about.xml\n          fi \n          echo 'crosswalk源，防挂'\n          if grep -q 'crosswalk' build.gradle; then\n            sed -i \"/crosswalk/a\\        maven { url 'https://j4uq.github.io/crosswalk/releases/crosswalk/android/maven2' }\" build.gradle\n          else\n            sed -i \"/jitpack.io/a\\        maven { url 'https://j4uq.github.io/crosswalk/releases/crosswalk/android/maven2' }\" build.gradle\n          fi\n      - name: Compress Source Code\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          #zip -q -x \".git/*\" -x  \".github/*\" -r sourceCode-${{ env.commitS }}.zip .\n          tar -cJf sourceCode-${{ env.commitS }}.tar.xz --exclude=.git --exclude=.github *\n      \n      - name: Setup Python\n        #if: ${{ matrix.userName == 'q215613905' && env.commit }}\n        if: ${{ env.commit }}\n        uses: actions/setup-python@v6\n        with:\n          python-version: '3.8'\n\n      - name: Install Python dependencies\n        #if: ${{ matrix.userName == 'q215613905' && env.commit }}\n        if: ${{ env.commit }}\n        run: |\n          python -m pip install --upgrade pip\n          pip install lxml ujson pyquery requests jsonpath cachetools pycryptodome beautifulsoup4\n\n      - name: Modify pyramid——build.gradle\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          # 替换Windows路径为系统Python路径\n          # sed -i \"s|buildPython(\\\"D:/Programs/Python/Python38/python.exe\\\")|buildPython(\\\"/usr/bin/python3\\\")|g\" pyramid/build.gradle\n          sed -i '/buildPython.*python.exe/d' pyramid/build.gradle\n\n      - name: Setup Python local.properties\n        #if: ${{ matrix.userName == 'q215613905' && env.commit }}\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: echo \"\" > local.properties \n          \n      - name: Release Apk Sign\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          signingConfigs='ICAgIHNpZ25pbmdDb25maWdzIHtcCiAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICBteUNvbmZpZyB7XAogICAgICAgICAgICAgICAgc3RvcmVGaWxlIGZpbGUoUkVMRUFTRV9TVE9SRV9GSUxFKVwKICAgICAgICAgICAgICAgIHN0b3JlUGFzc3dvcmQgUkVMRUFTRV9TVE9SRV9QQVNTV09SRFwKICAgICAgICAgICAgICAgIGtleUFsaWFzIFJFTEVBU0VfS0VZX0FMSUFTXAogICAgICAgICAgICAgICAga2V5UGFzc3dvcmQgUkVMRUFTRV9LRVlfUEFTU1dPUkRcCiAgICAgICAgICAgICAgICB2MVNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICB2MlNpZ25pbmdFbmFibGVkIHRydWVcCiAgICAgICAgICAgICAgICBlbmFibGVWM1NpZ25pbmcgPSB0cnVlXAogICAgICAgICAgICAgICAgZW5hYmxlVjRTaWduaW5nID0gdHJ1ZVwKICAgICAgICAgICAgfVwKICAgICAgICB9XAogICAgfVwKXA=='\n          signingConfig='ICAgICAgICAgICAgaWYgKHByb2plY3QuaGFzUHJvcGVydHkoIlJFTEVBU0VfU1RPUkVfRklMRSIpKSB7XAogICAgICAgICAgICAgICAgc2lnbmluZ0NvbmZpZyBzaWduaW5nQ29uZmlncy5teUNvbmZpZ1wKICAgICAgICAgICAgfVwK'\n          signingConfigs=\"$(echo \"$signingConfigs\" |base64 -d )\"\n          signingConfig=\"$(echo \"$signingConfig\" |base64 -d )\"\n          sed -i -e \"/defaultConfig {/i\\\\$signingConfigs \" -e \"/debug {/a\\\\$signingConfig \" -e \"/release {/a\\\\$signingConfig \" app/build.gradle\n          cp -f ${{ github.workspace }}/.github/workflows/TVBoxOSC.jks app/TVBoxOSC.jks\n          sed -i '$a\\RELEASE_STORE_FILE=./TVBoxOSC.jks'     ./gradle.properties\n          sed -i '$a\\RELEASE_KEY_ALIAS=TVBoxOSC'            ./gradle.properties\n          sed -i '$a\\RELEASE_STORE_PASSWORD=TVBoxOSC'       ./gradle.properties\n          sed -i '$a\\RELEASE_KEY_PASSWORD=TVBoxOSC'         ./gradle.properties\n      - uses: actions/setup-java@v5\n        if: ${{ matrix.java_ver }}\n        with:\n          distribution: temurin\n          java-version: ${{ matrix.java_ver }}\n      - uses: gradle/actions/setup-gradle@v5\n        if: ${{ env.commit }}\n      - name: Build With Gradle\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          chmod +x gradlew\n          ./gradlew assemblerelease --build-cache --parallel --daemon --warning-mode all\n      - name: Prepare App\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          rm -rf apk/\n          mkdir -p apk/\n          for file in `find ~ -name \"*release*.apk\" -print`; do\n            # 获取文件的基本名称\n            base=$(basename \"$file\")\n            # 如果文件是 TVBox_ 开头\n            if [[ \"$base\" == TVBox_* ]]; then\n              new_base=$(echo \"$base\" | sed \"s/release/${{ matrix.userName }}_${{ env.tag }}/\")\n            else\n              new_base=\"TVBox_${{ matrix.userName }}_${{ env.tag }}.apk\"\n            fi\n            # 移动并重命名文件\n            mv \"$file\" \"apk/$new_base\"\n          done\n          mv sourceCode-${{ env.commitS }}.* apk/\n      - name: Release Note\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        run: |\n          lastCommit=$(grep \"${{ matrix.userName }}\\/${{ matrix.repoName }}\" ${{ github.workspace }}/README.md |grep -o '[a-z0-9]\\{40\\}')\n          export LESSCHARSET=utf-8\n          echo -e \"Credit: [${{ matrix.userName }}](${{ env.upStream }})\\nCommit: ${{ env.commit }}\\nChangelog:\\n\\`\\`\\`\" > apk/${{ matrix.userName }}-Release.log\n          if [ \"${{ env.commit }}\" == \"${lastCommit}\" ]; then\n            git log --pretty=format:%B ${{ env.commitS }} -1 |sed -e \"s# \\{2,\\}#\\n#g\" -e \"/^Merge \\(pull\\|branch\\|remote\\)/d\" -e '/^$/d' |cat -n |sort -k2,2 -k1,1n |uniq -f1 |sort -k1,1n |cut -f2- >> apk/${{ matrix.userName }}-Release.log\n          else\n            git log --pretty=format:%B ${{ env.commitS }}...${lastCommit:0:7} |sed -e \"s# \\{2,\\}#\\n#g\" -e \"/^Merge \\(pull\\|branch\\|remote\\)/d\" -e '/^$/d' |cat -n |sort -k2,2 -k1,1n |uniq -f1 |sort -k1,1n |cut -f2- >> apk/${{ matrix.userName }}-Release.log\n          fi\n          echo -e '\\n```' >> apk/${{ matrix.userName }}-Release.log\n      - name: Upload App To Artifact\n        uses: actions/upload-artifact@v7\n        if: ${{ env.commit }}\n        with:\n          name: ${{ matrix.userName }}-${{ matrix.repoName }}\n          path: |\n            TVBoxOSC/apk/*\n      - name: Whether Or Not to Publish\n        if: ${{ inputs.donotpublish && env.commit }}\n        run: |\n          echo \"commit=\" >> $GITHUB_ENV\n      - name: Release and Upload Assets\n        uses: ncipollo/release-action@v1\n        if: ${{ env.commit }}\n        with:\n          name: ${{ env.tag }}\n          tag: ${{ env.tag }}\n          bodyFile: TVBoxOSC/apk/${{ matrix.userName }}-Release.log\n          allowUpdates: true\n          removeArtifacts: true\n          artifacts: |\n            TVBoxOSC/apk/*.apk\n            TVBoxOSC/apk/sourceCode-${{ env.commitS }}.*\n      - name: Download Telegram Bot API Binary\n        if: ${{ env.commit }}\n        uses: actions/download-artifact@v8\n        with:\n          name: telegram-bot-api-binary\n          path: TVBoxOSC\n      - name: Post To Telegram\n        if: ${{ env.commit }}\n        working-directory: TVBoxOSC\n        env:\n          CHAT_ID: -1001734684817\n          TELEGRAM_TOKEN: ${{ secrets.BOT_TOKEN }}\n        run: |\n          if [ -n \"${{ secrets.BOT_TOKEN }}\" ]; then\n            sed -i -e '1s/\\[\\(.*\\)\\].*/#\\1/' -e 's#\\([&\"\\/]\\)#\\\\\\1#g' apk/${{ matrix.userName }}-Release.log\n            mv -f apk/${{ matrix.userName }}-Release.log caption.txt\n            chmod +x telegram-bot-api-binary\n            ./telegram-bot-api-binary --api-id=21724 --api-hash=3e0cb5efcd52300aec5994fdfc5bdc16 --local 2>&1 > /dev/null &\n            mv ../.github/scripts/upload.py ./\n            python upload.py\n          fi\n      - name: Push to master\n        if: ${{ env.commit }}\n        run: |\n          rm -rf TVBoxOSC\n          git reset --hard\n          sed -i '/url =/d' ./.git/config\n          git config --local user.name \"github-actions[bot]\"\n          git config --local user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\n          git remote set-url --add origin \"https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}\"\n          git pull --rebase\n          sed -i \"/${{ matrix.userName }}\\/${{ matrix.repoName }}/s#Updated: [a-zA-Z0-9]*#Updated: ${{ env.commit }}#\" README.md\n          git add --all\n          git commit -m \"${{ env.commit }}\"\n          git push -u -f origin master\n\n  telegram-bot-api:\n    name: Telegram Bot API\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v6\n\n      - name: Clone Telegram Bot API\n        run: |\n          git clone --recursive https://github.com/tdlib/telegram-bot-api.git\n          git status telegram-bot-api >> telegram-bot-api-status\n\n      - name: Cache Bot API Binary\n        id: cache-bot-api\n        uses: actions/cache@v5\n        with:\n          path: telegram-bot-api-binary\n          key: CI-telegram-bot-api-${{ hashFiles('telegram-bot-api-status') }}\n\n      - name: Compile Telegram Bot API\n        if: steps.cache-bot-api.outputs.cache-hit != 'true'\n        run: |\n          sudo apt-get update\n          sudo apt-get install make git zlib1g-dev libssl-dev gperf cmake g++\n          cd telegram-bot-api\n          rm -rf build\n          mkdir build\n          cd build\n          cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..\n          cmake --build . --target install -j$(nproc)\n          cd ../..\n          ls -l telegram-bot-api/bin/telegram-bot-api*\n          cp telegram-bot-api/bin/telegram-bot-api telegram-bot-api-binary\n\n      - name: Upload Binary\n        uses: actions/upload-artifact@master\n        with:\n          name: telegram-bot-api-binary\n          path: telegram-bot-api-binary\n\n  clean:\n    needs: build\n    runs-on: ubuntu-latest\n    steps:\n      - name: Delete older workflow runs and artifacts\n        uses: Mattraks/delete-workflow-runs@main\n        with:\n          token: ${{ github.token }}\n          repository: ${{ github.repository }}\n          retain_days: 14\n          keep_minimum_runs: 10\n"
  },
  {
    "path": "README.md",
    "content": "# TVBoxOSC\n\n![Build](https://shields.io/github/actions/workflow/status/o0HalfLife0o/TVBoxOSC/test.yml?branch=master&logo=github&label=Build)\n[![Channel](https://img.shields.io/badge/Follow-Telegram-blue.svg?logo=telegram)](https://t.me/TVBoxOSC)\n[![Download](https://img.shields.io/github/v/release/o0HalfLife0o/TVBoxOSC?color=orange&logoColor=orange&label=Download&logo=DocuSign)](https://github.com/o0HalfLife0o/TVBoxOSC/releases/latest) \n[![Total](https://shields.io/github/downloads/o0HalfLife0o/TVBoxOSC/total?logo=Bookmeter&label=Counts&logoColor=yellow&color=yellow)](https://github.com/o0HalfLife0o/TVBoxOSC/releases)\n\n## Credits\nThis repo relies on the following third-party projects:\n- [CatVodTVOfficial/TVBoxOSC](https://github.com/CatVodTVOfficial/TVBoxOSC)\n- [q215613905/TVBoxOS](https://github.com/q215613905/TVBoxOS) (Updated: 704cd2658fbcaf38551228cb90bd9f766a0c9e72)\n- [takagen99/Box](https://github.com/takagen99/Box) (Updated: 258a5fef61578869ae905ca230bdde9e99fc19a8)\n"
  }
]