🧹 More Cleanup

This commit is contained in:
Nikhil Badyal
2022-10-06 22:11:08 +05:30
parent 2e41d8ff9f
commit 0d9688470a
7 changed files with 112 additions and 122 deletions
+12 -35
View File
@@ -1,43 +1,20 @@
import sys
from pathlib import Path
from subprocess import PIPE, Popen
from time import perf_counter
from typing import List
from environs import Env
from loguru import logger
from src.config import RevancedConfig
from src.patches import Patches
class Parser(object):
def __init__(self, patcher: Patches, env: Env, temp_folder: Path) -> None:
def __init__(self, patcher: Patches, config: RevancedConfig) -> None:
self._PATCHES: List[str] = []
self._EXCLUDED: List[str] = []
self.patcher = patcher
self.keystore_name = env.str("KEYSTORE_FILE_NAME", "revanced.keystore")
self.build_extended = env.bool("BUILD_EXTENDED", False)
self.extended_apps = ["youtube", "youtube_music"]
self.keystore_name = env.str("KEYSTORE_FILE_NAME", "revanced.keystore")
self.normal_cli_jar = "revanced-cli.jar"
self.normal_patches_jar = "revanced-patches.jar"
self.normal_integrations_apk = "revanced-integrations.apk"
self.cli_jar = (
f"inotia00-{self.normal_cli_jar}"
if self.build_extended
else self.normal_cli_jar
)
self.patches_jar = (
f"inotia00-{self.normal_patches_jar}"
if self.build_extended
else self.normal_patches_jar
)
self.integrations_apk = (
f"inotia00-{self.normal_integrations_apk}"
if self.build_extended
else self.normal_integrations_apk
)
self.temp_folder = temp_folder
self.config = config
def include(self, name: str) -> None:
self._PATCHES.extend(["-i", name])
@@ -51,13 +28,13 @@ class Parser(object):
def patch_app(self, app: str, version: str, is_experimental: bool = False) -> None:
logger.debug(f"Sending request to revanced cli for building {app} revanced")
cli = self.normal_cli_jar
patches = self.normal_patches_jar
integrations = self.normal_integrations_apk
if self.build_extended and app in self.extended_apps:
cli = self.cli_jar
patches = self.patches_jar
integrations = self.integrations_apk
cli = self.config.normal_cli_jar
patches = self.config.normal_patches_jar
integrations = self.config.normal_integrations_apk
if self.config.build_extended and app in self.config.extended_apps:
cli = self.config.cli_jar
patches = self.config.patches_jar
integrations = self.config.integrations_apk
args = [
"-jar",
cli,
@@ -70,12 +47,12 @@ class Parser(object):
"-o",
f"Re-{app}-{version}-output.apk",
"--keystore",
self.keystore_name,
self.config.keystore_name,
]
if is_experimental:
logger.debug("Using experimental features")
args.append("--experimental")
args[1::2] = map(lambda i: self.temp_folder.joinpath(i), args[1::2])
args[1::2] = map(lambda i: self.config.temp_folder.joinpath(i), args[1::2])
if self._PATCHES:
args.extend(self._PATCHES)