mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🐛 Handle new v3 cli args (#339)
This commit is contained in:
@@ -5,6 +5,7 @@ venv
|
|||||||
*/__pycache__*
|
*/__pycache__*
|
||||||
*.pyc
|
*.pyc
|
||||||
/revanced-cache/
|
/revanced-cache/
|
||||||
|
/revanced-resource-cache/
|
||||||
changelog.md
|
changelog.md
|
||||||
.idea
|
.idea
|
||||||
*.json
|
*.json
|
||||||
|
|||||||
+25
-2
@@ -1,4 +1,5 @@
|
|||||||
"""Revanced Parser."""
|
"""Revanced Parser."""
|
||||||
|
from pathlib import Path
|
||||||
from subprocess import PIPE, Popen
|
from subprocess import PIPE, Popen
|
||||||
from time import perf_counter
|
from time import perf_counter
|
||||||
from typing import List, Self
|
from typing import List, Self
|
||||||
@@ -17,6 +18,7 @@ class Parser(object):
|
|||||||
|
|
||||||
CLI_JAR = "-jar"
|
CLI_JAR = "-jar"
|
||||||
APK_ARG = "-a"
|
APK_ARG = "-a"
|
||||||
|
NEW_APK_ARG = "patch"
|
||||||
PATCHES_ARG = "-b"
|
PATCHES_ARG = "-b"
|
||||||
INTEGRATIONS_ARG = "-m"
|
INTEGRATIONS_ARG = "-m"
|
||||||
OUTPUT_ARG = "-o"
|
OUTPUT_ARG = "-o"
|
||||||
@@ -101,6 +103,21 @@ class Parser(object):
|
|||||||
if item == "-i":
|
if item == "-i":
|
||||||
self._PATCHES[idx] = "-e"
|
self._PATCHES[idx] = "-e"
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_new_cli(cli_path: Path) -> 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:
|
||||||
|
logger.debug("New cli")
|
||||||
|
return True
|
||||||
|
logger.debug("Old cli")
|
||||||
|
return False
|
||||||
|
|
||||||
# noinspection IncorrectFormatting
|
# noinspection IncorrectFormatting
|
||||||
def patch_app(
|
def patch_app(
|
||||||
self: Self,
|
self: Self,
|
||||||
@@ -114,10 +131,16 @@ class Parser(object):
|
|||||||
The `app` parameter is an instance of the `APP` class. It represents an application that needs
|
The `app` parameter is an instance of the `APP` class. It represents an application that needs
|
||||||
to be patched.
|
to be patched.
|
||||||
"""
|
"""
|
||||||
|
if self.is_new_cli(self.config.temp_folder.joinpath(app.resource["cli"])):
|
||||||
|
apk_arg = self.NEW_APK_ARG
|
||||||
|
exp = "--force"
|
||||||
|
else:
|
||||||
|
apk_arg = self.APK_ARG
|
||||||
|
exp = "--experimental"
|
||||||
args = [
|
args = [
|
||||||
self.CLI_JAR,
|
self.CLI_JAR,
|
||||||
app.resource["cli"],
|
app.resource["cli"],
|
||||||
self.APK_ARG,
|
apk_arg,
|
||||||
app.download_file_name,
|
app.download_file_name,
|
||||||
self.PATCHES_ARG,
|
self.PATCHES_ARG,
|
||||||
app.resource["patches"],
|
app.resource["patches"],
|
||||||
@@ -132,7 +155,7 @@ class Parser(object):
|
|||||||
]
|
]
|
||||||
if app.experiment:
|
if app.experiment:
|
||||||
logger.debug("Using experimental features")
|
logger.debug("Using experimental features")
|
||||||
args.append("--experimental")
|
args.append(exp)
|
||||||
args[1::2] = map(self.config.temp_folder.joinpath, args[1::2])
|
args[1::2] = map(self.config.temp_folder.joinpath, args[1::2])
|
||||||
if self.config.ci_test:
|
if self.config.ci_test:
|
||||||
self.exclude_all_patches()
|
self.exclude_all_patches()
|
||||||
|
|||||||
Reference in New Issue
Block a user