implemented a run on first start thingie

This commit is contained in:
Hellow2 2023-06-21 14:05:40 +02:00
parent cd61fe4c1d
commit 721265d3e8
5 changed files with 37 additions and 2 deletions

View File

@ -3,8 +3,10 @@ from pathlib import Path
import re import re
from .utils import cli_function from .utils import cli_function
from .options.first_config import initial_config
from ..utils.shared import MUSIC_DIR, NOT_A_GENRE_REGEX, ENABLE_RESULT_HISTORY, HISTORY_LENGTH, HELP_MESSAGE from ..utils.config import set_name_to_value, write_config
from ..utils.shared import MUSIC_DIR, NOT_A_GENRE_REGEX, ENABLE_RESULT_HISTORY, HISTORY_LENGTH, HELP_MESSAGE, HASNT_YET_STARTED
from ..utils.regex import URL_PATTERN from ..utils.regex import URL_PATTERN
from ..utils.string_processing import fit_to_file_system from ..utils.string_processing import fit_to_file_system
from ..utils.support_classes import Query, DownloadResult from ..utils.support_classes import Query, DownloadResult
@ -391,6 +393,18 @@ def download(
command_list: List[str] = None, command_list: List[str] = None,
process_metadata_anyway: bool = False, process_metadata_anyway: bool = False,
): ):
if HASNT_YET_STARTED:
code = initial_config()
if code == 0:
set_name_to_value("hasnt_yet_started", "false")
write_config()
print("Restart the programm to use it.")
return code
print("Something went wrong configuring.")
return code
shell = Downloader(genre=genre, process_metadata_anyway=process_metadata_anyway) shell = Downloader(genre=genre, process_metadata_anyway=process_metadata_anyway)
if command_list is not None: if command_list is not None:

View File

@ -183,3 +183,5 @@ def set_frontend(silent: bool = False):
shell = FrontendSelection() shell = FrontendSelection()
shell.choose(silent=silent) shell.choose(silent=silent)
return 0

View File

@ -3,10 +3,20 @@ from ..utils.shared import get_random_message
def cli_function(function): def cli_function(function):
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
silent = kwargs.get("no_cli", False)
if "no_cli" in kwargs:
del kwargs["no_cli"]
if silent:
return function(*args, **kwargs)
return
code = 0
print_cute_message() print_cute_message()
print() print()
try: try:
function(*args, **kwargs) code = function(*args, **kwargs)
except KeyboardInterrupt: except KeyboardInterrupt:
print("\n\nRaise an issue if I fucked up:\nhttps://github.com/HeIIow2/music-downloader/issues") print("\n\nRaise an issue if I fucked up:\nhttps://github.com/HeIIow2/music-downloader/issues")

View File

@ -3,6 +3,12 @@ from .base_classes import Section, IntAttribute, ListAttribute, BoolAttribute
class MiscSection(Section): class MiscSection(Section):
def __init__(self): def __init__(self):
self.HASNT_YET_STARTED = BoolAttribute(
name="hasnt_yet_started",
description="If you did already run, and configured everything, this is false.",
value="true"
)
self.ENABLE_RESULT_HISTORY = BoolAttribute( self.ENABLE_RESULT_HISTORY = BoolAttribute(
name="result_history", name="result_history",
description="If enabled, you can go back to the previous results.\n" description="If enabled, you can go back to the previous results.\n"
@ -52,6 +58,7 @@ class MiscSection(Section):
) )
self.attribute_list = [ self.attribute_list = [
self.HASNT_YET_STARTED,
self.ENABLE_RESULT_HISTORY, self.ENABLE_RESULT_HISTORY,
self.HISTORY_LENGTH, self.HISTORY_LENGTH,
self.HAPPY_MESSAGES, self.HAPPY_MESSAGES,

View File

@ -122,3 +122,5 @@ have fun :3
""".strip() """.strip()
FFMPEG_BINARY: Path = PATHS_SECTION.FFMPEG_BINARY.object_from_value FFMPEG_BINARY: Path = PATHS_SECTION.FFMPEG_BINARY.object_from_value
HASNT_YET_STARTED: bool = MISC_SECTION.HASNT_YET_STARTED.object_from_value