🎨 Updated function name

This commit is contained in:
Nikhil Badyal
2023-08-22 16:52:33 +05:30
parent 70dbea76c9
commit f1873a2f85
4 changed files with 9 additions and 11 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ from src.utils import (
apk_mirror_base_url, apk_mirror_base_url,
apkmirror_status_check, apkmirror_status_check,
bs4_parser, bs4_parser,
handle_github_response, handle_request_response,
) )
not_found_icon = "https://img.icons8.com/bubbles/500/android-os.png" not_found_icon = "https://img.icons8.com/bubbles/500/android-os.png"
@@ -103,7 +103,7 @@ def generate_markdown_table(data: List[List[str]]) -> str:
def main() -> None: def main() -> None:
repo_url = "https://releases.revanced.app/patches" repo_url = "https://releases.revanced.app/patches"
response = requests.get(repo_url, timeout=10) response = requests.get(repo_url, timeout=10)
handle_github_response(response) handle_request_response(response)
patches = response.json() patches = response.json()
+2 -2
View File
@@ -13,7 +13,7 @@ from src.config import RevancedConfig
from src.downloader.utils import implement_method from src.downloader.utils import implement_method
from src.exceptions import DownloadFailure from src.exceptions import DownloadFailure
from src.patches import Patches from src.patches import Patches
from src.utils import handle_github_response from src.utils import handle_request_response
class Downloader(object): class Downloader(object):
@@ -55,7 +55,7 @@ class Downloader(object):
stream=True, stream=True,
headers=headers, headers=headers,
) )
handle_github_response(response) handle_request_response(response)
total = int(response.headers.get("content-length", 0)) total = int(response.headers.get("content-length", 0))
bar = tqdm( bar = tqdm(
desc=file_name, desc=file_name,
+3 -3
View File
@@ -9,7 +9,7 @@ from loguru import logger
from src.config import RevancedConfig from src.config import RevancedConfig
from src.downloader.download import Downloader from src.downloader.download import Downloader
from src.exceptions import DownloadFailure from src.exceptions import DownloadFailure
from src.utils import handle_github_response, update_changelog from src.utils import handle_request_response, update_changelog
class Github(Downloader): class Github(Downloader):
@@ -36,7 +36,7 @@ class Github(Downloader):
logger.debug("Using personal access token") logger.debug("Using personal access token")
headers["Authorization"] = f"token {self.config.personal_access_token}" headers["Authorization"] = f"token {self.config.personal_access_token}"
response = requests.get(repo_url, headers=headers, timeout=60) response = requests.get(repo_url, headers=headers, timeout=60)
handle_github_response(response) handle_request_response(response)
if repo_name == "revanced-patches": if repo_name == "revanced-patches":
download_url = response.json()["assets"][1]["browser_download_url"] download_url = response.json()["assets"][1]["browser_download_url"]
else: else:
@@ -80,7 +80,7 @@ class Github(Downloader):
if config.personal_access_token: if config.personal_access_token:
headers["Authorization"] = f"token {config.personal_access_token}" headers["Authorization"] = f"token {config.personal_access_token}"
response = requests.get(api_url, headers=headers, timeout=60) response = requests.get(api_url, headers=headers, timeout=60)
handle_github_response(response) handle_request_response(response)
assets = response.json()["assets"] assets = response.json()["assets"]
try: try:
filter_pattern = re.compile(asset_filter) filter_pattern = re.compile(asset_filter)
+2 -4
View File
@@ -67,13 +67,11 @@ def get_parent_repo() -> str:
return "https://github.com/nikhilbadyal/docker-py-revanced" return "https://github.com/nikhilbadyal/docker-py-revanced"
def handle_github_response(response: Response) -> None: def handle_request_response(response: Response) -> None:
"""Handle Get Request Response.""" """Handle Get Request Response."""
response_code = response.status_code response_code = response.status_code
if response_code != 200: if response_code != 200:
raise DownloadFailure( raise DownloadFailure(f"Unable to downloaded assets. Reason - {response.text}")
f"Unable to downloaded assets from GitHub. Reason - {response.text}"
)
def slugify(string: str) -> str: def slugify(string: str) -> str: