From ecd80dffdac32577a6e22d47bc05a3ef63b22167 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal <59223300+nikhilbadyal@users.noreply.github.com> Date: Wed, 23 Aug 2023 20:51:50 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Ability=20to=20provide=20app=20dl?= =?UTF-8?q?=20(#303)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 19 +++++++++++++++---- src/app.py | 24 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6784149..d2e52dc 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ You can use any of the following methods to build. | [*APP_NAME*_EXCLUDE_PATCH**](#custom-exclude-patching) | Patches to exclude while patching **APP_NAME**. | [] | | [*APP_NAME*_INCLUDE_PATCH**](#custom-include-patching) | Patches to include while patching **APP_NAME**. | [] | | [*APP_NAME*_VERSION**](#app-version) | Version to use for download for patching. | Recommended by patch resources | +| [*APP_NAME*_DL](#app-dl) | | | `**` - By default all patches for a given app are included.
`**` - Can be used to included universal patch. @@ -331,7 +332,17 @@ You can use any of the following methods to build. YOUTUBE_MUSIC_VERSION=X.X.X TWITTER_VERSION=latest ``` -14. For Telegram Upload. +14. If you have your personal source for apk to be downloaded. You can also provide that and tool + will not scarp links from apk sources.Add `dl` in `.env` file or in `ENVS` in `GitHub secrets` (Recommended) in + the format + ```ini + _DL= + ``` + Example: + ```ini + YOUTUBE_DL=https://d.apkpure.com/b/APK/com.google.android.youtube?version=latest + ``` +15. For Telegram Upload. 1. Set up a telegram channel, send a message to it and forward the message to this telegram [bot](https://t.me/username_to_id_bot) 2. Copy `id` and save it to `TELEGRAM_CHAT_ID`
@@ -345,12 +356,12 @@ You can use any of the following methods to build.
6. After Everything done successfully a part of the actions secrets of the repository may look like
-15. Configuration defined in `ENVS` in `GitHub secrets` will override the configuration in `.env` file. You can use this +16. Configuration defined in `ENVS` in `GitHub secrets` will override the configuration in `.env` file. You can use this fact to define your normal configurations in `.env` file and sometimes if you want to build something different just once. Add it in `GitHub secrets`.
-16. Sample Envs
+17. Sample Envs
-17. Make sure your Action has write access. If not click +18. Make sure your Action has write access. If not click [here](https://github.com/nikhilbadyal/docker-py-revanced/settings/actions). In the bottom give read and write access to Actions. diff --git a/src/app.py b/src/app.py index cfff565..c8a4a54 100644 --- a/src/app.py +++ b/src/app.py @@ -8,6 +8,7 @@ from typing import Dict, List from loguru import logger from src.config import RevancedConfig +from src.downloader.download import Downloader from src.exceptions import PatchingFailed from src.utils import slugify @@ -44,20 +45,27 @@ class APP(object): f"{app_name}_ARCHS_TO_BUILD".upper(), config.global_archs_to_build ) self.download_file_name = "" - self.download_dl = "" + self.download_dl = config.env.str(f"{app_name}_DL".upper(), "") self.download_patch_resources(config) def download_apk_for_patching(self, config: RevancedConfig) -> None: """Download apk to be patched.""" from src.downloader.factory import DownloaderFactory - logger.info("Downloading apk to be patched") - downloader = DownloaderFactory.create_downloader( - app=self.app_name, config=config - ) - self.download_file_name, self.download_dl = downloader.download( - self.app_version, self.app_name - ) + if self.download_dl: + logger.info("Downloading apk to be patched using provided dl") + self.download_file_name = f"{self.app_name}.apk" + Downloader(config).direct_download( + self.download_dl, self.download_file_name + ) + else: + logger.info("Downloading apk to be patched by scrapping") + downloader = DownloaderFactory.create_downloader( + app=self.app_name, config=config + ) + self.download_file_name, self.download_dl = downloader.download( + self.app_version, self.app_name + ) def get_output_file_name(self) -> str: """The function returns a string representing the output file name for