diff --git a/README.md b/README.md index b66d48b..9656173 100644 --- a/README.md +++ b/README.md @@ -225,6 +225,9 @@ You can use any of the following methods to build. 5. APKMonk - Supports downloading any available version 1. Link Format - https://www.apkmonk.com/app// 2. Example Link - https://www.apkmonk.com/app// + 6. Google Drive - Supports downloading from Google Drive lint + 1. Link Format - https://drive.google.com/uc? + 2. Example Link - https://drive.google.com/uc?id=1ad44UTghbDty8o36Nrp3ZMyUzkPckIqY
Please verify the source of original APKs yourself with links provided. I'm not responsible for any damage caused.If you know any better/safe source to download clean. Open a discussion. diff --git a/pyproject.toml b/pyproject.toml index f44411c..9cdf4b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -52,7 +52,8 @@ ignore = [ "PTH122", #os-path-splitext "TRY301", #raise-within-try "PERF203", #try-except-in-loop - "UP004" #useless-object-inheritance + "UP004", #useless-object-inheritance + "PLR0911" #too many returns ] fix = true show-fixes = true diff --git a/requirements.txt b/requirements.txt index 86038d9..bc60778 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ beautifulsoup4==4.12.2 environs==9.5.0 +gdown @ git+https://github.com/nikhilbadyal/gdown google-play-scraper==1.2.4 lastversion==3.0.1 loguru==0.7.0 diff --git a/src/config.py b/src/config.py index 9bc56a9..2b024b5 100644 --- a/src/config.py +++ b/src/config.py @@ -16,10 +16,10 @@ class RevancedConfig(object): def __init__(self: Self, env: Env) -> None: self.env = env - self.temp_folder = Path("apks") + self.temp_folder_name = "apks" + self.temp_folder = Path(self.temp_folder_name) self.session = Session() self.ci_test = env.bool("CI_TEST", False) - self.rip_libs_apps: List[str] = [] self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", []) self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None) diff --git a/src/downloader/factory.py b/src/downloader/factory.py index d1c0a97..39e9b0c 100644 --- a/src/downloader/factory.py +++ b/src/downloader/factory.py @@ -6,11 +6,13 @@ from src.downloader.apkpure import ApkPure from src.downloader.apksos import ApkSos from src.downloader.download import Downloader from src.downloader.github import Github +from src.downloader.google_drive import GoogleDrive from src.downloader.sources import ( APK_MIRROR_BASE_URL, APK_MONK_BASE_URL, APK_PURE_BASE_URL, APKS_SOS_BASE_URL, + DRIVE_DOWNLOAD_BASE_URL, GITHUB_BASE_URL, ) from src.downloader.uptodown import UptoDown @@ -41,5 +43,7 @@ class DownloaderFactory(object): return ApkMirror(config) if apk_source.startswith(APK_MONK_BASE_URL): return ApkMonk(config) + if apk_source.startswith(DRIVE_DOWNLOAD_BASE_URL): + return GoogleDrive(config) msg = "No download factory found." - raise DownloadError(msg) + raise DownloadError(msg, url=apk_source) diff --git a/src/downloader/google_drive.py b/src/downloader/google_drive.py new file mode 100644 index 0000000..37ff4f6 --- /dev/null +++ b/src/downloader/google_drive.py @@ -0,0 +1,31 @@ +"""Google Drive downloader Class.""" +from typing import Any, Self, Tuple + +import gdown + +from src.app import APP +from src.downloader.download import Downloader + + +class GoogleDrive(Downloader): + """Google Driver downloader.""" + + 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 + :param version: Version of the application to download + :return: Version of downloaded apk + """ + return self.latest_version(app) + + 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 + :return: Version of downloaded apk + """ + url = app.download_source + file_name = f"{self.config.temp_folder_name}/{app.app_name}.apk" + _, download_url = gdown.download(url, quiet=False, use_cookies=False, output=file_name) + return file_name, download_url diff --git a/src/downloader/sources.py b/src/downloader/sources.py index 709345c..770dc06 100644 --- a/src/downloader/sources.py +++ b/src/downloader/sources.py @@ -1,4 +1,5 @@ """APK Sources used.""" + APK_MIRROR_BASE_URL = "https://www.apkmirror.com" APK_MIRROR_BASE_APK_URL = f"{APK_MIRROR_BASE_URL}/apk" APK_MIRROR_PACKAGE_URL = f"{APK_MIRROR_BASE_URL}/?s=" + "{}" @@ -20,6 +21,9 @@ revanced_api = "https://api.revanced.app/v2/patches/latest" APK_MONK_BASE_URL = "https://www.apkmonk.com" APK_MONK_APK_URL = APK_MONK_BASE_URL + "/app/{}/" APK_MONK_ICON_URL = "https://cdn.apkmonk.com/logos/{}" +DRIVE_BASE_URL = "https://drive.google.com" +DRIVE_DOWNLOAD_BASE_URL = f"{DRIVE_BASE_URL}/uc?id=" +DRIVE_DOWNLOAD_URL = DRIVE_DOWNLOAD_BASE_URL + "{}" apk_sources = { "backdrops": f"{APK_MIRROR_BASE_APK_URL}/backdrops/backdrops-wallpapers/", "bacon": f"{APK_MIRROR_BASE_APK_URL}/onelouder-apps/baconreader-for-reddit/",