diff --git a/.github/runOnRelease.py b/.github/runOnRelease.py index a537b71b3..3b1554d71 100644 --- a/.github/runOnRelease.py +++ b/.github/runOnRelease.py @@ -1,21 +1,15 @@ from pyrogram import Client -from pyrogram.types import ( - InlineKeyboardButton, - InlineKeyboardMarkup, - InputMediaDocument, -) +from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, InputMediaDocument from requests import get from tgconfig import TG_API_HASH, TG_API_ID, TG_TOKEN -url = "https://api.github.com/repos/Libre-Tube/LibreTube/releases/latest" -req = get(url).json() +req = get("https://api.github.com/repos/Libre-Tube/LibreTube/releases/latest").json() TG_CHANNEL = "LibreTube" def get_changelog(): - url = "https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs" - data = get(url).json() + data = get("https://api.github.com/repos/libre-tube/LibreTube/contents/fastlane/metadata/android/en-US/changelogs").json() last_log = max([int(file["name"].replace(".txt", "")) for file in data]) log = get( f"https://github.com/libre-tube/LibreTube/raw/master/fastlane/metadata/android/en-US/changelogs/{last_log}.txt" @@ -23,12 +17,6 @@ def get_changelog(): return log -def download(url, name): - with open(name, "wb") as f: - f.write(get(url, stream=True).content) - return name - - buttons = InlineKeyboardMarkup( [ [ @@ -45,13 +33,23 @@ buttons = InlineKeyboardMarkup( ) -_files, files, result, tag = req.get("assets"), [], req.get("body"), req.get("tag_name") -for file in _files: +assets, files = req.get("assets"), list() + +for file in assets: + with open(name, "wb") as f: + f.write(get(file.get("browser_download_url"), stream=True).content) + files.append( - InputMediaDocument(download(file.get("browser_download_url"), file.get("name"))) + InputMediaDocument( + download( + file.get("name") + ) + ) ) + caption = f"**LibreTube {tag} // Privacy Simplified**\n\nWhat's Changed?\n```{get_changelog()}```" + with Client("bot", TG_API_ID, TG_API_HASH, bot_token=TG_TOKEN) as app: app.send_photo( TG_CHANNEL, diff --git a/.github/uploader.py b/.github/uploader.py index cf9f0ab10..ecd963297 100644 --- a/.github/uploader.py +++ b/.github/uploader.py @@ -1,6 +1,6 @@ from os import system as run, listdir, remove from json import load -import tgconfig +import config_fie import hashlib with open("../.github/commit.json") as f: @@ -28,7 +28,7 @@ with open("checksums", "w") as checksums: if tgconfig.GH_REPO.lower() == "libre-tube/libretube": run("git add -f *") - run(f"git commit -m \"{message}\"") + run(f'git commit -m "{message}"') run("git push -u") else: print("Official Repo not Detected") diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 909f2fd17..559022a43 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - - name: Check for Execution Orders + - name: Retrieve Commit Info run: | cd .github curl https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }} > commit.json @@ -65,7 +65,7 @@ jobs: continue-on-error: true run: | mv .github/uploader.py . - echo "GH_REPO = '${{ github.repository }}'" > tgconfig.py + echo "GH_REPO = '${{ github.repository }}'" > config_file.py git clone --filter=blob:none https://github.com/libre-tube/NightlyBuilds nightly rm -rf nightly/*.apk mv app/build/outputs/apk/debug/*.apk nightly/ diff --git a/.github/workflows/run-on-release.yml b/.github/workflows/run-on-release.yml index 9d6664f30..2bc0bf7bc 100644 --- a/.github/workflows/run-on-release.yml +++ b/.github/workflows/run-on-release.yml @@ -13,13 +13,11 @@ jobs: python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified - - name: Upload to Telegram + - name: Upload to Telegram (@LibreTube) run: | - git clone https://github.com/${{ github.repository }} && cd LibreTube echo "TG_API_ID = '${{ secrets.TG_API_ID }}'" >> tgconfig.py echo "TG_API_HASH = '${{ secrets.TG_API_HASH }}'" >> tgconfig.py echo "TG_TOKEN = '${{ secrets.TG_TOKEN }}'" >> tgconfig.py pip install pyrogram TgCrypto requests mv .github/runOnRelease.py . - python runOnRelease.py - + python runOnRelease.py \ No newline at end of file