📝 Consistent env convention

This commit is contained in:
Nikhil Badyal
2023-08-06 12:00:38 +05:30
parent 2897a8f6c3
commit 2197c30f33
3 changed files with 151 additions and 136 deletions
+146 -127
View File
@@ -1,15 +1,11 @@
# 🤓Docker-Py-ReVanced
A little python script that will help you in building Revanced and Revanced-Extended [apps](#note).
A little python script that will help you in building Revanced [apps](#note).
**`Note`** - If you are a root user and want magisk module (Extended). Get them [here](https://github.com/nikhilbadyal/revanced-magisk-module)
This is just a builder for revanced and not a revanced support. Please be understanding and refrain from asking
about revanced features/bugs. Discuss those on proper relevant forums(on Revanced GitHub , Discord)
**`Note`** - I prefer [Revanced Extended](https://github.com/inotia00/revanced-patches/tree/revanced-extended) more
(for YouTube & YouTube Music) hence the YouTube and YouTube Music builds in this repo are from
Revanced Extended.
about revanced features/bugs. Discuss those on proper relevant forums.
## Pre-Built APKs
@@ -19,7 +15,7 @@ You can get pre-built apks [here](https://revanced_apkss.t.me/)
You can use any of the following methods to build.
- 🚀In GitHub (**_`Recommended`_**)
- 🚀 **_GitHub**_ (**_`Recommended`_**)
1. Click Star to support the project.<br>
<img src="https://i.imgur.com/FFyXaWY.png" width="400" style="left"><br>
@@ -51,7 +47,7 @@ You can use any of the following methods to build.
5. If the building process is successful, youll get your APKs in the<br>
<img src="https://i.imgur.com/S5d7qAO.png" width="700" style="left">
- 🐳With Docker Compose
- 🐳 **_Docker Compose_**<br>
Windows/Mac users simply install Docker Desktop. If using Linux see below
1. Install Docker(Skip if already installed)
@@ -80,7 +76,7 @@ You can use any of the following methods to build.
6. Update `.env` file if you want some customization(See notes)
7. Run script with
```shell
docker-compose up
docker-compose up --build
```
- 🐳With Docker
@@ -99,7 +95,7 @@ You can use any of the following methods to build.
- 🫠Without Docker
1. Install Java17 (zulu preferred)
1. Install Java >= 17
2. Install Python
3. Create virtual environment
```
@@ -115,15 +111,51 @@ You can use any of the following methods to build.
```
6. Run the script with
```
python python main.py
python main.py
```
## Configurations
### Global Config
| Env Name | Description | Default |
|:---------------------------|:-------------------------------------------------:|:---------------------------------------------------------------------------------------------------------|
| PATCH_APPS | Apps to patch/build | youtube |
| EXISTING_DOWNLOADED_APKS | Already downloaded clean apks | [] |
| PERSONAL_ACCESS_TOKEN | Github Token to be used | None |
| DRY_RUN | Do a dry run | False |
| GLOBAL_CLI_DL* | DL for CLI to be used for patching apps. | [Revanced CLI](https://github.com/revanced/revanced-cli) |
| GLOBAL_PATCHES_DL* | DL for Patches to be used for patching apps. | [Revanced Patches](https://github.com/revanced/revanced-patches) |
| GLOBAL_INTEGRATIONS_DL* | DL for Integrations to be used for patching apps. | [Revanced CLI](https://github.com/revanced/revanced-integrations) |
| GLOBAL_KEYSTORE_FILE_NAME* | Key file to be used for signing apps | [Builder's own key](https://github.com/nikhilbadyal/docker-py-revanced/blob/main/apks/revanced.keystore) |
| GLOBAL_ARCHS_TO_BUILD* | Arch to keep in the patched apk. | All |
| REDDIT_CLIENT_ID | Reddit Client ID to patch reddit apps | None |
| VT_API_KEY | Virus Total Key to scan APKs | None |
| TELEGRAM_CHAT_ID | Receiver in Telegram upload | None |
| TELEGRAM_BOT_TOKEN | APKs Sender for Telegram upload | None |
| TELEGRAM_API_ID | Used for telegram Authentication | None |
| TELEGRAM_API_HASH | Used for telegram Authentication | None |
`*` - Can be overridden for individual app.
### App Level Config
| Env Name | Description | Default |
|:------------------------------|:---------------------------------------------------------:|:-------------------------------|
| *APP_NAME*_CLI_DL | DL for CLI to be used for patching **APP_NAME**. | GLOBAL_CLI_DL |
| *APP_NAME*_PATCHES_DL | DL for Patches to be used for patching **APP_NAME**. | GLOBAL_PATCHES_DL |
| *APP_NAME*_INTEGRATIONS_DL | DL for Integrations to be used for patching **APP_NAME**. | GLOBAL_INTEGRATIONS_DL |
| *APP_NAME*_KEYSTORE_FILE_NAME | Key file to be used for signing **APP_NAME**. | GLOBAL_KEYSTORE_FILE_NAME |
| *APP_NAME*_ARCHS_TO_BUILD | Arch to keep in the patched **APP_NAME**. | GLOBAL_ARCHS_TO_BUILD |
| *APP_NAME*_EXCLUDE_PATCH** | Patches to exclude while patching **APP_NAME**. | [] |
| *APP_NAME*_INCLUDE_PATCH** | Patches to include while patching **APP_NAME**. | [] |
| *APP_NAME*_VERSION** | Version to use for download for patching. | Recommended by patch resources |
`**` - By default all patches for a given app are included.<br>
`**` - Can be used to included universal patch.
## Note
(Pay attention to 3,4)<br>
By default, script build the version as recommended by Revanced team.
1. Supported values for **REVANCED_APPS_NAME** are :
1. Supported values for **APP_NAME** are :
1. [youtube](https://www.apkmirror.com/apk/google-inc/youtube/)
2. [youtube_music](https://www.apkmirror.com/apk/google-inc/youtube-music/)
@@ -165,106 +197,123 @@ By default, script build the version as recommended by Revanced team.
38. [bacon](https://www.apkmirror.com/apk/onelouder-apps/baconreader-for-reddit/)
39. [microg](https://github.com/inotia00/mMicroG/releases)
<br>Please verify the source of original APKs yourself with links provided. I'm not responsible for any damaged caused.
If you know any better/safe source to download clean. Please raise a PR.
2. Remember to download the **_Microg_**. Otherwise, you will not be able to open YouTube.
3. By default, it will build only `youtube`. To build other apps supported by revanced team.
Add the apps you want to build in `.env` file or in `ENVS` in
`GitHub secrets` in the format
<br>Please verify the source of original APKs yourself with links provided. I'm not responsible for any damage
caused.If you know any better/safe source to download clean. Open a discussion.
2. By default, script build the latest version as recommended by `patches.json` team.
3. Remember to download the **_Microg_**. Otherwise, you may not be able to open YouTube/YouTube Music.
4. By default, tool will build only `youtube`. To build other apps supported by patching resources.
Add the apps you want to build in `.env` file or in `ENVS` in `GitHub secrets` in the format
```ini
PATCH_APPS=<REVANCED_APPS_NAME>
PATCH_APPS=<APP_NAME>
```
Example:
```ini
PATCH_APPS=youtube,twitter,reddit
```
4. If you want to exclude any patch. Set comma separated patch in `.env` file or in `ENVS` in `GitHub secrets`
(Recommended) in the format
```ini
EXCLUDE_PATCH_<REVANCED_APPS_NAME>=<PATCH_TO_EXCLUDE-1,PATCH_TO_EXCLUDE-2>
5. If APKMirror or other apk sources are 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=<Comma,Seperate,App,Name>
```
Example:
```dotenv
EXCLUDE_PATCH_YOUTUBE=custom-branding,hide-get-premium
EXCLUDE_PATCH_YOUTUBE_MUSIC=yt-music-is-shit
EXISTING_DOWNLOADED_APKS=youtube,youtube_music
```
**_All the patches for an app are included by default._**.<br><br>If you want to apply a universal patch. You can
include it
manually. See below for more information.<br>
5. If you want to include any universal patch. Set comma separated patch in `.env` file or in `ENVS` in `GitHub
If you add above. Script will not download the `youtube` & `youtube_music`apk from internet and expects an apk in
`/apks` folder with **same** name.
6. If you run script again & again. You might hit GitHub API limit. In that case you can provide your Personal
GitHub Access Token in `.env` file or in `ENVS` in `GitHub secrets` (Recommended) in the format -
```dotenv
PERSONAL_ACCESS_TOKEN=<PAT>
```
7. You can provide Direct download to the resource to used for patching apps `.env` file or in `ENVS` in `GitHub
secrets`
(Recommended) in the format
```ini
INCLUDE_PATCH_<REVANCED_APPS_NAME>=<PATCH_TO_EXCLUDE-1,PATCH_TO_EXCLUDE-2>
(Recommended) in the format -
```dotenv
GLOBAL_CLI_DL=https://github.com/revanced/revanced-cli
GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches
GLOBAL_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations
```
Resources downloaded from envs and will be used for patching for any **APP_NAME**.
Unless provided different resource for the individual app.<br><br>
Tool also support resource config at app level. You can patch A app with X resources while patching B with Y
resources.
This can be done by providing Direct download link for resources for app.<br>
Example:
```dotenv
INCLUDE_PATCH_YOUTUBE=remove-screenshot-restriction
YOUTUBE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_PATCHES_DL=https://github.com/inotia00/revanced-patches
YOUTUBE_INTEGRATIONS_DL=https://github.com/inotia00/revanced-integrations
```
If you are using `Revanced Extended.` Add `_EXTENDED` in exclude options.
Example:
```dotenv
INCLUDE_PATCH_YOUTUBE_EXTENDED=remove-screenshot-restriction
```
**_Remember_** - Revanced patches are provided space separated, make sure you type those **-** separated here.
It means a patch named _**Hey There**_ will be entered as **_hey-there_** in the above example.
6. If you want to use custom Patching resource. You can do so by providing respective DLs. Per app support is there too.
```ini
YOUTUBE_MUSIC_INTEGRATION_DL=https://github.com/inotia00/revanced-integrations/releases/latest
YOUTUBE_MUSIC_PATCHES_DL=https://github.com/inotia00/revanced-patches/releases/latest
YOUTUBE_MUSIC_CLI_DL=https://github.com/inotia00/revanced-cli/releases/latest
YOUTUBE_MUSIC_KEYSTORE_FILE_NAME=key.store
YOUTUBE_MUSIC_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a
```
These link if not from GitHub must be direct download links.
7. You can also provide a default resources which will be used when per app config is missing.
```ini
GLOBAL_INTEGRATION_DL=https://github.com/inotia00/revanced-integrations/releases/latest
GLOBAL_PATCHES_DL=https://github.com/inotia00/revanced-patches/releases/latest
GLOBAL_CLI_DL=https://github.com/inotia00/revanced-cli/releases/latest
```
These link if not from GitHub must be direct download links.
8. If you want to build a specific version . Add `version` in `.env` file or in `ENVS` in `GitHub secrets` (Recommended)
in the format
```ini
<APPNAME>_VERSION=<VERSION>
```
Example:
```ini
YOUTUBE_VERSION=17.31.36
YOUTUBE_MUSIC_VERSION=X.X.X
TWITTER_VERSION=X.X.X
REDDIT_VERSION=X.X.X
TIKTOK_VERSION=X.X.X
WARNWETTER_VERSION=X.X.X
```
9. If you want to build `latest` version, whatever latest is available(including
beta) .
Add `latest` in `.env` file or in `ENVS` in `GitHub secrets` (Recommended) in the format
```ini
<APPNAME>_VERSION=latest
```
Example:
```ini
YOUTUBE_VERSION=latest
YOUTUBE_MUSIC_VERSION=latest
TWITTER_VERSION=latest
REDDIT_VERSION=latest
TIKTOK_VERSION=latest
WARNWETTER_VERSION=latest
```
10. If you don't want to use default keystore. You can provide your own by placing it
With the config tool will try to patch youtube with resources from inotia00 while other global resource will used
for patching other apps.
*Note* - The link provided must be DLs. Unless they are from GitHub.
8. If you don't want to use default keystore. You can provide your own by placing it
inside `apks` folder. And adding the name of `keystore-file` in `.env` file or in `ENVS` in `GitHub secrets`
(Recommended) in the format
```dotenv
GLOBAL_KEYSTORE_FILE_NAME=revanced.keystore
```
11. For Telegram Upload.
Tool also support providing secret key at app level. You can sign A app with X key while signing B with Y
key.<br>
Example:
```dotenv
YOUTUBE_KEYSTORE_FILE_NAME=youtube.keystore
```
9. You can build only for a particular arch in order to get smaller apk files.This can be done with by adding comma
separated `ARCHS_TO_BUILD` in `ENVS` in `GitHub secrets` (Recommended) in the format.
```dotenv
GLOABAL_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a
```
Tool also support configuring at app level.<br>
Example:
```dotenv
YOUTUBE_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a
```
*Note* -
1. Possible values are: `armeabi-v7a`,`x86`,`x86_64`,`arm64-v8a`
2. Make sure the patching resource(CLI) support this feature.
10. If you want to exclude any patch. Set comma separated patch in `.env` file or in `ENVS` in `GitHub secrets`
(Recommended) in the format
```ini
<APP_NAME>_EXCLUDE_PATCH=<PATCH_TO_EXCLUDE-1,PATCH_TO_EXCLUDE-2>
```
Example:
```dotenv
YOUTUBE_EXCLUDE_PATCH=custom-branding,hide-get-premium
YOUTUBE_MUSIC_EXCLUDE_PATCH=yt-music-is-shit
```
Note -
1. **All** the patches for an app are **included** by default.<br>
2. Revanced patches are provided as space separated, make sure you type those **-** separated here.
It means a patch named _**Hey There**_ must be entered as **_hey-there_** in the above example.
11. If you want to include any universal patch. Set comma separated patch in `.env` file or in `ENVS` in `GitHub
secrets`
(Recommended) in the format
```ini
<APP_NAME>_INCLUDE_PATCH=<PATCH_TO_EXCLUDE-1,PATCH_TO_EXCLUDE-2>
```
Example:
```dotenv
YOUTUBE_INCLUDE_PATCH=remove-screenshot-restriction
```
Note -
1. Revanced patches are provided as space separated, make sure you type those **-** separated here.
It means a patch named _**Hey There**_ must be entered as **_hey-there_** in the above example.
12. If you want to build a specific version or latest version. Add `version` in `.env` file or in `ENVS` in `GitHub
secrets` (Recommended) in the format
```ini
<APP_NAME>_VERSION=<VERSION>
```
Example:
```ini
YOUTUBE_VERSION=17.31.36
YOUTUBE_MUSIC_VERSION=X.X.X
TWITTER_VERSION=latest
```
13. 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`<br>
@@ -278,42 +327,12 @@ By default, script build the version as recommended by Revanced team.
<img src="https://i.imgur.com/7n5k1mp.png" width="300" style="left"><br>
6. After Everything done successfully the actions secrets of the repository will look something like<br>
<img src="https://i.imgur.com/dzC1KFa.png" width="400">
12. You can build only for a particular arch in order to get smaller apk files.This can be done with by adding comma
separated `ARCHS_TO_BUILD` in `ENVS` in `GitHub secrets` (Recommended) in the format.
```dotenv
GLOABAL_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a
```
Possible values for `ARCHS_TO_BUILD` are: `armeabi-v7a`,`x86`,`x86_64`,`arm64-v8a`
Make sure the patching resource support this.
13. You can scan your built apks files with VirusTotal. For that, Add `VT_API_KEY` in `GitHub secrets`.
14. 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`.<br>
Or you can ignore what I said above and always use `GitHub secrets`.
15. 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=<Comma,Seperate,App,Name>
```
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)
16. If you run script again & again. You might hit GitHub API limit. In that case you can provide your Personal
GitHub Access Token in `.env` file or in `ENVS` in `GitHub secrets` (Recommended) in the format -
```dotenv
PERSONAL_ACCESS_TOKEN=<PAT>
```
17. Sample Envs<br>
15. Sample Envs<br>
<img src="https://i.imgur.com/ajSE5nA.png" width="600" style="left">
18. Make your Action has write access. If not click
16. Make 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.
<img src="https://i.imgur.com/STSv2D3.png" width="400">
19. If you want to patch reddit apps using your own Client ID. You can provide your Client ID
as secret `REDDIT_CLIENT_ID` in `GitHub secrets`.
+2 -2
View File
@@ -25,8 +25,8 @@ class APP(object):
self.integrations_dl = config.env.str(
f"{app_name}_INTEGRATION_DL".upper(), config.global_integrations_dl
)
self.exclude_request = config.env.list(f"EXCLUDE_PATCH_{app_name}".upper(), [])
self.include_request = config.env.list(f"INCLUDE_PATCH_{app_name}".upper(), [])
self.exclude_request = config.env.list(f"{app_name}_EXCLUDE_PATCH".upper(), [])
self.include_request = config.env.list(f"{app_name}_INCLUDE_PATCH".upper(), [])
self.resource: Dict[str, str] = {}
self.no_of_patches = 0
self.keystore_name = config.env.str(
-4
View File
@@ -72,10 +72,6 @@ class RevancedConfig(object):
key: value + value.split("/")[-2]
for key, value in self.apk_mirror_urls.items()
}
self.alternative_youtube_patches = env.list("ALTERNATIVE_YOUTUBE_PATCHES", [])
self.alternative_youtube_music_patches = env.list(
"ALTERNATIVE_YOUTUBE_MUSIC_PATCHES", []
)
self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", [])
self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None)
self.dry_run = env.bool("DRY_RUN", False)