From 55bffcf84ea83567c84aa4711983ca358c736957 Mon Sep 17 00:00:00 2001 From: Nikhil Badyal <59223300+nikhilbadyal@users.noreply.github.com> Date: Tue, 29 Aug 2023 14:30:09 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=BD=EF=B8=8F=20Updated=20Revanced=20AP?= =?UTF-8?q?I=20(#353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/status_check.py | 5 ++++- src/downloader/sources.py | 2 +- src/exceptions.py | 14 +++++++++----- src/utils.py | 4 ++-- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/status_check.py b/scripts/status_check.py index 49b3c0e..64c1959 100644 --- a/scripts/status_check.py +++ b/scripts/status_check.py @@ -25,6 +25,7 @@ from src.exceptions import ( APKMonkIconScrapError, APKPureIconScrapError, BuilderError, + ScrapingError, ) from src.patches import Patches from src.utils import apkmirror_status_check, bs4_parser, handle_request_response, request_header, request_timeout @@ -161,6 +162,8 @@ def icon_scrapper(package_name: str) -> str: return str(globals()[scraper_name](package_name)) except error_type: pass + except ScrapingError: + pass return not_found_icon @@ -189,7 +192,7 @@ def main() -> None: response = requests.get(revanced_api, timeout=request_timeout) handle_request_response(response, revanced_api) - patches = response.json() + patches = response.json()["patches"] possible_apps = set() for patch in patches: diff --git a/src/downloader/sources.py b/src/downloader/sources.py index 2bedf5e..709345c 100644 --- a/src/downloader/sources.py +++ b/src/downloader/sources.py @@ -16,7 +16,7 @@ PLAY_STORE_APK_URL = f"{PLAY_STORE_BASE_URL}/store/apps/details?id=" + "{}" APK_COMBO_BASE_URL = "https://apkcombo.com" APK_COMBO_GENERIC_URL = APK_COMBO_BASE_URL + "/genericApp/{}" not_found_icon = "https://img.icons8.com/bubbles/500/android-os.png" -revanced_api = "https://releases.revanced.app/patches" +revanced_api = "https://api.revanced.app/v2/patches/latest" APK_MONK_BASE_URL = "https://www.apkmonk.com" APK_MONK_APK_URL = APK_MONK_BASE_URL + "/app/{}/" APK_MONK_ICON_URL = "https://cdn.apkmonk.com/logos/{}" diff --git a/src/exceptions.py b/src/exceptions.py index 16fdc1b..de93103 100644 --- a/src/exceptions.py +++ b/src/exceptions.py @@ -17,8 +17,8 @@ class BuilderError(Exception): return self.message -class APKMirrorIconScrapError(BuilderError): - """Exception raised when the icon cannot be scraped from apkmirror.""" +class ScrapingError(BuilderError): + """Exception raised when the url cannot be scraped.""" def __init__(self: Self, *args: Any, **kwargs: Any) -> None: """Initialize the APKMirrorIconScrapFailure exception. @@ -33,15 +33,19 @@ class APKMirrorIconScrapError(BuilderError): self.url = kwargs.get("url", None) -class APKComboIconScrapError(APKMirrorIconScrapError): +class APKMirrorIconScrapError(ScrapingError): + """Exception raised when the icon cannot be scraped from apkmirror.""" + + +class APKComboIconScrapError(ScrapingError): """Exception raised when the icon cannot be scraped from apkcombo.""" -class APKPureIconScrapError(APKMirrorIconScrapError): +class APKPureIconScrapError(ScrapingError): """Exception raised when the icon cannot be scraped from apkpure.""" -class APKMonkIconScrapError(APKMirrorIconScrapError): +class APKMonkIconScrapError(ScrapingError): """Exception raised when the icon cannot be scraped from apkmonk.""" diff --git a/src/utils.py b/src/utils.py index 9b52c54..86654b6 100644 --- a/src/utils.py +++ b/src/utils.py @@ -13,7 +13,7 @@ from requests import Response from src.config import RevancedConfig from src.downloader.sources import APK_MIRROR_APK_CHECK from src.downloader.utils import status_code_200 -from src.exceptions import DownloadError +from src.exceptions import ScrapingError default_build = [ "youtube", @@ -115,7 +115,7 @@ def handle_request_response(response: Response, url: str) -> None: response_code = response.status_code if response_code != status_code_200: msg = f"Unable to downloaded assets. Reason - {response.text}" - raise DownloadError(msg, url=url) + raise ScrapingError(msg, url=url) def slugify(string: str) -> str: