mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🚨 Updated lints (#308)
This commit is contained in:
@@ -1,38 +1,38 @@
|
||||
"""APK SOS Downloader Class."""
|
||||
from typing import Any, Tuple
|
||||
from typing import Any, Self, Tuple
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from src.app import APP
|
||||
from src.downloader.download import Downloader
|
||||
from src.exceptions import APKSosAPKDownloadFailure
|
||||
from src.exceptions import APKSosAPKDownloadError
|
||||
from src.utils import bs4_parser, request_header
|
||||
|
||||
|
||||
class ApkSos(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def extract_download_link(self, page: str, app: str) -> Tuple[str, str]:
|
||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
||||
"""Function to extract the download link from apkmirror html page.
|
||||
|
||||
:param page: Url of the page
|
||||
:param app: Name of the app
|
||||
"""
|
||||
r = requests.get(page, headers=request_header, allow_redirects=True)
|
||||
r = requests.get(page, headers=request_header, allow_redirects=True, timeout=60)
|
||||
soup = BeautifulSoup(r.text, bs4_parser)
|
||||
download_button = soup.find(class_="col-sm-12 col-md-8 text-center")
|
||||
possible_links = download_button.find_all("a")
|
||||
possible_links = download_button.find_all("a") # type: ignore[union-attr]
|
||||
for possible_link in possible_links:
|
||||
if possible_link.get("href"):
|
||||
file_name = f"{app}.apk"
|
||||
self._download(possible_link["href"], file_name)
|
||||
return file_name, possible_link["href"]
|
||||
raise APKSosAPKDownloadFailure(f"Unable to download {app}", url=page)
|
||||
msg = f"Unable to download {app}"
|
||||
raise APKSosAPKDownloadError(msg, url=page)
|
||||
|
||||
def latest_version(self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
"""Function to download whatever the latest version of app from
|
||||
apkmirror.
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
"""Function to download whatever the latest version of app from apkmirror.
|
||||
|
||||
:param app: Name of the application
|
||||
:return: Version of downloaded apk
|
||||
|
||||
Reference in New Issue
Block a user