🐛 Updated for revanced cli v5

This commit is contained in:
Nikhil Badyal
2024-11-12 22:00:35 +05:30
committed by Nikhil Badyal
parent 3e3d14c14a
commit 614046a15a
10 changed files with 25 additions and 81 deletions
-8
View File
@@ -4,7 +4,6 @@ PATCH_APPS=youtube,youtube_revancify_red,youtube_revancify_blue,youtube_mmt,yout
GLOBAL_CLI_DL=https://github.com/revanced/revanced-cli
GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches
GLOBAL_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches
GLOBAL_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations
#Example
EXISTING_DOWNLOADED_APKS=twitter
@@ -14,7 +13,6 @@ PERSONAL_ACCESS_TOKEN=ghp_asample_token
YOUTUBE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#Example
@@ -27,7 +25,6 @@ YOUTUBE_REVANCIFY_RED_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtube
YOUTUBE_REVANCIFY_RED_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_REVANCIFY_RED_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_RED_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_RED_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_REVANCIFY_RED_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#YouTube Revancify Blue:
@@ -36,7 +33,6 @@ YOUTUBE_REVANCIFY_BLUE_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtub
YOUTUBE_REVANCIFY_BLUE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_REVANCIFY_BLUE_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_BLUE_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_REVANCIFY_BLUE_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_REVANCIFY_BLUE_EXCLUDE_PATCH=custom-branding-icon-revancify-red,custom-branding-icon-mmt,custom-branding-youtube-name,enable-debug-logging
#YouTube MMT:
@@ -45,14 +41,12 @@ YOUTUBE_MMT_DL_SOURCE=https://www.apkmirror.com/apk/google-inc/youtube/
YOUTUBE_MMT_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_MMT_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MMT_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MMT_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_MMT_EXCLUDE_PATCH=custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-youtube-name,enable-debug-logging
#YouTube Music:
YOUTUBE_MUSIC_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_MUSIC_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MUSIC_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
YOUTUBE_MUSIC_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
YOUTUBE_MUSIC_EXCLUDE_PATCH=custom-branding-icon-mmt,custom-branding-icon-revancify-blue,custom-branding-icon-revancify-red,custom-branding-music-name,enable-compact-dialog,enable-debug-logging
#Example
@@ -62,7 +56,6 @@ YOUTUBE_MUSIC_VERSION=6.15.52
REDDIT_CLI_DL=https://github.com/inotia00/revanced-cli
REDDIT_PATCHES_DL=https://github.com/YT-Advanced/ReX-patches
REDDIT_PATCHES_JSON_DL=https://github.com/YT-Advanced/ReX-patches
REDDIT_INTEGRATIONS_DL=https://github.com/YT-Advanced/ReX-integrations
#Example
#Twitter
@@ -70,4 +63,3 @@ TWITTER_VERSION=latest
TWITTER_CLI_DL=local://cli.jar
TWITTER_PATCHES_DL=local://patches.jar
TWITTER_PATCHES_JSON_DL=local://patches.json
TWITTER_INTEGRATIONS_DL=local://integrations.apk
-5
View File
@@ -3,24 +3,19 @@ EXTRA_FILES=https://github.com/ReVanced/GmsCore/releases/latest@Revanced-Microg.
PATCH_APPS=youtube,youtube_music,reddit,twitter
GLOBAL_CLI_DL=https://github.com/inotia00/revanced-cli/releases/latest
GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches/releases/latest
GLOBAL_INTEGRATIONS_DL=https://github.com/revanced/revanced-integrations/releases/latest
#YouTube:
YOUTUBE_PATCHES_DL=https://github.com/inotia00/revanced-patches/latest-prerelease
YOUTUBE_INTEGRATIONS_DL=https://github.com/inotia00/revanced-integrations/releases/latest-prerelease
YOUTUBE_EXCLUDE_PATCH=custom-branding-icon-youtube,custom-branding-name-youtube,enable-debug-logging,hide-fullscreen-button
#YouTube Music:
YOUTUBE_MUSIC_PATCHES_DL=https://github.com/inotia00/revanced-patches/latest-prerelease
YOUTUBE_MUSIC_INTEGRATIONS_DL=https://github.com/inotia00/revanced-integrations/releases/latest-prerelease
YOUTUBE_MUSIC_EXCLUDE_PATCH=custom-branding-icon-youtube-music,custom-branding-name-youtube-music,enable-compact-dialog,enable-debug-logging,enable-old-player-layout
YOUTUBE_MUSIC_VERSION=latest
#Reddit:
REDDIT_PATCHES_DL=https://github.com/inotia00/revanced-patches/latest-prerelease
REDDIT_INTEGRATIONS_DL=https://github.com/inotia00/revanced-integrations/releases/latest-prerelease
REDDIT_EXCLUDE_PATCH=change-package-name
#Twitter:
TWITTER_PATCHES_DL=https://github.com/crimera/piko/releases/latest
TWITTER_INTEGRATIONS_DL=https://github.com/crimera/revanced-integrations/releases/latest
+7 -7
View File
@@ -51,13 +51,13 @@ repos:
args:
- "--config=pyproject.toml"
- repo: https://github.com/PyCQA/docformatter
rev: master
hooks:
- id: docformatter
args:
- "--config=pyproject.toml"
- "--in-place"
# - repo: https://github.com/PyCQA/docformatter
# rev: master
# hooks:
# - id: docformatter
# args:
# - "--config=pyproject.toml"
# - "--in-place"
- repo: https://github.com/pre-commit/mirrors-mypy
+1 -5
View File
@@ -116,7 +116,6 @@ You can use any of the following methods to build.
| [GLOBAL_PATCHES_DL*](#global-resources) | DL for Patches to be used for patching apps. | [Revanced Patches](https://github.com/revanced/revanced-patches) |
| [GLOBAL_SPACE_FORMATTED_PATCHES*](#global-resources) | Whether patches are space formatted. | True |
| [GLOBAL_PATCHES_JSON_DL*](#global-resources) | DL for Patches Json to be used for patching apps. | [Revanced Patches](https://github.com/revanced/revanced-patches) |
| [GLOBAL_INTEGRATIONS_DL*](#global-resources) | DL for Integrations to be used for patching apps. | [Revanced Integrations](https://github.com/revanced/revanced-integrations) |
| [GLOBAL_KEYSTORE_FILE_NAME*](#global-keystore-file-name) | Key file to be used for signing apps | [Builder's own key](https://github.com/nikhilbadyal/docker-py-revanced/blob/main/apks/revanced.keystore) |
| [GLOBAL_OLD_KEY*](#global-keystore-file-name) | Whether key was generated with cli v4(new) or not | <br/>[Builder's v3(old) own key](https://github.com/nikhilbadyal/docker-py-revanced/blob/main/apks/revanced.keystore) |
| [GLOBAL_OPTIONS_FILE*](#global-options-file) | Options file to be used | [Builder's default file](https://github.com/nikhilbadyal/docker-py-revanced/blob/main/apks/options.json) |
@@ -141,7 +140,6 @@ You can use any of the following methods to build.
| [*APP_NAME*_PATCHES_DL](#global-resources) | DL for Patches to be used for patching **APP_NAME**. | GLOBAL_PATCHES_DL |
| [*APP_NAME*_PATCHES_JSON_DL](#global-resources) | DL for Patches Json to be used for patching **APP_NAME**. | GLOBAL_PATCHES_JSON_DL |
| [*APP_NAME*_SPACE_FORMATTED_PATCHES](#global-resources) | Whether patches are space formatted. **APP_NAME**. | GLOBAL_SPACE_FORMATTED_PATCHES |
| [*APP_NAME*_INTEGRATIONS_DL](#global-resources) | DL for Integrations to be used for patching **APP_NAME**. | GLOBAL_INTEGRATIONS_DL |
| [*APP_NAME*_KEYSTORE_FILE_NAME](#global-keystore-file-name) | Key file to be used for signing **APP_NAME**. | GLOBAL_KEYSTORE_FILE_NAME |
| [*APP_NAME*_OLD_KEY](#global-keystore-file-name) | Whether key used was generated with cli > v4(new) <br/><br/>**APP_NAME**. <br/> <br/> | GLOBAL_OLK_KEY |
| [*APP_NAME*_ARCHS_TO_BUILD](#global-archs-to-build) | Arch to keep in the patched **APP_NAME**. | GLOBAL_ARCHS_TO_BUILD |
@@ -287,7 +285,6 @@ You can use any of the following methods to build.
GLOBAL_CLI_DL=https://github.com/revanced/revanced-cli
GLOBAL_PATCHES_DL=https://github.com/revanced/revanced-patches
GLOBAL_PATCHES_JSON_DL=https://github.com/revanced/revanced-patches
GLOBAL_INTEGRATIONS_DL=local://integrations.apk
```
Resources downloaded from envs and will be used for patching for any **APP_NAME**.
Unless provided different resource for the individual app.<br><br>
@@ -299,7 +296,6 @@ You can use any of the following methods to build.
YOUTUBE_CLI_DL=https://github.com/inotia00/revanced-cli
YOUTUBE_PATCHES_DL=https://github.com/inotia00/revanced-patches
YOUTUBE_PATCHES_JSON_DL=https://github.com/inotia00/revanced-patches
YOUTUBE_INTEGRATIONS_DL=https://github.com/inotia00/revanced-integrations
```
With the config tool will try to patch YouTube with resources from inotia00 while other global resource will used
for patching other apps.<br>
@@ -376,7 +372,7 @@ You can use any of the following methods to build.
```
Example:
```dotenv
EXTRA_FILES=https://github.com/inotia00/mMicroG/releases/latest@mmicrog.apk,https://github.com/revanced/revanced-integrations@integrations.apk
EXTRA_FILES=https://github.com/inotia00/mMicroG/releases/latest@mmicrog.apk
```
12. <a id="custom-exclude-patching"></a>If you want to exclude any patch. Set comma separated patch in `.env` file
or in `ENVS` in `GitHub secrets` (Recommended) in the format
+1 -12
View File
@@ -6,7 +6,7 @@ from loguru import logger
from main import get_app
from src.config import RevancedConfig
from src.manager.github import GitHubManager
from src.utils import default_build, integration_version_key, integrations_dl_key, patches_dl_key, patches_version_key
from src.utils import default_build, patches_dl_key, patches_version_key
def check_if_build_is_required() -> bool:
@@ -18,17 +18,10 @@ def check_if_build_is_required() -> bool:
for app_name in env.list("PATCH_APPS", default_build):
logger.info(f"Checking {app_name}")
app_obj = get_app(config, app_name)
old_integration_version = GitHubManager(env).get_last_version(app_obj, integration_version_key)
old_integration_source = GitHubManager(env).get_last_version_source(app_obj, integrations_dl_key)
old_patches_version = GitHubManager(env).get_last_version(app_obj, patches_version_key)
old_patches_source = GitHubManager(env).get_last_version_source(app_obj, patches_dl_key)
app_obj.download_patch_resources(config)
if GitHubManager(env).should_trigger_build(
old_integration_version,
old_integration_source,
app_obj.resource["integrations"]["version"],
app_obj.integrations_dl,
) or GitHubManager(env).should_trigger_build(
old_patches_version,
old_patches_source,
app_obj.resource["patches"]["version"],
@@ -36,10 +29,6 @@ def check_if_build_is_required() -> bool:
):
caused_by = {
"app_name": app_name,
"integration": {
"old": old_integration_version,
"new": app_obj.resource["integrations"]["version"],
},
"patches": {
"old": old_patches_version,
"new": app_obj.resource["patches"]["version"],
+4 -6
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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"],