From d098835b219c20df852876425c0670b56add1d98 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Wed, 21 Dec 2022 09:47:29 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Ability=20to=20provide=20apk=20manu?= =?UTF-8?q?ally.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 16 +++++++++++++++- src/config.py | 1 + src/downloader.py | 6 +++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index efe50b7..8e05221 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,21 @@ By default, script build the version as recommended by Revanced team. 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`.
Or you can ignore what I said above and always use `GitHub secrets`. -13. Sample Envs
+13. If APKMirror or other apk source is blocked in your region or script somehow is unable to download from apkmirror. + You can download apk manually from any source. Place them in `/apks` directory and provide environment variable + in `.env` file or in `ENVS` in `GitHub secrets`(Recommended) in the format. + ```dotenv + EXISTING_DOWNLOADED_APKS= + ``` + Example: + ```dotenv + EXISTING_DOWNLOADED_APKS=youtube,youtube_music + ``` + If you add above. Script will not download the `Youtube` & `youtube music`apk from internet and expects an apk in + `/apks` folder. + + Name of the downloaded apk must match with the available app choices found [here.](#note) +14. Sample Envs
Thanks to [@aliharslan0](https://github.com/aliharslan0/pyrevanced) for his work. diff --git a/src/config.py b/src/config.py index ab80c33..7b4e0d8 100644 --- a/src/config.py +++ b/src/config.py @@ -80,3 +80,4 @@ class RevancedConfig: self.alternative_youtube_music_patches = env.list( "ALTERNATIVE_YOUTUBE_MUSIC_PATCHES", [] ) + self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", []) diff --git a/src/downloader.py b/src/downloader.py index 3c3a1b8..939f871 100644 --- a/src/downloader.py +++ b/src/downloader.py @@ -263,8 +263,12 @@ class Downloader(object): :param version: version to download :param app: App to download - :return: Version of apk + :return: Version of apk. """ + if app in self.config.existing_downloaded_apks: + logger.debug("Will not download apk from the internet as it already exist.") + # Returning Latest as I don't know, which version user provided. + return "latest" if app in self.config.upto_down: return self.upto_down_downloader(app) elif app in self.config.apk_pure: