mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 11:58:37 +09:00
Merge pull request #71 from nikhilbadyal/invalid-buil
Invalid App for Building
This commit is contained in:
@@ -8,6 +8,7 @@ from src.config import RevancedConfig
|
|||||||
from src.downloader import Downloader
|
from src.downloader import Downloader
|
||||||
from src.parser import Parser
|
from src.parser import Parser
|
||||||
from src.patches import Patches
|
from src.patches import Patches
|
||||||
|
from src.utils import AppNotFound
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
@@ -25,35 +26,51 @@ def main() -> None:
|
|||||||
logger.info("Trying to build %s" % app)
|
logger.info("Trying to build %s" % app)
|
||||||
app_all_patches, version, is_experimental = patcher.get_app_configs(app)
|
app_all_patches, version, is_experimental = patcher.get_app_configs(app)
|
||||||
version = downloader.download_apk_to_patch(version, app)
|
version = downloader.download_apk_to_patch(version, app)
|
||||||
|
config.app_versions[app] = version
|
||||||
patcher.include_exclude_patch(app, parser, app_all_patches)
|
patcher.include_exclude_patch(app, parser, app_all_patches)
|
||||||
logger.info(f"Downloaded {app}, version {version}")
|
logger.info(f"Downloaded {app}, version {version}")
|
||||||
parser.patch_app(app=app, version=version, is_experimental=is_experimental)
|
parser.patch_app(app=app, version=version, is_experimental=is_experimental)
|
||||||
|
except AppNotFound as e:
|
||||||
|
logger.info(f"Invalid app requested to build {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.exception(f"Failed to build {app} because of {e}")
|
logger.exception(f"Failed to build {app} because of {e}")
|
||||||
if len(config.alternative_youtube_patches):
|
if len(config.alternative_youtube_patches) and "youtube" in config.apps:
|
||||||
for alternative_patch in config.alternative_youtube_patches:
|
for alternative_patch in config.alternative_youtube_patches:
|
||||||
logger.info(f"Rebuilding youtube with inverted ${alternative_patch} patch.")
|
|
||||||
_, version, is_experimental = patcher.get_app_configs("youtube")
|
_, version, is_experimental = patcher.get_app_configs("youtube")
|
||||||
parser.invert_patch(alternative_patch)
|
was_inverted = parser.invert_patch(alternative_patch)
|
||||||
parser.patch_app(
|
if was_inverted:
|
||||||
app="youtube",
|
logger.info(
|
||||||
version=version,
|
f"Rebuilding youtube with inverted {alternative_patch} patch."
|
||||||
is_experimental=is_experimental,
|
)
|
||||||
output_prefix="-" + alternative_patch + "-",
|
parser.patch_app(
|
||||||
)
|
app="youtube",
|
||||||
if len(config.alternative_youtube_music_patches):
|
version=config.app_versions.get("youtube", "latest"),
|
||||||
|
is_experimental=is_experimental,
|
||||||
|
output_prefix="-" + alternative_patch + "-",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f"Skipping Rebuilding youtube as {alternative_patch} patch was not found."
|
||||||
|
)
|
||||||
|
if len(config.alternative_youtube_music_patches) and "youtube_music" in config.apps:
|
||||||
for alternative_patch in config.alternative_youtube_music_patches:
|
for alternative_patch in config.alternative_youtube_music_patches:
|
||||||
logger.info(
|
|
||||||
f"Rebuilding youtube music with inverted ${alternative_patch} patch."
|
|
||||||
)
|
|
||||||
_, version, is_experimental = patcher.get_app_configs("youtube_music")
|
_, version, is_experimental = patcher.get_app_configs("youtube_music")
|
||||||
parser.invert_patch(alternative_patch)
|
was_inverted = parser.invert_patch(alternative_patch)
|
||||||
parser.patch_app(
|
if was_inverted:
|
||||||
app="youtube_music",
|
logger.info(
|
||||||
version=version,
|
f"Rebuilding youtube music with inverted {alternative_patch} patch."
|
||||||
is_experimental=is_experimental,
|
)
|
||||||
output_prefix="-" + alternative_patch + "-",
|
parser.patch_app(
|
||||||
)
|
app="youtube_music",
|
||||||
|
version=config.app_versions.get("youtube_music", "latest"),
|
||||||
|
is_experimental=is_experimental,
|
||||||
|
output_prefix="-" + alternative_patch + "-",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
f"Skipping Rebuilding youtube music as {alternative_patch} patch was not found."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
"""Revanced Configurations."""
|
"""Revanced Configurations."""
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import List
|
from typing import Dict, List
|
||||||
|
|
||||||
from environs import Env
|
from environs import Env
|
||||||
from requests import Session
|
from requests import Session
|
||||||
@@ -12,6 +12,7 @@ class RevancedConfig:
|
|||||||
"""Revanced Configurations."""
|
"""Revanced Configurations."""
|
||||||
|
|
||||||
def __init__(self, env: Env) -> None:
|
def __init__(self, env: Env) -> None:
|
||||||
|
self.app_versions: Dict[str, str] = {}
|
||||||
self.env = env
|
self.env = env
|
||||||
self.temp_folder = Path("apks")
|
self.temp_folder = Path("apks")
|
||||||
self.session = Session()
|
self.session = Session()
|
||||||
|
|||||||
+10
-6
@@ -49,16 +49,20 @@ class Parser(object):
|
|||||||
"""
|
"""
|
||||||
return self._PATCHES
|
return self._PATCHES
|
||||||
|
|
||||||
def invert_patch(self, name: str) -> None:
|
def invert_patch(self, name: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Getter to get all excluded patches
|
Getter to get all excluded patches
|
||||||
:return: List of excluded patches
|
:return: List of excluded patches
|
||||||
"""
|
"""
|
||||||
patch_index = self._PATCHES.index(name)
|
try:
|
||||||
if self._PATCHES[patch_index - 1] == "-e":
|
patch_index = self._PATCHES.index(name)
|
||||||
self._PATCHES[patch_index - 1] = "-i"
|
if self._PATCHES[patch_index - 1] == "-e":
|
||||||
else:
|
self._PATCHES[patch_index - 1] = "-i"
|
||||||
self._PATCHES[patch_index - 1] = "-e"
|
else:
|
||||||
|
self._PATCHES[patch_index - 1] = "-e"
|
||||||
|
return True
|
||||||
|
except ValueError:
|
||||||
|
return False
|
||||||
|
|
||||||
# noinspection IncorrectFormatting
|
# noinspection IncorrectFormatting
|
||||||
def patch_app(
|
def patch_app(
|
||||||
|
|||||||
+2
-3
@@ -1,12 +1,12 @@
|
|||||||
"""Revanced Patches."""
|
"""Revanced Patches."""
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, List, Tuple
|
||||||
|
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from requests import Session
|
from requests import Session
|
||||||
|
|
||||||
from src.config import RevancedConfig
|
from src.config import RevancedConfig
|
||||||
|
from src.utils import AppNotFound
|
||||||
|
|
||||||
|
|
||||||
class Patches(object):
|
class Patches(object):
|
||||||
@@ -118,8 +118,7 @@ class Patches(object):
|
|||||||
"nyx-music-player": "_nyx",
|
"nyx-music-player": "_nyx",
|
||||||
}
|
}
|
||||||
if not (app_name := app_names.get(app)):
|
if not (app_name := app_names.get(app)):
|
||||||
logger.debug("Invalid app name")
|
raise AppNotFound(app_name)
|
||||||
sys.exit(-1)
|
|
||||||
patches = getattr(self, app_name)
|
patches = getattr(self, app_name)
|
||||||
version = ""
|
version = ""
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -31,3 +31,9 @@ def update_changelog(name: str, response: Dict[str, str]) -> None:
|
|||||||
)
|
)
|
||||||
file1.write(change_log)
|
file1.write(change_log)
|
||||||
file1.close()
|
file1.close()
|
||||||
|
|
||||||
|
|
||||||
|
class AppNotFound(ValueError):
|
||||||
|
"""Not a valid Revanced App."""
|
||||||
|
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user