From a07d852ec4f1c3a330f436a72658b68356fce7c8 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Fri, 14 Oct 2022 19:46:51 +0530 Subject: [PATCH 1/4] =?UTF-8?q?=E2=9C=A8=20Build=20Og=20and=20Custom=20Ico?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 7 +++++++ main.py | 12 ++++++++++++ src/config.py | 1 + src/parser.py | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+) diff --git a/.env b/.env index e69de29..0344bdf 100644 --- a/.env +++ b/.env @@ -0,0 +1,7 @@ +PATCH_APPS=youtube +BUILD_EXTENDED=True +EXCLUDE_PATCH_YOUTUBE=custom-branding,enable-debugging +EXCLUDE_PATCH_YOUTUBE_EXTENDED=custom-branding-red,custom-branding-blue,materialyou,custom-branding-decipher3114,custom-branding-name,custom-package-name,always-autorepeat +EXCLUDE_PATCH_YOUTUBE_MUSIC_EXTENDED=custom-branding-music,custom-branding-music-decipher3114,custom-package-name-music,custom-branding-music-red +CHANGELOG_GITHUB_REPOSITORY=inotia00/revanced-patches +BUILD_OG_BRANDING_YOUTUBE=True diff --git a/main.py b/main.py index 929c752..f87be4d 100644 --- a/main.py +++ b/main.py @@ -30,6 +30,18 @@ def main() -> None: parser.patch_app(app=app, version=version, is_experimental=is_experimental) except Exception as e: logger.exception(f"Failed to build {app} because of {e}") + if config.build_og_nd_branding_youtube: + all_patches = parser.get_all_patches() + branding_patch = "custom-branding" + if config.build_extended: + branding_patch = "custom-branding-blue" + branding_index = all_patches.index(branding_patch) + was_og_build = True if all_patches[branding_index - 1] == "-e" else False + app = "youtube-custom-icon" if was_og_build else "youtube" + _, version, is_experimental = patcher.get_app_configs("youtube") + parser.invert_patch(branding_patch) + parser.patch_app(app=app, version=version, is_experimental=is_experimental) + logger.info(parser.get_all_patches()) if __name__ == "__main__": diff --git a/src/config.py b/src/config.py index cb18fec..f139547 100644 --- a/src/config.py +++ b/src/config.py @@ -56,3 +56,4 @@ class RevancedConfig: "youtube": f"{self.apk_mirror_urls.get('youtube')}youtube", "youtube_music": f"{self.apk_mirror_urls.get('youtube_music')}youtube-music", } + self.build_og_nd_branding_youtube = env.bool("BUILD_OG_BRANDING_YOUTUBE", False) diff --git a/src/parser.py b/src/parser.py index d9a483c..015c151 100644 --- a/src/parser.py +++ b/src/parser.py @@ -41,6 +41,24 @@ class Parser(object): """ return self._EXCLUDED + def get_all_patches(self) -> List[str]: + """ + Getter to get all excluded patches + :return: List of excluded patches + """ + return self._PATCHES + + def invert_patch(self, name: str) -> None: + """ + Getter to get all excluded patches + :return: List of excluded patches + """ + patch_index = self._PATCHES.index(name) + if self._PATCHES[patch_index - 1] == "e": + self._PATCHES[patch_index - 1] = "-i" + else: + self._PATCHES[patch_index - 1] = "-e" + def patch_app(self, app: str, version: str, is_experimental: bool = False) -> None: """Revanced APP Patcher. From c562839b9ec05068ce9a0832958b9f8fd7fa4e60 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Fri, 14 Oct 2022 19:53:53 +0530 Subject: [PATCH 2/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20file=20not=20found?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 16 ++++++++++++---- src/parser.py | 12 ++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index f87be4d..4204b70 100644 --- a/main.py +++ b/main.py @@ -31,17 +31,25 @@ def main() -> None: except Exception as e: logger.exception(f"Failed to build {app} because of {e}") if config.build_og_nd_branding_youtube: + logger.info("Rebuilding youtube") all_patches = parser.get_all_patches() branding_patch = "custom-branding" if config.build_extended: branding_patch = "custom-branding-blue" branding_index = all_patches.index(branding_patch) was_og_build = True if all_patches[branding_index - 1] == "-e" else False - app = "youtube-custom-icon" if was_og_build else "youtube" - _, version, is_experimental = patcher.get_app_configs("youtube") + output = "-custom-icon-" if was_og_build else "" + app = "youtube" + _, version, is_experimental = patcher.get_app_configs(app) + logger.info(parser.get_all_patches()) parser.invert_patch(branding_patch) - parser.patch_app(app=app, version=version, is_experimental=is_experimental) - logger.info(parser.get_all_patches()) + logger.info(parser.get_all_patches()) + parser.patch_app( + app=app, + version=version, + is_experimental=is_experimental, + output_prefix=output, + ) if __name__ == "__main__": diff --git a/src/parser.py b/src/parser.py index 015c151..198e83a 100644 --- a/src/parser.py +++ b/src/parser.py @@ -59,12 +59,20 @@ class Parser(object): else: self._PATCHES[patch_index - 1] = "-e" - def patch_app(self, app: str, version: str, is_experimental: bool = False) -> None: + # noinspection IncorrectFormatting + def patch_app( + self, + app: str, + version: str, + is_experimental: bool = False, + output_prefix: str = "-", + ) -> None: """Revanced APP Patcher. :param app: Name of the app :param version: Version of the application :param is_experimental: Whether to enable experimental support + :param output_prefix: Prefix to add to the output apks file name """ logger.debug(f"Sending request to revanced cli for building {app} revanced") cli = self.config.normal_cli_jar @@ -84,7 +92,7 @@ class Parser(object): "-m", integrations, "-o", - f"Re-{app}-{version}-output.apk", + f"Re-{app}-{version}{output_prefix}output.apk", "--keystore", self.config.keystore_name, ] From 9b91ca70bd05c43e2a41468349f9ac815e5a5828 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Fri, 14 Oct 2022 20:19:37 +0530 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=90=9B=20Fix=20incorrect=20exclude=20?= =?UTF-8?q?sign?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/parser.py b/src/parser.py index 198e83a..c3ed9b2 100644 --- a/src/parser.py +++ b/src/parser.py @@ -54,7 +54,7 @@ class Parser(object): :return: List of excluded patches """ patch_index = self._PATCHES.index(name) - if self._PATCHES[patch_index - 1] == "e": + if self._PATCHES[patch_index - 1] == "-e": self._PATCHES[patch_index - 1] = "-i" else: self._PATCHES[patch_index - 1] = "-e" From 722d9dd4d4709fbe03308ed382743d9acbb48022 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal Date: Fri, 14 Oct 2022 20:28:26 +0530 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=93=9D=20Removed=20envs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.env b/.env index 0344bdf..e69de29 100644 --- a/.env +++ b/.env @@ -1,7 +0,0 @@ -PATCH_APPS=youtube -BUILD_EXTENDED=True -EXCLUDE_PATCH_YOUTUBE=custom-branding,enable-debugging -EXCLUDE_PATCH_YOUTUBE_EXTENDED=custom-branding-red,custom-branding-blue,materialyou,custom-branding-decipher3114,custom-branding-name,custom-package-name,always-autorepeat -EXCLUDE_PATCH_YOUTUBE_MUSIC_EXTENDED=custom-branding-music,custom-branding-music-decipher3114,custom-package-name-music,custom-branding-music-red -CHANGELOG_GITHUB_REPOSITORY=inotia00/revanced-patches -BUILD_OG_BRANDING_YOUTUBE=True