music-kraken-core/music_kraken/utils/shared.py

52 lines
1.2 KiB
Python
Raw Normal View History

2023-04-04 18:19:29 +00:00
import random
2024-04-10 10:18:07 +00:00
from dotenv import load_dotenv
from pathlib import Path
import os
2023-04-04 18:19:29 +00:00
from .path_manager import LOCATIONS
2023-09-11 19:34:45 +00:00
from .config import main_settings
2023-04-18 07:02:03 +00:00
2024-04-10 10:18:07 +00:00
if not load_dotenv(Path(__file__).parent.parent.parent / ".env"):
load_dotenv(Path(__file__).parent.parent.parent / ".env.example")
__stage__ = os.getenv("STAGE", "prod")
2024-04-10 12:18:19 +00:00
DEBUG = (__stage__ == "dev") and True
2024-04-16 12:19:07 +00:00
DEBUG_LOGGING = DEBUG and True
2024-04-10 10:18:07 +00:00
DEBUG_TRACE = DEBUG and True
2024-04-18 15:47:33 +00:00
DEBUG_OBJECT_TRACE = DEBUG and False
2024-01-22 20:39:39 +00:00
DEBUG_YOUTUBE_INITIALIZING = DEBUG and False
2023-09-13 14:01:01 +00:00
DEBUG_PAGES = DEBUG and False
2024-04-10 07:28:28 +00:00
DEBUG_DUMP = DEBUG and True
2023-09-12 08:58:44 +00:00
2023-09-10 14:27:09 +00:00
if DEBUG:
print("DEBUG ACTIVE")
2023-04-04 18:19:29 +00:00
2024-01-16 12:55:24 +00:00
2023-04-04 18:19:29 +00:00
def get_random_message() -> str:
2023-09-10 14:27:09 +00:00
return random.choice(main_settings['happy_messages'])
2023-04-04 19:10:47 +00:00
2023-06-20 14:40:34 +00:00
CONFIG_DIRECTORY = LOCATIONS.CONFIG_DIRECTORY
2024-01-16 12:55:24 +00:00
HIGHEST_ID = 2 ** main_settings['id_bits']
2023-09-11 19:34:45 +00:00
2023-09-12 11:56:40 +00:00
HELP_MESSAGE = """to search:
2023-06-20 14:40:34 +00:00
> s: {query or url}
> s: https://musify.club/release/some-random-release-183028492
> s: #a {artist} #r {release} #t {track}
to download:
> d: {option ids or direct url}
> d: 0, 3, 4
> d: 1
> d: https://musify.club/release/some-random-release-183028492
2023-09-12 11:56:40 +00:00
have fun :3""".strip()
2024-04-09 12:00:51 +00:00
# regex pattern
URL_PATTERN = r"https?://(?:[-\w.]|(?:%[\da-fA-F]{2}))+"
INT_PATTERN = r"^\d*$"
FLOAT_PATTERN = r"^[\d|\,|\.]*$"