mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
🎨 Removed patcher from downloader arguments [skip ci]
This commit is contained in:
@@ -32,7 +32,7 @@ def main() -> None:
|
||||
app_all_patches = patcher.get_app_configs(app)
|
||||
patcher.include_exclude_patch(app, parser, app_all_patches)
|
||||
downloader = DownloaderFactory.create_downloader(
|
||||
app=app.app_name, patcher=patcher, config=config
|
||||
app=app.app_name, config=config
|
||||
)
|
||||
app.download_file_name, app.download_dl = downloader.download(
|
||||
app.app_version, app.app_name
|
||||
|
||||
+1
-1
@@ -113,7 +113,7 @@ class APP(object):
|
||||
if not file_name:
|
||||
extension = pathlib.Path(url).suffix
|
||||
file_name = APP.generate_filename(url) + extension
|
||||
Downloader(None, config).direct_download(url, file_name) # type: ignore
|
||||
Downloader(config).direct_download(url, file_name)
|
||||
return file_name
|
||||
|
||||
def download_patch_resources(self, config: RevancedConfig) -> None:
|
||||
|
||||
@@ -7,6 +7,7 @@ from bs4 import BeautifulSoup
|
||||
from src.downloader.download import Downloader
|
||||
from src.downloader.sources import apk_sources
|
||||
from src.exceptions import APKSosAPKDownloadFailure
|
||||
from src.patches import Patches
|
||||
from src.utils import bs4_parser, request_header
|
||||
|
||||
|
||||
@@ -37,6 +38,6 @@ class ApkSos(Downloader):
|
||||
:param app: Name of the application
|
||||
:return: Version of downloaded apk
|
||||
"""
|
||||
package_name = self.patcher.get_package_name(app)
|
||||
package_name = Patches.get_package_name(app)
|
||||
download_url = apk_sources[app].format(package_name)
|
||||
return self.extract_download_link(download_url, app)
|
||||
|
||||
@@ -12,19 +12,17 @@ from tqdm import tqdm
|
||||
from src.config import RevancedConfig
|
||||
from src.downloader.utils import implement_method
|
||||
from src.exceptions import DownloadFailure
|
||||
from src.patches import Patches
|
||||
from src.utils import handle_request_response
|
||||
|
||||
|
||||
class Downloader(object):
|
||||
"""Files downloader."""
|
||||
|
||||
def __init__(self, patcher: Patches, config: RevancedConfig):
|
||||
def __init__(self, config: RevancedConfig):
|
||||
self._CHUNK_SIZE = 10485760
|
||||
self._QUEUE: PriorityQueue[Tuple[float, str]] = PriorityQueue()
|
||||
self._QUEUE_LENGTH = 0
|
||||
self.config = config
|
||||
self.patcher = patcher
|
||||
|
||||
@staticmethod
|
||||
def file_status_check(file_name: Path, dry_run: bool, url: str) -> bool:
|
||||
|
||||
@@ -14,32 +14,28 @@ from src.downloader.sources import (
|
||||
)
|
||||
from src.downloader.uptodown import UptoDown
|
||||
from src.exceptions import DownloadFailure
|
||||
from src.patches import Patches
|
||||
|
||||
|
||||
class DownloaderFactory(object):
|
||||
"""Downloader Factory."""
|
||||
|
||||
@staticmethod
|
||||
def create_downloader(
|
||||
app: str, patcher: Patches, config: RevancedConfig
|
||||
) -> Downloader:
|
||||
def create_downloader(app: str, config: RevancedConfig) -> Downloader:
|
||||
"""Returns appropriate downloader.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
app : App Name
|
||||
patcher : Patcher
|
||||
config : Config
|
||||
"""
|
||||
if apk_sources[app].startswith(GITHUB_BASE_URL):
|
||||
return Github(patcher, config)
|
||||
return Github(config)
|
||||
if apk_sources[app].startswith(APK_PURE_URL):
|
||||
return ApkPure(patcher, config)
|
||||
return ApkPure(config)
|
||||
elif apk_sources[app].startswith(APK_SOS_URL):
|
||||
return ApkSos(patcher, config)
|
||||
return ApkSos(config)
|
||||
elif apk_sources[app].endswith("en.uptodown.com/android"):
|
||||
return UptoDown(patcher, config)
|
||||
return UptoDown(config)
|
||||
elif apk_sources[app].startswith(APK_MIRROR_BASE_URL):
|
||||
return ApkMirror(patcher, config)
|
||||
return ApkMirror(config)
|
||||
raise DownloadFailure(f"No download factory found for {app}")
|
||||
|
||||
Reference in New Issue
Block a user