mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
fix(apkmirror): Extract source instead to reuse in extracting divs
This commit is contained in:
@@ -18,8 +18,9 @@ class ApkMirror(Downloader):
|
|||||||
|
|
||||||
def _extract_force_download_link(self: Self, link: str, app: str) -> tuple[str, str]:
|
def _extract_force_download_link(self: Self, link: str, app: str) -> tuple[str, str]:
|
||||||
"""Extract force download link."""
|
"""Extract force download link."""
|
||||||
notes_divs = self._extracted_search_div(link, "tab-pane")
|
link_page_source = self._extract_source(link)
|
||||||
apk_type = self._extracted_search_div(link, "apkm-badge").get_text()
|
notes_divs = self._extracted_search_source_div(link_page_source, "tab-pane")
|
||||||
|
apk_type = self._extracted_search_source_div(link_page_source, "apkm-badge").get_text()
|
||||||
extension = "zip" if apk_type == "BUNDLE" else "apk"
|
extension = "zip" if apk_type == "BUNDLE" else "apk"
|
||||||
possible_links = notes_divs.find_all("a")
|
possible_links = notes_divs.find_all("a")
|
||||||
for possible_link in possible_links:
|
for possible_link in possible_links:
|
||||||
@@ -75,13 +76,22 @@ class ApkMirror(Downloader):
|
|||||||
raise APKMirrorAPKDownloadError(msg, url=main_page)
|
raise APKMirrorAPKDownloadError(msg, url=main_page)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extracted_search_div(url: str, search_class: str) -> Tag:
|
def _extract_source(url: str) -> str:
|
||||||
"""Extract search div."""
|
"""Extracts the source from the url incase of reuse."""
|
||||||
r = requests.get(url, headers=request_header, timeout=request_timeout)
|
response = requests.get(url, headers=request_header, timeout=request_timeout)
|
||||||
handle_request_response(r, url)
|
handle_request_response(response, url)
|
||||||
soup = BeautifulSoup(r.text, bs4_parser)
|
return response.text
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _extracted_search_source_div(source: str, search_class: str) -> Tag:
|
||||||
|
"""Extract search div from source."""
|
||||||
|
soup = BeautifulSoup(source, bs4_parser)
|
||||||
return soup.find(class_=search_class) # type: ignore[return-value]
|
return soup.find(class_=search_class) # type: ignore[return-value]
|
||||||
|
|
||||||
|
def _extracted_search_div(self: Self, url: str, search_class: str) -> Tag:
|
||||||
|
"""Extract search div from url."""
|
||||||
|
return self._extracted_search_source_div(self._extract_source(url), search_class)
|
||||||
|
|
||||||
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> tuple[str, str]:
|
def specific_version(self: Self, app: APP, version: str, main_page: str = "") -> tuple[str, str]:
|
||||||
"""Function to download the specified version of app from apkmirror.
|
"""Function to download the specified version of app from apkmirror.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user