♻️ Modularized downloader

This commit is contained in:
Nikhil Badyal
2023-07-02 17:51:26 +05:30
parent ad973926aa
commit 711e2d8c3c
10 changed files with 412 additions and 346 deletions
+33
View File
@@ -0,0 +1,33 @@
"""Downloader Factory."""
from src.config import RevancedConfig
from src.downloader.apkmirror import ApkMirror
from src.downloader.apkpure import ApkPure
from src.downloader.apksos import ApkSos
from src.downloader.download import Downloader
from src.downloader.uptodown import UptoDown
from src.patches import Patches
class DownloaderFactory(object):
"""Downloader Factory."""
@staticmethod
def create_downloader(
app: str, patcher: Patches, config: RevancedConfig
) -> Downloader:
"""Returns appropriate downloader.
Parameters
----------
app : App Name
patcher : Patcher
config : Config
"""
if app in config.apk_pure:
return ApkPure(patcher, config)
elif app in config.apk_sos:
return ApkSos(patcher, config)
elif app in config.upto_down:
return UptoDown(patcher, config)
else:
return ApkMirror(patcher, config)