mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🐛 Updated for revanced cli v5
This commit is contained in:
committed by
Nikhil Badyal
parent
3e3d14c14a
commit
614046a15a
+4
-6
@@ -32,8 +32,7 @@ class APP(object):
|
||||
self.experiment = False
|
||||
self.cli_dl = config.env.str(f"{app_name}_CLI_DL".upper(), config.global_cli_dl)
|
||||
self.patches_dl = config.env.str(f"{app_name}_PATCHES_DL".upper(), config.global_patches_dl)
|
||||
self.integrations_dl = config.env.str(f"{app_name}_INTEGRATIONS_DL".upper(), config.global_integrations_dl)
|
||||
self.patches_json_dl = config.env.str(f"{app_name}_PATCHES_JSON_DL".upper(), self.patches_dl)
|
||||
self.patches_json_dl = config.env.str(f"{app_name}_PATCHES_JSON_DL".upper(), config.global_patches_json_dl)
|
||||
self.exclude_request: list[str] = config.env.list(f"{app_name}_EXCLUDE_PATCH".upper(), [])
|
||||
self.include_request: list[str] = config.env.list(f"{app_name}_INCLUDE_PATCH".upper(), [])
|
||||
self.resource: dict[str, dict[str, str]] = {}
|
||||
@@ -149,13 +148,12 @@ class APP(object):
|
||||
# Create a list of resource download tasks
|
||||
download_tasks = [
|
||||
("cli", self.cli_dl, config, ".*jar"),
|
||||
("integrations", self.integrations_dl, config, ".*apk"),
|
||||
("patches", self.patches_dl, config, ".*jar"),
|
||||
("patches_json", self.patches_json_dl, config, ".*json"),
|
||||
("patches", self.patches_dl, config, ".*rvp"),
|
||||
("patches_json", self.patches_json_dl, config, ".*"),
|
||||
]
|
||||
|
||||
# Using a ThreadPoolExecutor for parallelism
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
with ThreadPoolExecutor(1) as executor:
|
||||
futures = {resource_name: executor.submit(self.download, *args) for resource_name, *args in download_tasks}
|
||||
|
||||
# Wait for all tasks to complete
|
||||
|
||||
+1
-9
@@ -5,14 +5,7 @@ from typing import Self
|
||||
|
||||
from environs import Env
|
||||
|
||||
from src.utils import (
|
||||
default_build,
|
||||
default_cli,
|
||||
default_integrations,
|
||||
default_patches,
|
||||
default_patches_json,
|
||||
resource_folder,
|
||||
)
|
||||
from src.utils import default_build, default_cli, default_patches, default_patches_json, resource_folder
|
||||
|
||||
|
||||
class RevancedConfig(object):
|
||||
@@ -30,7 +23,6 @@ class RevancedConfig(object):
|
||||
self.global_cli_dl = env.str("GLOBAL_CLI_DL", default_cli)
|
||||
self.global_patches_dl = env.str("GLOBAL_PATCHES_DL", default_patches)
|
||||
self.global_patches_json_dl = env.str("GLOBAL_PATCHES_JSON_DL", default_patches_json)
|
||||
self.global_integrations_dl = env.str("GLOBAL_INTEGRATIONS_DL", default_integrations)
|
||||
self.global_keystore_name = env.str("GLOBAL_KEYSTORE_FILE_NAME", "revanced.keystore")
|
||||
self.global_options_file = env.str("GLOBAL_OPTIONS_FILE", "options.json")
|
||||
self.global_archs_to_build = env.list("GLOBAL_ARCHS_TO_BUILD", [])
|
||||
|
||||
+7
-21
@@ -1,6 +1,5 @@
|
||||
"""Revanced Parser."""
|
||||
|
||||
from pathlib import Path
|
||||
from subprocess import PIPE, Popen
|
||||
from time import perf_counter
|
||||
from typing import Self
|
||||
@@ -20,8 +19,7 @@ class Parser(object):
|
||||
CLI_JAR = "-jar"
|
||||
APK_ARG = "-a"
|
||||
NEW_APK_ARG = "patch"
|
||||
PATCHES_ARG = "-b"
|
||||
INTEGRATIONS_ARG = "-m"
|
||||
PATCHES_ARG = "-p"
|
||||
OUTPUT_ARG = "-o"
|
||||
KEYSTORE_ARG = "--keystore"
|
||||
OPTIONS_ARG = "--options"
|
||||
@@ -40,7 +38,7 @@ class Parser(object):
|
||||
name : str
|
||||
The `name` parameter is a string that represents the name of the patch to be included.
|
||||
"""
|
||||
self._PATCHES.extend(["-i", name])
|
||||
self._PATCHES.extend(["-e", name])
|
||||
|
||||
def exclude(self: Self, name: str) -> None:
|
||||
"""The `exclude` function adds a given patch to the list of excluded patches.
|
||||
@@ -50,7 +48,7 @@ class Parser(object):
|
||||
name : str
|
||||
The `name` parameter is a string that represents the name of the patch to be excluded.
|
||||
"""
|
||||
self._PATCHES.extend(["-e", name])
|
||||
self._PATCHES.extend(["-d", name])
|
||||
self._EXCLUDED.append(name)
|
||||
|
||||
def get_excluded_patches(self: Self) -> list[str]:
|
||||
@@ -137,19 +135,9 @@ class Parser(object):
|
||||
self.include(patch["name"]) if patch["name"] in app.include_request else ()
|
||||
|
||||
@staticmethod
|
||||
def is_new_cli(cli_path: Path) -> tuple[bool, str]:
|
||||
def is_new_cli() -> bool:
|
||||
"""Check if new cli is being used."""
|
||||
process = Popen(["java", "-jar", cli_path, "-V"], stdout=PIPE)
|
||||
output = process.stdout
|
||||
if not output:
|
||||
msg = "Failed to send request for patching."
|
||||
raise PatchingFailedError(msg)
|
||||
combined_result = "".join(line.decode() for line in output)
|
||||
if "v3" in combined_result or "v4" in combined_result:
|
||||
logger.debug("New cli")
|
||||
return True, combined_result
|
||||
logger.debug("Old cli")
|
||||
return False, combined_result
|
||||
return True
|
||||
|
||||
# noinspection IncorrectFormatting
|
||||
def patch_app(
|
||||
@@ -164,7 +152,7 @@ class Parser(object):
|
||||
The `app` parameter is an instance of the `APP` class. It represents an application that needs
|
||||
to be patched.
|
||||
"""
|
||||
is_new, version = self.is_new_cli(self.config.temp_folder.joinpath(app.resource["cli"]["file_name"]))
|
||||
is_new = self.is_new_cli()
|
||||
if is_new:
|
||||
apk_arg = self.NEW_APK_ARG
|
||||
exp = "--force"
|
||||
@@ -178,8 +166,6 @@ class Parser(object):
|
||||
app.download_file_name,
|
||||
self.PATCHES_ARG,
|
||||
app.resource["patches"]["file_name"],
|
||||
self.INTEGRATIONS_ARG,
|
||||
app.resource["integrations"]["file_name"],
|
||||
self.OUTPUT_ARG,
|
||||
app.get_output_file_name(),
|
||||
self.KEYSTORE_ARG,
|
||||
@@ -191,7 +177,7 @@ class Parser(object):
|
||||
logger.debug("Using experimental features")
|
||||
args.append(exp)
|
||||
args[1::2] = map(self.config.temp_folder.joinpath, args[1::2])
|
||||
if app.old_key and "v4" in version:
|
||||
if app.old_key:
|
||||
# https://github.com/ReVanced/revanced-cli/issues/272#issuecomment-1740587534
|
||||
old_key_flags = [
|
||||
"--keystore-entry-alias=alias",
|
||||
|
||||
+3
-3
@@ -129,11 +129,11 @@ class Patches(object):
|
||||
p["version"] = "all"
|
||||
self.patches_dict["universal_patch"].append(p)
|
||||
else:
|
||||
for compatible_package, version in [(x["name"], x["versions"]) for x in patch["compatiblePackages"]]:
|
||||
for compatible_package, versions in patch["compatiblePackages"].items():
|
||||
if app.package_name == compatible_package:
|
||||
p = {x: patch[x] for x in ["name", "description"]}
|
||||
p = {x: patch[x] for x in ["name", "description", "use"]}
|
||||
p["app"] = compatible_package
|
||||
p["version"] = version[-1] if version else "all"
|
||||
p["version"] = versions[-1] if versions else "all"
|
||||
self.patches_dict[app.app_name].append(p)
|
||||
|
||||
app.no_of_patches = len(self.patches_dict[app.app_name])
|
||||
|
||||
+1
-5
@@ -38,8 +38,7 @@ request_header = {
|
||||
}
|
||||
default_cli = "https://github.com/revanced/revanced-cli/releases/latest"
|
||||
default_patches = "https://github.com/revanced/revanced-patches/releases/latest"
|
||||
default_patches_json = default_patches
|
||||
default_integrations = "https://github.com/revanced/revanced-integrations/releases/latest"
|
||||
default_patches_json = "https://api.revanced.app/v4/patches/list"
|
||||
bs4_parser = "html.parser"
|
||||
changelog_file = "changelog.md"
|
||||
changelog_json_file = "changelog.json"
|
||||
@@ -51,7 +50,6 @@ updates_file_url = "https://raw.githubusercontent.com/{github_repository}/{branc
|
||||
changelogs: dict[str, dict[str, str]] = {}
|
||||
time_zone = "Asia/Kolkata"
|
||||
app_version_key = "app_version"
|
||||
integration_version_key = "integrations_version"
|
||||
patches_version_key = "patches_version"
|
||||
cli_version_key = "cli_version"
|
||||
patches_json_version_key = "patches_json_version"
|
||||
@@ -61,7 +59,6 @@ resource_folder = "apks"
|
||||
branch_name = "changelogs"
|
||||
app_dump_key = "app_dump"
|
||||
patches_dl_key = "patches_dl"
|
||||
integrations_dl_key = "integrations_dl"
|
||||
|
||||
|
||||
def update_changelog(name: str, response: dict[str, str]) -> None:
|
||||
@@ -268,7 +265,6 @@ def save_patch_info(app: "APP", updates_info: dict[str, Any]) -> dict[str, Any]:
|
||||
"""Save version info a patching resources used to a file."""
|
||||
updates_info[app.app_name] = {
|
||||
app_version_key: app.app_version,
|
||||
integration_version_key: app.resource["integrations"]["version"],
|
||||
patches_version_key: app.resource["patches"]["version"],
|
||||
cli_version_key: app.resource["cli"]["version"],
|
||||
patches_json_version_key: app.resource["patches_json"]["version"],
|
||||
|
||||
Reference in New Issue
Block a user