Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from src.config import RevancedConfig
from src.downloader.sources import apk_sources
from src.exceptions import BuilderError, DownloadError, PatchingFailedError
from src.utils import slugify
from src.utils import slugify, time_zone


class APP(object):
Expand Down Expand Up @@ -81,7 +81,7 @@ def get_output_file_name(self: Self) -> str:
-------
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()
return f"Re-{self.app_name}-{slugify(self.app_version)}-{formatted_date}-output.apk"

Expand Down
14 changes: 13 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
import re
import subprocess
import sys
import time
from datetime import datetime
from json import JSONDecodeError
from pathlib import Path
from typing import Any

import requests
from loguru import logger
from pytz import timezone
from requests import Response, Session

from src.downloader.sources import APK_MIRROR_APK_CHECK
Expand All @@ -37,6 +40,7 @@
session.headers["User-Agent"] = request_header["User-Agent"]
updates_file = "updates.json"
changelogs: dict[str, dict[str, str]] = {}
time_zone = "Asia/Kolkata"


def update_changelog(name: str, response: dict[str, str]) -> None:
Expand Down Expand Up @@ -217,6 +221,12 @@ def contains_any_word(string: str, words: list[str]) -> bool:
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:
"""Save version info a patching resources used to a file."""
try:
Expand All @@ -232,5 +242,7 @@ def save_patch_info(app: Any) -> None:
"patches_version": app.resource["patches"]["version"],
"cli_version": app.resource["cli"]["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")