Added ability to dynamically exclude patches.

This commit is contained in:
Nikhil Badyal
2022-08-22 19:47:59 +05:30
parent 90c07fa2db
commit 5931265a5c
2 changed files with 35 additions and 18 deletions
+6 -1
View File
@@ -67,7 +67,7 @@ By default script build the version as recommended by revanced team.
TIKTOK_VERSION=latest TIKTOK_VERSION=latest
WARNWETTER_VERSION=latest WARNWETTER_VERSION=latest
``` ```
3. By default it will build all build app supported by revanced team. If you don't 3. By default, it will build all build app supported by revanced team. If you don't
want to waste time and build only few apps. Add following(the apps you want to want to waste time and build only few apps. Add following(the apps you want to
build) `environment`. build) `environment`.
```dotenv ```dotenv
@@ -78,5 +78,10 @@ By default script build the version as recommended by revanced team.
```dotenv ```dotenv
KEYSTORE_FILE_NAME=revanced.keystore KEYSTORE_FILE_NAME=revanced.keystore
``` ```
5. If you want to exclude any patch. Set comma seperated environment variable like
```dotenv
EXCLUDE_PATCH_YOUTUBE=custom-branding,hide-get-premium
EXCLUDE_PATCH_YOUTUBE_MUSIC=yt-music-is-shit
```
Thanks to [@aliharslan0](https://github.com/aliharslan0/pyrevanced) for his work. Thanks to [@aliharslan0](https://github.com/aliharslan0/pyrevanced) for his work.
+24 -12
View File
@@ -7,7 +7,7 @@ from queue import PriorityQueue
from shutil import rmtree from shutil import rmtree
from subprocess import PIPE, Popen from subprocess import PIPE, Popen
from time import perf_counter from time import perf_counter
from typing import Any, Dict, List, Tuple from typing import Any, Dict, List, Tuple, Type
from environs import Env from environs import Env
from loguru import logger from loguru import logger
@@ -247,6 +247,7 @@ class Patches:
class ArgParser: class ArgParser:
_PATCHES = [] _PATCHES = []
_EXCLUDED = []
@classmethod @classmethod
def include(cls, name: str) -> None: def include(cls, name: str) -> None:
@@ -255,6 +256,11 @@ class ArgParser:
@classmethod @classmethod
def exclude(cls, name: str) -> None: def exclude(cls, name: str) -> None:
cls._PATCHES.extend(["-e", name]) cls._PATCHES.extend(["-e", name])
cls._EXCLUDED.append(name)
@classmethod
def get_excluded_patches(cls) -> List[Any]:
return cls._EXCLUDED
@classmethod @classmethod
def run(cls, app: str, version: str, is_experimental: bool = False) -> None: def run(cls, app: str, version: str, is_experimental: bool = False) -> None:
@@ -324,24 +330,30 @@ def pre_requisite():
return patches return patches
def main() -> None: def download_revanced(downloader: Type[Downloader]) -> None:
patches = pre_requisite()
downloader = Downloader
downloader.repository("revanced-cli") downloader.repository("revanced-cli")
downloader.repository("revanced-integrations") downloader.repository("revanced-integrations")
downloader.repository("revanced-patches") downloader.repository("revanced-patches")
downloader.repository("VancedMicroG", "TeamVanced") downloader.repository("VancedMicroG", "TeamVanced")
def main() -> None:
patches = pre_requisite()
downloader = Downloader
download_revanced(downloader)
def get_patches() -> None: def get_patches() -> None:
logger.debug(f"Excluding patches for app {app}") logger.debug(f"Excluding patches for app {app}")
selected_patches = list(range(0, len(app_patches))) excluded_patches = env.list(f"EXCLUDE_PATCH_{app}".upper(), [])
if app == "youtube": for patch in app_patches:
selected_patches.remove(9) arg_parser.include(patch["name"]) if patch[
for i, v in enumerate(app_patches): "name"
arg_parser.include( ] not in excluded_patches else arg_parser.exclude(patch["name"])
v["name"] excluded = arg_parser.get_excluded_patches()
) if i in selected_patches else arg_parser.exclude(v["name"]) if excluded:
logger.debug(f"Excluded patches for app {app}") logger.debug(f"Excluded patches {excluded} for {app}")
else:
logger.debug(f"No excluded patches for {app}")
def get_patches_version() -> Any: def get_patches_version() -> Any:
experiment = False experiment = False