added config directory, and a new dependency

This commit is contained in:
Hellow 2023-04-13 19:22:54 +02:00
parent 73c75c6598
commit eda39186d4
3 changed files with 15 additions and 3 deletions

View File

@ -12,4 +12,5 @@ SQLAlchemy
setuptools~=60.2.0
tqdm~=4.65.0
peewee~=3.15.4
ffmpeg-python~=0.2.0
ffmpeg-python~=0.2.0
platformdirs~=3.2.0

View File

@ -0,0 +1,7 @@
from pathlib import Path
import platformdirs
def get_config_directory(application_name: str) -> Path:
return platformdirs.user_config_path(appname=application_name)

View File

@ -4,14 +4,18 @@ import os
import tempfile
from .music_directory import get_music_directory
from .config_directory import get_config_directory
class Locations:
def __init__(self, temp_folder_name: os.PathLike = "music-downloader"):
self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), temp_folder_name)
def __init__(self, application_name: os.PathLike = "music-kraken"):
self.TEMP_DIRECTORY = Path(tempfile.gettempdir(), application_name)
self.TEMP_DIRECTORY.mkdir(exist_ok=True)
self.MUSIC_DIRECTORY = get_music_directory()
self.CONFIG_DIRECTORY = get_config_directory(str(application_name))
self.CONFIG_DIRECTORY.mkdir(exist_ok=True)
def get_log_file(self, file_name: os.PathLike) -> Path:
return Path(self.TEMP_DIRECTORY, file_name)