mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🌱 Updated linter
This commit is contained in:
committed by
Nikhil Badyal
parent
e533912ccf
commit
1366c6c663
@@ -1,5 +1,5 @@
|
||||
"""Downloader Class."""
|
||||
from typing import Any, Dict, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup, Tag
|
||||
@@ -15,7 +15,7 @@ from src.utils import bs4_parser, contains_any_word, handle_request_response, re
|
||||
class ApkMirror(Downloader):
|
||||
"""Files 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."""
|
||||
notes_divs = self._extracted_search_div(link, "tab-pane")
|
||||
apk_type = self._extracted_search_div(link, "apkm-badge").get_text()
|
||||
@@ -29,7 +29,7 @@ class ApkMirror(Downloader):
|
||||
msg = f"Unable to extract force download for {app}"
|
||||
raise APKMirrorAPKDownloadError(msg, url=link)
|
||||
|
||||
def extract_download_link(self: 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
|
||||
@@ -58,7 +58,7 @@ class ApkMirror(Downloader):
|
||||
"""
|
||||
list_widget = self._extracted_search_div(main_page, "listWidget")
|
||||
table_rows = list_widget.find_all(class_="table-row")
|
||||
links: Dict[str, str] = {}
|
||||
links: dict[str, str] = {}
|
||||
apk_archs = ["arm64-v8a", "universal", "noarch"]
|
||||
for row in table_rows:
|
||||
if row.find(class_="accent_color"):
|
||||
@@ -81,7 +81,7 @@ class ApkMirror(Downloader):
|
||||
soup = BeautifulSoup(r.text, bs4_parser)
|
||||
return soup.find(class_=search_class) # type: ignore[return-value]
|
||||
|
||||
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.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -97,7 +97,7 @@ class ApkMirror(Downloader):
|
||||
download_page = self.get_download_page(main_page)
|
||||
return self.extract_download_link(download_page, app.app_name)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""APK Monk Downloader Class."""
|
||||
import re
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -16,7 +16,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
||||
class ApkMonk(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def extract_download_link(self: 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 apkmonk html page.
|
||||
|
||||
:param page: Url of the page
|
||||
@@ -48,7 +48,7 @@ class ApkMonk(Downloader):
|
||||
self._download(final_download_url, file_name)
|
||||
return file_name, final_download_url
|
||||
|
||||
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.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -73,7 +73,7 @@ class ApkMonk(Downloader):
|
||||
url=app.download_source,
|
||||
)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||
"""Function to download whatever the latest version of app from apkmonkP.
|
||||
|
||||
:param app: Name of the application
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""APK Pure Downloader Class."""
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
from src.app import APP
|
||||
from src.downloader.download import Downloader
|
||||
@@ -8,7 +8,7 @@ from src.downloader.download import Downloader
|
||||
class ApkPure(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
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
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""APK SOS Downloader Class."""
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -13,7 +13,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
||||
class ApkSos(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def extract_download_link(self: 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
|
||||
@@ -32,7 +32,7 @@ class ApkSos(Downloader):
|
||||
msg = f"Unable to download {app}"
|
||||
raise APKSosAPKDownloadError(msg, url=page)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
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
|
||||
|
||||
@@ -4,7 +4,7 @@ import subprocess
|
||||
from pathlib import Path
|
||||
from queue import PriorityQueue
|
||||
from time import perf_counter
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
from loguru import logger
|
||||
from tqdm import tqdm
|
||||
@@ -21,7 +21,7 @@ class Downloader(object):
|
||||
|
||||
def __init__(self: Self, config: RevancedConfig) -> None:
|
||||
self._CHUNK_SIZE = 10485760
|
||||
self._QUEUE: PriorityQueue[Tuple[float, str]] = PriorityQueue()
|
||||
self._QUEUE: PriorityQueue[tuple[float, str]] = PriorityQueue()
|
||||
self._QUEUE_LENGTH = 0
|
||||
self.config = config
|
||||
|
||||
@@ -61,11 +61,11 @@ class Downloader(object):
|
||||
self._QUEUE.put((perf_counter() - start, file_name))
|
||||
logger.debug(f"Downloaded {file_name}")
|
||||
|
||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
||||
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||
"""Extract download link from web page."""
|
||||
raise NotImplementedError(implement_method)
|
||||
|
||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
||||
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||
"""Function to download the specified version of app from apkmirror.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -74,7 +74,7 @@ class Downloader(object):
|
||||
"""
|
||||
raise NotImplementedError(implement_method)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||
"""Function to download the latest version of app.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -112,7 +112,7 @@ class Downloader(object):
|
||||
base_name, _ = os.path.splitext(filename)
|
||||
return base_name + new_extension
|
||||
|
||||
def download(self: Self, version: str, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
def download(self: Self, version: str, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||
"""Public function to download apk to patch.
|
||||
|
||||
:param version: version to download
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Github Downloader."""
|
||||
import re
|
||||
from typing import Dict, Self, Tuple
|
||||
from typing import Self
|
||||
from urllib.parse import urlparse
|
||||
|
||||
import requests
|
||||
@@ -16,7 +16,7 @@ from src.utils import handle_request_response, request_timeout, update_changelog
|
||||
class Github(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Dict[str, str]) -> Tuple[str, str]:
|
||||
def latest_version(self: Self, app: APP, **kwargs: dict[str, str]) -> tuple[str, str]:
|
||||
"""Function to download files from GitHub repositories.
|
||||
|
||||
:param app: App to download
|
||||
@@ -45,7 +45,7 @@ class Github(Downloader):
|
||||
return app.app_name, download_url
|
||||
|
||||
@staticmethod
|
||||
def _extract_repo_owner_and_tag(url: str) -> Tuple[str, str, str]:
|
||||
def _extract_repo_owner_and_tag(url: str) -> tuple[str, str, str]:
|
||||
"""Extract repo owner and url from github url."""
|
||||
parsed_url = urlparse(url)
|
||||
path_segments = parsed_url.path.strip("/").split("/")
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Google Drive downloader Class."""
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
import gdown
|
||||
|
||||
@@ -10,7 +10,7 @@ from src.downloader.download import Downloader
|
||||
class GoogleDrive(Downloader):
|
||||
"""Google Driver downloader."""
|
||||
|
||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
||||
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||
"""Function to download the specified version of app from apkmirror.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -19,7 +19,7 @@ class GoogleDrive(Downloader):
|
||||
"""
|
||||
return self.latest_version(app)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||
"""Function to download whatever the latest version of app from Google Driver.
|
||||
|
||||
:param app: Name of the application
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
"""Upto Down Downloader."""
|
||||
from typing import Any, Self, Tuple
|
||||
from typing import Any, Self
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
@@ -14,7 +14,7 @@ from src.utils import bs4_parser, handle_request_response, request_header, reque
|
||||
class UptoDown(Downloader):
|
||||
"""Files downloader."""
|
||||
|
||||
def extract_download_link(self: Self, page: str, app: str) -> Tuple[str, str]:
|
||||
def extract_download_link(self: Self, page: str, app: str) -> tuple[str, str]:
|
||||
"""Extract download link from uptodown url."""
|
||||
r = requests.get(page, headers=request_header, allow_redirects=True, timeout=request_timeout)
|
||||
handle_request_response(r, page)
|
||||
@@ -34,7 +34,7 @@ class UptoDown(Downloader):
|
||||
msg = f"Unable to download {app} from uptodown."
|
||||
raise UptoDownAPKDownloadError(msg, url=page)
|
||||
|
||||
def specific_version(self: Self, app: APP, version: str) -> Tuple[str, str]:
|
||||
def specific_version(self: Self, app: APP, version: str) -> tuple[str, str]:
|
||||
"""Function to download the specified version of app from apkmirror.
|
||||
|
||||
:param app: Name of the application
|
||||
@@ -57,7 +57,7 @@ class UptoDown(Downloader):
|
||||
raise UptoDownAPKDownloadError(msg, url=url)
|
||||
return self.extract_download_link(download_url, app.app_name)
|
||||
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> Tuple[str, str]:
|
||||
def latest_version(self: Self, app: APP, **kwargs: Any) -> tuple[str, str]:
|
||||
"""Function to download the latest version of app from uptodown."""
|
||||
logger.debug("downloading latest version of app from uptodown.")
|
||||
page = f"{app.download_source}/download"
|
||||
|
||||
Reference in New Issue
Block a user