mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Chore (#289)
This commit is contained in:
+3
-1
@@ -12,6 +12,8 @@ default_integrations = (
|
||||
"https://github.com/revanced/revanced-integrations/releases/latest"
|
||||
)
|
||||
|
||||
APK_MIRROR_BASE_URL = "https://www.apkmirror.com"
|
||||
|
||||
|
||||
class RevancedConfig(object):
|
||||
"""Revanced Configurations."""
|
||||
@@ -23,7 +25,7 @@ class RevancedConfig(object):
|
||||
self.temp_folder = Path("apks")
|
||||
self.session = Session()
|
||||
self.session.headers["User-Agent"] = "anything"
|
||||
self.apk_mirror = "https://www.apkmirror.com"
|
||||
self.apk_mirror = APK_MIRROR_BASE_URL
|
||||
self.upto_down = {
|
||||
"spotify": "spotify",
|
||||
"nyx-music-player": "nyx-music-player",
|
||||
|
||||
+15
-3
@@ -1,7 +1,19 @@
|
||||
class APKMirrorScrapperFailure(Exception):
|
||||
"""Failed to scrap icon from apkmirror."""
|
||||
from typing import Any
|
||||
|
||||
pass
|
||||
|
||||
class APKMirrorIconScrapFailure(Exception):
|
||||
"""Exception raised when the icon cannot be scraped from apkmirror."""
|
||||
|
||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||
"""Initialize the APKMirrorIconScrapFailure exception.
|
||||
|
||||
Args:
|
||||
*args: Variable length argument list.
|
||||
**kwargs: Arbitrary keyword arguments.
|
||||
url (str, optional): The URL of the failed icon scraping. Defaults to None.
|
||||
"""
|
||||
super().__init__(*args)
|
||||
self.url = kwargs.get("url", None)
|
||||
|
||||
|
||||
class PatchingFailed(Exception):
|
||||
|
||||
+2
-1
@@ -113,7 +113,8 @@ class Patches(object):
|
||||
app_names = {value[0]: value[1] for value in self.revanced_app_ids.values()}
|
||||
|
||||
if not (app_name := app_names.get(app)):
|
||||
raise AppNotFound(app)
|
||||
raise AppNotFound(f"App '{app}' not found in the supported apps.")
|
||||
|
||||
patches = getattr(self, app_name)
|
||||
version = "latest"
|
||||
with contextlib.suppress(StopIteration):
|
||||
|
||||
+49
-27
@@ -1,5 +1,4 @@
|
||||
"""Utilities."""
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
@@ -28,27 +27,46 @@ bs4_parser = "html.parser"
|
||||
|
||||
def update_changelog(name: str, response: Dict[str, str]) -> None:
|
||||
"""Updated Changelog."""
|
||||
parent_repo = "https://github.com/nikhilbadyal/docker-py-revanced"
|
||||
with open("changelog.md", "a", encoding="utf_8") as file1:
|
||||
collapse_start = f"\n<details> <summary>👀 {name} </summary>\n\n"
|
||||
release_version = f"**Release Version** - [{response['tag_name']}]({response['html_url']})<br>"
|
||||
change_log = f"**Changelog** -<br> {response['body']}"
|
||||
publish_time = f"**Published at** -<br> {response['published_at']}"
|
||||
footer = f"<br><sub>Change logs generated by [Docker Py Revanced]({parent_repo})</sub>\n"
|
||||
collapse_end = "</details>"
|
||||
change_log = "".join(
|
||||
[
|
||||
collapse_start,
|
||||
release_version,
|
||||
change_log,
|
||||
publish_time,
|
||||
footer,
|
||||
collapse_end,
|
||||
]
|
||||
)
|
||||
parent_repo = get_parent_repo()
|
||||
change_log = format_changelog(name, response, parent_repo)
|
||||
write_to_file(change_log)
|
||||
|
||||
|
||||
def format_changelog(name: str, response: Dict[str, str], parent_repo: str) -> str:
|
||||
"""Format changelog."""
|
||||
collapse_start = f"\n<details> <summary>👀 {name} </summary>\n\n"
|
||||
release_version = (
|
||||
f"**Release Version** - [{response['tag_name']}]({response['html_url']})<br>"
|
||||
)
|
||||
change_log = f"**Changelog** -<br> {response['body']}"
|
||||
publish_time = f"**Published at** -<br> {response['published_at']}"
|
||||
footer = (
|
||||
f"<br><sub>Change logs generated by [Docker Py Revanced]({parent_repo})</sub>\n"
|
||||
)
|
||||
collapse_end = "</details>"
|
||||
return "".join(
|
||||
[
|
||||
collapse_start,
|
||||
release_version,
|
||||
change_log,
|
||||
publish_time,
|
||||
footer,
|
||||
collapse_end,
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def write_to_file(change_log: str) -> None:
|
||||
"""Write changelog to file."""
|
||||
with open("changelog.md", "w", encoding="utf_8") as file1:
|
||||
file1.write(change_log)
|
||||
|
||||
|
||||
def get_parent_repo() -> str:
|
||||
"""Get parent repository URL from configuration file."""
|
||||
return "https://github.com/nikhilbadyal/docker-py-revanced"
|
||||
|
||||
|
||||
def handle_github_response(response: Response) -> None:
|
||||
"""Handle Get Request Response."""
|
||||
response_code = response.status_code
|
||||
@@ -93,7 +111,7 @@ def check_java(dry_run: bool) -> None:
|
||||
raise subprocess.CalledProcessError(-1, "java -version")
|
||||
logger.debug("Cool!! Java is available")
|
||||
except subprocess.CalledProcessError:
|
||||
logger.error("Java>= 17 Must be installed")
|
||||
logger.error("Java>= 17 must be installed")
|
||||
exit(-1)
|
||||
|
||||
|
||||
@@ -119,11 +137,15 @@ def extra_downloads(config: RevancedConfig) -> None:
|
||||
|
||||
|
||||
def apkmirror_status_check(package_name: str) -> Any:
|
||||
"""Check if app exists on APKMirror."""
|
||||
check_if_exist = f"{apk_mirror_base_url}/wp-json/apkm/v1/app_exists/"
|
||||
"""Check if app exists on APKMirror.
|
||||
|
||||
Args:
|
||||
package_name (str): The name of the package to check.
|
||||
|
||||
Returns:
|
||||
dict: The response from APKMirror API as a JSON object.
|
||||
"""
|
||||
api_url = f"{apk_mirror_base_url}/wp-json/apkm/v1/app_exists/"
|
||||
body = {"pnames": [package_name]}
|
||||
return json.loads(
|
||||
requests.post(
|
||||
check_if_exist, data=json.dumps(body), headers=apk_mirror_header
|
||||
).content
|
||||
)
|
||||
response = requests.post(api_url, json=body, headers=apk_mirror_header)
|
||||
return response.json()
|
||||
|
||||
Reference in New Issue
Block a user