Removed checks options mpv; Configurator changes

This commit is contained in:
localhost_frssoft 2022-11-10 03:23:46 +03:00
parent 77f5d4b0cb
commit 2158019241
2 changed files with 17 additions and 8 deletions

View file

@ -1,5 +1,6 @@
import src.fw_api
from src.utils import download_track
from src.settings import get_config
from loguru import logger
from pyfzf.pyfzf import FzfPrompt
import mpv
@ -14,12 +15,8 @@ def mpv_log(loglevel, component, message):
logger.error(f'{component} {message}')
player = mpv.MPV()
list_options = dir(player)
if 'ytdl' in list_options:
player.ytdl = False
if 'prefetch_playlist' in list_options:
player.prefetch_playlist = True
player.ytdl = False # Prevent attempts load track with yt-dlp
player.prefetch_playlist = get_config('prefetch_playlist') # Fast loading next track, but high network traffic
def set_http_header(headers=[]):

View file

@ -34,7 +34,8 @@ default_conf = {
"listen.knsm.cc",
"funkwhale.gegeweb.eu",
"shitnoise.monster"
]
],
'prefetch_playlist': True
}
@ -47,7 +48,7 @@ def set_defaults(corrected_config=None):
def check_config():
'''Check config and remove keys if not found in default config'''
'''Check config and remove or add keys if not found in default config'''
with open(conf_file, 'rt') as f:
loaded_config = json.loads(f.read())
correct_conf = {}
@ -56,6 +57,10 @@ def check_config():
correct_conf[k] = v
else:
logger.warning(f'{k} from config will be removed. Value: {v}')
for k, v in default_conf.items():
if k not in correct_conf.keys():
correct_conf[k] = v
logger.warning(f'{k} added in config. Value: {v}')
set_defaults(correct_conf)
@ -65,6 +70,13 @@ else:
check_config()
def get_config(key):
'''return value from config by key'''
with open(conf_file, 'rt') as f:
loaded_config = json.loads(f.read())
return loaded_config.get(key)
@logger.catch
def get_new_funkwhale_servers():
# Uses official API network.funkwhale.audio for getting new instances