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

57 lines
1.3 KiB
Python
Raw Normal View History

2024-05-27 13:50:04 +00:00
import os
2023-04-04 18:19:29 +00:00
import random
2024-04-10 10:18:07 +00:00
from pathlib import Path
2024-05-27 13:50:04 +00:00
from dotenv import load_dotenv
2023-04-04 18:19:29 +00:00
2023-09-11 19:34:45 +00:00
from .config import main_settings
2024-05-27 13:50:04 +00:00
from .path_manager import LOCATIONS
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-05-16 15:09:36 +00:00
DEBUG = (__stage__ == "dev") and True
DEBUG_LOGGING = DEBUG and False
2024-04-10 10:18:07 +00:00
DEBUG_TRACE = DEBUG and True
2024-05-21 13:27:10 +00:00
DEBUG_OBJECT_TRACE = DEBUG and False
2024-04-23 09:44:39 +00:00
DEBUG_OBJECT_TRACE_CALLSTACK = DEBUG_OBJECT_TRACE and False
2024-01-22 20:39:39 +00:00
DEBUG_YOUTUBE_INITIALIZING = DEBUG and False
2024-04-19 10:47:36 +00:00
DEBUG_PAGES = DEBUG and False
2024-05-21 13:27:10 +00:00
DEBUG_DUMP = DEBUG and True
2024-05-03 12:52:12 +00:00
DEBUG_PRINT_ID = 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|\,|\.]*$"
2024-05-27 13:50:04 +00:00
ALPHABET = "abcdefghijklmnopqrstuvwxyz"