refactor #1 - logger print + music_dir
This commit is contained in:
parent
8405692d6b
commit
7f6e6ee5fa
@ -6,7 +6,7 @@ import io
|
|||||||
import configparser
|
import configparser
|
||||||
from sys import platform as current_os
|
from sys import platform as current_os
|
||||||
|
|
||||||
USER_XDG_DIR_FILE = os.path.expanduser("~/.config/user-dirs.dirs")
|
|
||||||
TEMP_FOLDER = "music-downloader"
|
TEMP_FOLDER = "music-downloader"
|
||||||
LOG_FILE = "download_logs.log"
|
LOG_FILE = "download_logs.log"
|
||||||
TEMP_DATABASE_FILE = "metadata.db"
|
TEMP_DATABASE_FILE = "metadata.db"
|
||||||
@ -29,6 +29,7 @@ logging.basicConfig(
|
|||||||
)
|
)
|
||||||
|
|
||||||
SEARCH_LOGGER = logging.getLogger("mb-cli")
|
SEARCH_LOGGER = logging.getLogger("mb-cli")
|
||||||
|
INIT_PATH_LOGGER = logging.getLogger("init_path")
|
||||||
DATABASE_LOGGER = logging.getLogger("database")
|
DATABASE_LOGGER = logging.getLogger("database")
|
||||||
METADATA_DOWNLOAD_LOGGER = logging.getLogger("metadata")
|
METADATA_DOWNLOAD_LOGGER = logging.getLogger("metadata")
|
||||||
URL_DOWNLOAD_LOGGER = logging.getLogger("AudioSource")
|
URL_DOWNLOAD_LOGGER = logging.getLogger("AudioSource")
|
||||||
@ -40,9 +41,12 @@ LYRICS_LOGGER = logging.getLogger("lyrics")
|
|||||||
GENIUS_LOGGER = logging.getLogger("genius")
|
GENIUS_LOGGER = logging.getLogger("genius")
|
||||||
|
|
||||||
NOT_A_GENRE = ".", "..", "misc_scripts", "Music", "script", ".git", ".idea"
|
NOT_A_GENRE = ".", "..", "misc_scripts", "Music", "script", ".git", ".idea"
|
||||||
MUSIC_DIR = os.path.join(os.path.expanduser("~"), "Music")
|
MUSIC_DIR = os.path.join("~", ".config", "user-dirs.dirs")
|
||||||
|
|
||||||
if current_os == "linux":
|
if current_os == "linux":
|
||||||
|
USER_XDG_DIR_FILE = os.path.expanduser("~/.config/user-dirs.dirss")
|
||||||
|
logger = logging.getLogger("init_path")
|
||||||
|
logger.setLevel(logging.WARNING)
|
||||||
try:
|
try:
|
||||||
with open(USER_XDG_DIR_FILE, 'r') as f:
|
with open(USER_XDG_DIR_FILE, 'r') as f:
|
||||||
data = io.StringIO("[XDG_USER_DIRS]\n" + f.read())
|
data = io.StringIO("[XDG_USER_DIRS]\n" + f.read())
|
||||||
@ -51,7 +55,7 @@ if current_os == "linux":
|
|||||||
xdg_config = config['XDG_USER_DIRS']
|
xdg_config = config['XDG_USER_DIRS']
|
||||||
MUSIC_DIR = os.path.expandvars(xdg_config['xdg_music_dir'].strip('"'))
|
MUSIC_DIR = os.path.expandvars(xdg_config['xdg_music_dir'].strip('"'))
|
||||||
except FileNotFoundError as N:
|
except FileNotFoundError as N:
|
||||||
print(f'''
|
logger.warning(f'''
|
||||||
Missing XDG_USER_DIRS file at: '{USER_XDG_DIR_FILE}'.
|
Missing XDG_USER_DIRS file at: '{USER_XDG_DIR_FILE}'.
|
||||||
Will fallback on default '$HOME/Music'.
|
Will fallback on default '$HOME/Music'.
|
||||||
----
|
----
|
||||||
|
Loading…
Reference in New Issue
Block a user