mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
✨ Allow dry run [skip ci]
This commit is contained in:
@@ -89,3 +89,4 @@ class RevancedConfig(object):
|
|||||||
)
|
)
|
||||||
self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", [])
|
self.existing_downloaded_apks = env.list("EXISTING_DOWNLOADED_APKS", [])
|
||||||
self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None)
|
self.personal_access_token = env.str("PERSONAL_ACCESS_TOKEN", None)
|
||||||
|
self.dry_run = env.bool("DRY_RUN", False)
|
||||||
|
|||||||
@@ -25,8 +25,13 @@ class Downloader(object):
|
|||||||
self.patcher = patcher
|
self.patcher = patcher
|
||||||
|
|
||||||
def _download(self, url: str, file_name: str) -> None:
|
def _download(self, url: str, file_name: str) -> None:
|
||||||
if os.path.exists(self.config.temp_folder.joinpath(file_name)):
|
if (
|
||||||
logger.debug(f"Skipping download of {file_name}. File already exists.")
|
os.path.exists(self.config.temp_folder.joinpath(file_name))
|
||||||
|
or self.config.dry_run
|
||||||
|
):
|
||||||
|
logger.debug(
|
||||||
|
f"Skipping download of {file_name}. File already exists or dry running."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
logger.info(f"Trying to download {file_name} from {url}")
|
logger.info(f"Trying to download {file_name} from {url}")
|
||||||
self._QUEUE_LENGTH += 1
|
self._QUEUE_LENGTH += 1
|
||||||
@@ -86,6 +91,8 @@ class Downloader(object):
|
|||||||
:param version: version to download
|
:param version: version to download
|
||||||
:param app: App to download
|
:param app: App to download
|
||||||
"""
|
"""
|
||||||
|
if self.config.dry_run:
|
||||||
|
return
|
||||||
if app in self.config.existing_downloaded_apks:
|
if app in self.config.existing_downloaded_apks:
|
||||||
logger.debug(f"Will not download {app} -v{version} from the internet.")
|
logger.debug(f"Will not download {app} -v{version} from the internet.")
|
||||||
return
|
return
|
||||||
|
|||||||
+21
-14
@@ -1,4 +1,5 @@
|
|||||||
"""Revanced Patches."""
|
"""Revanced Patches."""
|
||||||
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Any, Dict, List, Tuple
|
from typing import Any, Dict, List, Tuple
|
||||||
|
|
||||||
@@ -79,13 +80,17 @@ class Patches(object):
|
|||||||
def fetch_patches(self) -> None:
|
def fetch_patches(self) -> None:
|
||||||
"""Function to fetch all patches."""
|
"""Function to fetch all patches."""
|
||||||
session = Session()
|
session = Session()
|
||||||
|
if self.config.dry_run:
|
||||||
logger.debug("fetching all patches")
|
logger.debug("fetching all patches from local file")
|
||||||
response = session.get(
|
with open("patches.json") as f:
|
||||||
"https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json"
|
patches = json.load(f)
|
||||||
)
|
else:
|
||||||
handle_response(response)
|
logger.debug("fetching all patches")
|
||||||
patches = response.json()
|
response = session.get(
|
||||||
|
"https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json"
|
||||||
|
)
|
||||||
|
handle_response(response)
|
||||||
|
patches = response.json()
|
||||||
|
|
||||||
for app_name in (self.revanced_app_ids[x][1] for x in self.revanced_app_ids):
|
for app_name in (self.revanced_app_ids[x][1] for x in self.revanced_app_ids):
|
||||||
setattr(self, app_name, [])
|
setattr(self, app_name, [])
|
||||||
@@ -100,14 +105,16 @@ class Patches(object):
|
|||||||
p["app"] = compatible_package
|
p["app"] = compatible_package
|
||||||
p["version"] = version[-1] if version else "all"
|
p["version"] = version[-1] if version else "all"
|
||||||
getattr(self, app_name).append(p)
|
getattr(self, app_name).append(p)
|
||||||
if self.config.build_extended:
|
if self.config.dry_run:
|
||||||
url = "https://raw.githubusercontent.com/inotia00/revanced-patches/revanced-extended/patches.json"
|
extended_patches = patches
|
||||||
else:
|
else:
|
||||||
url = "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json"
|
if self.config.build_extended:
|
||||||
|
url = "https://raw.githubusercontent.com/inotia00/revanced-patches/revanced-extended/patches.json"
|
||||||
response = session.get(url)
|
else:
|
||||||
handle_response(response)
|
url = "https://raw.githubusercontent.com/revanced/revanced-patches/main/patches.json"
|
||||||
extended_patches = response.json()
|
response = session.get(url)
|
||||||
|
handle_response(response)
|
||||||
|
extended_patches = response.json()
|
||||||
for app_name in (
|
for app_name in (
|
||||||
self.revanced_extended_app_ids[x][1] for x in self.revanced_extended_app_ids
|
self.revanced_extended_app_ids[x][1] for x in self.revanced_extended_app_ids
|
||||||
):
|
):
|
||||||
|
|||||||
Reference in New Issue
Block a user