mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Patch any application
This commit is contained in:
@@ -34,7 +34,7 @@ def main() -> None:
|
||||
logger.info(app)
|
||||
parser.patch_app(app)
|
||||
except AppNotFound as e:
|
||||
logger.info(f"Invalid app requested to build {e}")
|
||||
logger.info(e)
|
||||
except PatchesJsonLoadFailed:
|
||||
logger.exception("Patches.json not found")
|
||||
except PatchingFailed as e:
|
||||
|
||||
+6
-4
@@ -50,9 +50,8 @@ class APP(object):
|
||||
self.download_dl = config.env.str(f"{app_name}_DL".upper(), "")
|
||||
self.download_patch_resources(config)
|
||||
self.download_source = config.env.str(f"{app_name}_DL_SOURCE".upper(), "")
|
||||
self.package_name = config.env.str(
|
||||
f"{app_name}_PACKAGE_NAME".upper(), Patches.get_package_name(app_name)
|
||||
)
|
||||
env_package_name = config.env.str(f"{app_name}_PACKAGE_NAME".upper(), None)
|
||||
self.package_name = env_package_name or Patches.get_package_name(app_name)
|
||||
|
||||
def download_apk_for_patching(self, config: RevancedConfig) -> None:
|
||||
"""Download apk to be patched."""
|
||||
@@ -73,7 +72,10 @@ class APP(object):
|
||||
self.package_name
|
||||
)
|
||||
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 "
|
||||
f"source in env."
|
||||
)
|
||||
downloader = DownloaderFactory.create_downloader(
|
||||
config=config, apk_source=self.download_source
|
||||
)
|
||||
|
||||
+14
-18
@@ -75,7 +75,9 @@ class Patches(object):
|
||||
for package, app_name in Patches.revanced_package_names.items():
|
||||
if app_name == app:
|
||||
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
|
||||
def support_app() -> Dict[str, str]:
|
||||
@@ -100,6 +102,7 @@ class Patches(object):
|
||||
app : APP
|
||||
The `app` parameter is of type `APP`. It represents an instance of the `APP` class.
|
||||
"""
|
||||
self.patches_dict[app.app_name] = []
|
||||
patch_loader = PatchLoader()
|
||||
patches = patch_loader.load_patches(
|
||||
f'{config.temp_folder}/{app.resource["patches_json"]}'
|
||||
@@ -111,20 +114,17 @@ class Patches(object):
|
||||
p["app"] = "universal"
|
||||
p["version"] = "all"
|
||||
self.patches_dict["universal_patch"].append(p)
|
||||
for compatible_package, version in [
|
||||
(x["name"], x["versions"]) for x in patch["compatiblePackages"]
|
||||
]:
|
||||
if compatible_package in self.revanced_package_names.keys():
|
||||
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["app"] = compatible_package
|
||||
p["version"] = version[-1] if version else "all"
|
||||
self.patches_dict[app_name].append(p)
|
||||
else:
|
||||
for compatible_package, version in [
|
||||
(x["name"], x["versions"]) for x in patch["compatiblePackages"]
|
||||
]:
|
||||
if app.package_name == compatible_package:
|
||||
p = {x: patch[x] for x in ["name", "description"]}
|
||||
p["app"] = compatible_package
|
||||
p["version"] = version[-1] if version else "all"
|
||||
self.patches_dict[app.app_name].append(p)
|
||||
|
||||
n_patches = len(self.patches_dict[app.app_name])
|
||||
app.no_of_patches = n_patches
|
||||
app.no_of_patches = len(self.patches_dict[app.app_name])
|
||||
|
||||
def __init__(self, config: RevancedConfig, app: APP) -> None:
|
||||
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.
|
||||
"""
|
||||
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]
|
||||
version = "latest"
|
||||
|
||||
Reference in New Issue
Block a user