mirror of
https://github.com/sotam0316/docker-py-revanced.git
synced 2026-04-25 03:48:37 +09:00
✨ Save patch time
This commit is contained in:
committed by
Nikhil Badyal
parent
63ca520990
commit
410a3baded
+2
-2
@@ -13,7 +13,7 @@ from pytz import timezone
|
|||||||
from src.config import RevancedConfig
|
from src.config import RevancedConfig
|
||||||
from src.downloader.sources import apk_sources
|
from src.downloader.sources import apk_sources
|
||||||
from src.exceptions import BuilderError, DownloadError, PatchingFailedError
|
from src.exceptions import BuilderError, DownloadError, PatchingFailedError
|
||||||
from src.utils import slugify
|
from src.utils import slugify, time_zone
|
||||||
|
|
||||||
|
|
||||||
class APP(object):
|
class APP(object):
|
||||||
@@ -81,7 +81,7 @@ class APP(object):
|
|||||||
-------
|
-------
|
||||||
a string that represents the output file name for an APK file.
|
a string that represents the output file name for an APK file.
|
||||||
"""
|
"""
|
||||||
current_date = datetime.now(timezone("Asia/Kolkata"))
|
current_date = datetime.now(timezone(time_zone))
|
||||||
formatted_date = current_date.strftime("%Y%b%d_%I%M%p").upper()
|
formatted_date = current_date.strftime("%Y%b%d_%I%M%p").upper()
|
||||||
return f"Re-{self.app_name}-{slugify(self.app_version)}-{formatted_date}-output.apk"
|
return f"Re-{self.app_name}-{slugify(self.app_version)}-{formatted_date}-output.apk"
|
||||||
|
|
||||||
|
|||||||
+13
-1
@@ -5,12 +5,15 @@ import json
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
from datetime import datetime
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
from pytz import timezone
|
||||||
from requests import Response, Session
|
from requests import Response, Session
|
||||||
|
|
||||||
from src.downloader.sources import APK_MIRROR_APK_CHECK
|
from src.downloader.sources import APK_MIRROR_APK_CHECK
|
||||||
@@ -37,6 +40,7 @@ session = Session()
|
|||||||
session.headers["User-Agent"] = request_header["User-Agent"]
|
session.headers["User-Agent"] = request_header["User-Agent"]
|
||||||
updates_file = "updates.json"
|
updates_file = "updates.json"
|
||||||
changelogs: dict[str, dict[str, str]] = {}
|
changelogs: dict[str, dict[str, str]] = {}
|
||||||
|
time_zone = "Asia/Kolkata"
|
||||||
|
|
||||||
|
|
||||||
def update_changelog(name: str, response: dict[str, str]) -> None:
|
def update_changelog(name: str, response: dict[str, str]) -> None:
|
||||||
@@ -217,6 +221,12 @@ def contains_any_word(string: str, words: list[str]) -> bool:
|
|||||||
return any(word in string for word in words)
|
return any(word in string for word in words)
|
||||||
|
|
||||||
|
|
||||||
|
def datetime_to_ms_epoch(dt: datetime) -> int:
|
||||||
|
"""Returns millis since epoch."""
|
||||||
|
microseconds = time.mktime(dt.timetuple()) * 1000000 + dt.microsecond
|
||||||
|
return int(round(microseconds / float(1000)))
|
||||||
|
|
||||||
|
|
||||||
def save_patch_info(app: Any) -> None:
|
def save_patch_info(app: Any) -> None:
|
||||||
"""Save version info a patching resources used to a file."""
|
"""Save version info a patching resources used to a file."""
|
||||||
try:
|
try:
|
||||||
@@ -232,5 +242,7 @@ def save_patch_info(app: Any) -> None:
|
|||||||
"patches_version": app.resource["patches"]["version"],
|
"patches_version": app.resource["patches"]["version"],
|
||||||
"cli_version": app.resource["cli"]["version"],
|
"cli_version": app.resource["cli"]["version"],
|
||||||
"patches_json_version": app.resource["patches_json"]["version"],
|
"patches_json_version": app.resource["patches_json"]["version"],
|
||||||
|
"ms_epoch_since_patched": datetime_to_ms_epoch(datetime.now(timezone(time_zone))),
|
||||||
|
"date_patched": datetime.now(timezone(time_zone)),
|
||||||
}
|
}
|
||||||
Path(updates_file).write_text(json.dumps(old_version, indent=4) + "\n")
|
Path(updates_file).write_text(json.dumps(old_version, indent=4, default=str) + "\n")
|
||||||
|
|||||||
Reference in New Issue
Block a user