Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: use global time variables

NTFSvolumed0cba63787b1
diff --git a/cyberdrop_dl/profiling.py b/cyberdrop_dl/profiling.py
index c09c0ecf2..f11368a75 100644
--- a/cyberdrop_dl/profiling.py
+++ b/cyberdrop_dl/profiling.py
@@ -8,12 +8,12 @@ import os
import pstats
import shutil
from contextlib import contextmanager
-from datetime import datetime
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import TYPE_CHECKING
from cyberdrop_dl import env
+from cyberdrop_dl.utils import constants
if TYPE_CHECKING:
from collections.abc import Callable
@@ -65,7 +65,7 @@ def destroy_profile(old_cwd: Path, temp_dir_path: Path) -> None:
if old_log_file and old_log_file.is_file():
suffix = "_profiling"
if env.PROFILING == "use_date":
- suffix += f"_{datetime.now().strftime('%Y%m%d_%H%M%S')}"
+ suffix += f"_{constants.STARTUP_TIME.strftime(constants.LOGS_DATETIME_FORMAT)}"
new_log_file = Path(f"cyberdrop_dl_debug{suffix}.log").resolve()
shutil.move(old_log_file, new_log_file)
diff --git a/cyberdrop_dl/utils/constants.py b/cyberdrop_dl/utils/constants.py
index cf113b088..a4d88b783 100644
--- a/cyberdrop_dl/utils/constants.py
+++ b/cyberdrop_dl/utils/constants.py
@@ -1,10 +1,17 @@
import re
+from datetime import UTC, datetime
from enum import Enum, IntEnum, StrEnum, auto
from pathlib import Path
from typing import Any
from rich.text import Text
+# TIME
+STARTUP_TIME = datetime.now()
+STARTUP_TIME_UTC = datetime.now(UTC)
+LOGS_DATETIME_FORMAT = "%Y%m%d_%H%M%S"
+LOGS_DATE_FORMAT = "%Y_%m_%d"
+
# logging
CONSOLE_LEVEL = 100
MAX_NAME_LENGTHS = {"FILE": 95, "FOLDER": 60}