diff --git a/.gitignore b/.gitignore index 28a388a..faa641c 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ venv .idea/aws.xml windows + +.env diff --git a/.vscode/settings.json b/.vscode/settings.json index 2ccb4e5..4ee5e04 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -17,6 +17,7 @@ "python.formatting.provider": "none", "cSpell.words": [ "Bandcamp", + "dotenv", "levenshtein", "OKBLUE" ] diff --git a/music_kraken/pages/abstract.py b/music_kraken/pages/abstract.py index bee8b67..9547298 100644 --- a/music_kraken/pages/abstract.py +++ b/music_kraken/pages/abstract.py @@ -378,6 +378,9 @@ class Page: if not (isinstance(music_object, Song) and self.NO_ADDITIONAL_DATA_FROM_SONG): self.fetch_details(music_object=music_object, stop_at_level=1) + if isinstance(music_object, Song): + trace(music_object.option_string) + naming_dict.add_object(music_object) if isinstance(music_object, Song): diff --git a/music_kraken/utils/__init__.py b/music_kraken/utils/__init__.py index fcf8aad..8018526 100644 --- a/music_kraken/utils/__init__.py +++ b/music_kraken/utils/__init__.py @@ -3,7 +3,7 @@ from pathlib import Path import json import logging -from .shared import DEBUG, DEBUG_LOGGING, DEBUG_DUMP +from .shared import DEBUG, DEBUG_LOGGING, DEBUG_DUMP, DEBUG_TRACE from .config import config, read_config, write_config from .enums.colors import BColors from .path_manager import LOCATIONS @@ -47,7 +47,7 @@ def dump_to_file(file_name: str, payload: str, is_json: bool = False, exit_after def trace(msg: str): - if DEBUG_LOGGING: + if DEBUG_TRACE: logging.debug(msg) output("trace: " + msg, BColors.OKBLUE) diff --git a/music_kraken/utils/shared.py b/music_kraken/utils/shared.py index 413eec9..3e79a29 100644 --- a/music_kraken/utils/shared.py +++ b/music_kraken/utils/shared.py @@ -1,10 +1,20 @@ import random +from dotenv import load_dotenv +from pathlib import Path +import os + from .path_manager import LOCATIONS from .config import main_settings -DEBUG = True +if not load_dotenv(Path(__file__).parent.parent.parent / ".env"): + load_dotenv(Path(__file__).parent.parent.parent / ".env.example") + +__stage__ = os.getenv("STAGE", "prod") + +DEBUG = __stage__ == "dev" and True DEBUG_LOGGING = DEBUG and False +DEBUG_TRACE = DEBUG and True DEBUG_YOUTUBE_INITIALIZING = DEBUG and False DEBUG_PAGES = DEBUG and False DEBUG_DUMP = DEBUG and True diff --git a/pyproject.toml b/pyproject.toml index 6fbb88b..d0003d8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,6 +51,7 @@ dependencies = [ "transliterate~=1.10.2", "pycountry~=24.0.1", + "python-dotenv~=1.0.1", "tqdm~=4.65.0", "platformdirs~=4.2.0", "pathvalidate~=2.5.2",