Merge pull request #306 from nikhilbadyal/feature/292-build-any-supported-application

This commit is contained in:
Nikhil Badyal
2023-08-24 22:08:15 +05:30
committed by GitHub
5 changed files with 115 additions and 66 deletions
+60 -17
View File
@@ -1,29 +1,72 @@
#GLobal envs #Global:
PATCH_APPS=youtube,youtube_music,twitter EXTRA_FILES=https://github.com/inotia00/VancedMicroG/releases/latest@VancedMicroG.apk,https://github.com/inotia00/mMicroG/releases@mmicrog.apk
PATCH_APPS=youtube,youtube_revancify_red,youtube_revancify_blue,youtube_mmt,youtube_music,reddit
GLOBAL_CLI_DL=https://github.com/revanced/revanced-cli GLOBAL_CLI_DL=https://github.com/revanced/revanced-cli
GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches
GLOBAL_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches GLOBAL_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches
GLOBAL_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations GLOBAL_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations
EXISTING_DOWNLOADED_APKS=youtube,youtube_music
#Example
EXISTING_DOWNLOADED_APKS=twitter
PERSONAL_ACCESS_TOKEN=ghp_asample_token PERSONAL_ACCESS_TOKEN=ghp_asample_token
#YouTune #YouTube:
YOUTUBE_CLI_DL=https://github.com/revanced/revanced-cli YOUTUBE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_PATCHES_DL=https://github.com/revanced/revanced-patches YOUTUBE_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches YOUTUBE_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations YOUTUBE_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#Example
YOUTUBE_KEYSTORE_FILE_NAME=youtube.keystore YOUTUBE_KEYSTORE_FILE_NAME=youtube.keystore
YOUTUBE_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a YOUTUBE_ARCHS_TO_BUILD=arm64-v8a,armeabi-v7a
YOUTUBE_EXCLUDE_PATCH=custom-branding,hide-get-premium
YOUTUBE_INCLUDE_PATCH=remove-screenshot-restriction
YOUTUBE_VERSION=17.31.36
#YOUTUBE_MUSIC Music
YOUTUBE_MUSIC_CLI_DL=https://github.com/revanced/revanced-cli/releases/tag/v2.22.1 #YouTube Revancify Red:
YOUTUBE_MUSIC_PATCHES_DL=https://github.com/revanced/revanced-patches YOUTUBE_REVANCIFY_RED_PACKAGE_NAME=com.google.android.youtube
YOUTUBE_MUSIC_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches YOUTUBE_REVANCIFY_RED_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtube/
YOUTUBE_MUSIC_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations YOUTUBE_REVANCIFY_RED_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_MUSIC_EXCLUDE_PATCH=yt-music-is-shit YOUTUBE_REVANCIFY_RED_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_RED_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_RED_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_REVANCIFY_RED_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#YouTube Revancify Blue:
YOUTUBE_REVANCIFY_BLUE_PACKAGE_NAME=com.google.android.youtube
YOUTUBE_REVANCIFY_BLUE_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtube/
YOUTUBE_REVANCIFY_BLUE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_REVANCIFY_BLUE_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_BLUE_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_BLUE_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_REVANCIFY_BLUE_EXCLUDE_PATCH=custom-branding-icon-revancify-red,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#YouTube MMT:
YOUTUBE_MMT_PACKAGE_NAME=com.google.android.youtube
YOUTUBE_MMT_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtube/
YOUTUBE_MMT_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_MMT_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MMT_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MMT_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_MMT_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-youtube-name,enable-debug-logging
#YouTube Music:
YOUTUBE_MUSIC_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_MUSIC_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MUSIC_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MUSIC_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_MUSIC_EXCLUDE_PATCH=custom-branding-icon-mmt,custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-music-name,enable-compact-dialog,enable-debug-logging
YOUTUBE_MUSIC_VERSION=6.15.52
#Reddit
REDDIT_CLI_DL=https://github.com/inotia00/revanced-cli
REDDIT_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
REDDIT_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
REDDIT_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
#Twitter #Twitter
TWITTER_VERSION=latest TWITTER_VERSION=latest
+33 -25
View File
@@ -15,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. You can use any of the following methods to build.
- 🚀 **_GitHub**_ (**_`Recommended`_**) - 🚀 **GitHub** (**_`Recommended`_**)
1. Click Star to support the project.<br> 1. Click Star to support the project.<br>
<img src="https://i.imgur.com/FFyXaWY.png" width="400" style="left"><br> <img src="https://i.imgur.com/FFyXaWY.png" width="400" style="left"><br>
@@ -48,40 +48,25 @@ You can use any of the following methods to build.
<img src="https://i.imgur.com/S5d7qAO.png" width="700" style="left"> <img src="https://i.imgur.com/S5d7qAO.png" width="700" style="left">
- 🐳 **_Docker Compose_**<br> - 🐳 **_Docker Compose_**<br>
Windows/Mac users simply install Docker Desktop. If using Linux see below
1. Install Docker(Skip if already installed) 1. Install [Docker Desktop](https://www.docker.com/products/docker-desktop/).
```bash 2. Clone the repo
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
```
2. Grant Permissions with(Skip if already there)
```bash
sudo chmod 777 /var/run/docker.sock
```
3. Install Docker compose(Skip if already installed or using **_`Docker Desktop`_**)
```bash
curl -L "https://github.com/docker/compose/releases/download/v2.10.2/docker-compose-$(uname -s)-$(uname -m)" \
-o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
```
4. Clone the repo
```bash ```bash
git clone https://github.com/nikhilbadyal/docker-py-revanced git clone https://github.com/nikhilbadyal/docker-py-revanced
``` ```
5. cd to the cloned repo 3. cd to the cloned repo
```bash ```bash
cd docker-py-revanced cd docker-py-revanced
``` ```
6. Update `.env` file if you want some customization(See notes) 4. Update `.env` file if you want some customization(See notes)
7. Run script with 5. Run script with
```shell ```shell
docker-compose up --build docker-compose up --build
``` ```
- 🐳With Docker - 🐳With Docker
1. Install Docker(Skip if already installed) 1. Install Docker or [Docker Desktop](https://www.docker.com/products/docker-desktop/).
```bash ```bash
curl -fsSL https://get.docker.com -o get-docker.sh curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh sh get-docker.sh
@@ -152,14 +137,16 @@ 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*_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*_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*_VERSION**](#app-version) | Version to use for download for patching. | Recommended by patch resources |
| [*APP_NAME*_DL](#app-dl) | | | | [*APP_NAME*_DL](#app-dl) | Direct download Link for clean apk | None |
| [*APP_NAME*_DL_SOURCE](#any-patch-apps) | Download source of any of the supported scrapper | None |
| [*APP_NAME*_DL_SOURCE](#any-patch-apps) | Package name of the app to be patched | None |
`**` - By default all patches for a given app are included.<br> `**` - By default all patches for a given app are included.<br>
`**` - Can be used to included universal patch. `**` - Can be used to included universal patch.
## Note ## Note
1. Supported values for **APP_NAME** are : 1. <a id="any-patch-apps"></a>**Officially** Supported values for **APP_NAME**** are :
1. [youtube](https://www.apkmirror.com/apk/google-inc/youtube/) 1. [youtube](https://www.apkmirror.com/apk/google-inc/youtube/)
2. [youtube_music](https://www.apkmirror.com/apk/google-inc/youtube-music/) 2. [youtube_music](https://www.apkmirror.com/apk/google-inc/youtube-music/)
@@ -201,10 +188,31 @@ You can use any of the following methods to build.
38. [bacon](https://www.apkmirror.com/apk/onelouder-apps/baconreader-for-reddit/) 38. [bacon](https://www.apkmirror.com/apk/onelouder-apps/baconreader-for-reddit/)
39. [microg](https://github.com/inotia00/mMicroG/releases) 39. [microg](https://github.com/inotia00/mMicroG/releases)
40. [pixiv](https://www.apkmirror.com/apk/pixiv-inc/pixiv/) 40. [pixiv](https://www.apkmirror.com/apk/pixiv-inc/pixiv/)
<br>`**` - You can also patch any other app which is **not** supported officially.To do so, you need to provide
few more inputs to the tool which are mentioned below.
```ini
<APP_NAME>_DL_SOURCE=<apk-link-to-any-of-the-suppored-scrapper>
<APP_NAME>_PACKAGE_NAME=<package-name-of-the-application>
```
You can also provide DL to the clean apk instead of providing DL_SOURCES as mentioned in this [note](#app-dl)
Supported Scrappers are
1. APKMIRROR - Supports downloading any versions
1. Link Format - https://www.apkmirror.com/apk/<organisation-name>/app-name/
2. Example Link - https://www.apkmirror.com/apk/google-inc/youtube/
2. UPTODOWN - Supports downloading any versions
1. Link Format - https://<app-name>.en.uptodown.com/android
2. Example Link - https://spotify.en.uptodown.com/android
3. APKSOS - Supports downloading any versions
1. Link Format - https://apksos.com/download-app/<package-name>
2. Example Link - https://apksos.com/download-app/com.expensemanager
4. APKPURE - Supports downloading only latest version
1. Link Format - https://d.apkpure.com/b/APK/<package-name>?version=latest
2. Example Link - https://d.apkpure.com/b/APK/com.google.android.youtube?version=latest
<br>Please verify the source of original APKs yourself with links provided. I'm not responsible for any damage <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. 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.
2. By default, script build the latest version mentioned in `patches.json` file.
3. Remember to download the **_Microg_**. Otherwise, you may not be able to open YouTube/YouTube Music. 3. Remember to download the **_Microg_**. Otherwise, you may not be able to open YouTube/YouTube Music.
4. <a id="patch-apps"></a>By default, tool will build only `youtube`. To build other apps supported by patching 4. <a id="patch-apps"></a>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 resources.Add the apps you want to build in `.env` file or in `ENVS` in `GitHub secrets` in the format
+1 -1
View File
@@ -34,7 +34,7 @@ def main() -> None:
logger.info(app) logger.info(app)
parser.patch_app(app) parser.patch_app(app)
except AppNotFound as e: except AppNotFound as e:
logger.info(f"Invalid app requested to build {e}") logger.info(e)
except PatchesJsonLoadFailed: except PatchesJsonLoadFailed:
logger.exception("Patches.json not found") logger.exception("Patches.json not found")
except PatchingFailed as e: except PatchingFailed as e:
+6 -4
View File
@@ -50,9 +50,8 @@ class APP(object):
self.download_dl = config.env.str(f"{app_name}_DL".upper(), "") self.download_dl = config.env.str(f"{app_name}_DL".upper(), "")
self.download_patch_resources(config) self.download_patch_resources(config)
self.download_source = config.env.str(f"{app_name}_DL_SOURCE".upper(), "") self.download_source = config.env.str(f"{app_name}_DL_SOURCE".upper(), "")
self.package_name = config.env.str( env_package_name = config.env.str(f"{app_name}_PACKAGE_NAME".upper(), None)
f"{app_name}_PACKAGE_NAME".upper(), Patches.get_package_name(app_name) self.package_name = env_package_name or Patches.get_package_name(app_name)
)
def download_apk_for_patching(self, config: RevancedConfig) -> None: def download_apk_for_patching(self, config: RevancedConfig) -> None:
"""Download apk to be patched.""" """Download apk to be patched."""
@@ -73,7 +72,10 @@ class APP(object):
self.package_name self.package_name
) )
except KeyError: except KeyError:
raise DownloadFailure(f"No download source found for {self.app_name}") raise DownloadFailure(
f"App {self.app_name} not supported officially yet. Please provide download "
"source in env."
)
downloader = DownloaderFactory.create_downloader( downloader = DownloaderFactory.create_downloader(
config=config, apk_source=self.download_source config=config, apk_source=self.download_source
) )
+8 -12
View File
@@ -75,7 +75,9 @@ class Patches(object):
for package, app_name in Patches.revanced_package_names.items(): for package, app_name in Patches.revanced_package_names.items():
if app_name == app: if app_name == app:
return package return package
raise AppNotFound(f"App {app} not supported yet.") raise AppNotFound(
f"App {app} not supported officially yet. Please provide package name in env to proceed."
)
@staticmethod @staticmethod
def support_app() -> Dict[str, str]: def support_app() -> Dict[str, str]:
@@ -100,6 +102,7 @@ class Patches(object):
app : APP app : APP
The `app` parameter is of type `APP`. It represents an instance of the `APP` class. The `app` parameter is of type `APP`. It represents an instance of the `APP` class.
""" """
self.patches_dict[app.app_name] = []
patch_loader = PatchLoader() patch_loader = PatchLoader()
patches = patch_loader.load_patches( patches = patch_loader.load_patches(
f'{config.temp_folder}/{app.resource["patches_json"]}' f'{config.temp_folder}/{app.resource["patches_json"]}'
@@ -111,20 +114,17 @@ class Patches(object):
p["app"] = "universal" p["app"] = "universal"
p["version"] = "all" p["version"] = "all"
self.patches_dict["universal_patch"].append(p) self.patches_dict["universal_patch"].append(p)
else:
for compatible_package, version in [ for compatible_package, version in [
(x["name"], x["versions"]) for x in patch["compatiblePackages"] (x["name"], x["versions"]) for x in patch["compatiblePackages"]
]: ]:
if compatible_package in self.revanced_package_names.keys(): if app.package_name == compatible_package:
app_name = self.revanced_package_names[compatible_package]
if not self.patches_dict.get(app_name, None):
self.patches_dict[app_name] = []
p = {x: patch[x] for x in ["name", "description"]} p = {x: patch[x] for x in ["name", "description"]}
p["app"] = compatible_package p["app"] = compatible_package
p["version"] = version[-1] if version else "all" p["version"] = version[-1] if version else "all"
self.patches_dict[app_name].append(p) self.patches_dict[app.app_name].append(p)
n_patches = len(self.patches_dict[app.app_name]) app.no_of_patches = len(self.patches_dict[app.app_name])
app.no_of_patches = n_patches
def __init__(self, config: RevancedConfig, app: APP) -> None: def __init__(self, config: RevancedConfig, app: APP) -> None:
self.patches_dict: Dict[str, Any] = {"universal_patch": []} self.patches_dict: Dict[str, Any] = {"universal_patch": []}
@@ -146,10 +146,6 @@ class Patches(object):
patches for the given app. The second element is a string representing the version of the patches for the given app. The second element is a string representing the version of the
patches. patches.
""" """
app_names = self.revanced_package_names
if app not in app_names.values():
raise AppNotFound(f"App {app} not supported yet.")
patches = self.patches_dict[app] patches = self.patches_dict[app]
version = "latest" version = "latest"