mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 17:09:20 +02:00
Removed checks options mpv; Configurator changes
This commit is contained in:
parent
77f5d4b0cb
commit
2158019241
|
@ -1,5 +1,6 @@
|
||||||
import src.fw_api
|
import src.fw_api
|
||||||
from src.utils import download_track
|
from src.utils import download_track
|
||||||
|
from src.settings import get_config
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
import mpv
|
import mpv
|
||||||
|
@ -14,12 +15,8 @@ def mpv_log(loglevel, component, message):
|
||||||
logger.error(f'{component} {message}')
|
logger.error(f'{component} {message}')
|
||||||
|
|
||||||
player = mpv.MPV()
|
player = mpv.MPV()
|
||||||
|
player.ytdl = False # Prevent attempts load track with yt-dlp
|
||||||
list_options = dir(player)
|
player.prefetch_playlist = get_config('prefetch_playlist') # Fast loading next track, but high network traffic
|
||||||
if 'ytdl' in list_options:
|
|
||||||
player.ytdl = False
|
|
||||||
if 'prefetch_playlist' in list_options:
|
|
||||||
player.prefetch_playlist = True
|
|
||||||
|
|
||||||
|
|
||||||
def set_http_header(headers=[]):
|
def set_http_header(headers=[]):
|
||||||
|
|
|
@ -34,7 +34,8 @@ default_conf = {
|
||||||
"listen.knsm.cc",
|
"listen.knsm.cc",
|
||||||
"funkwhale.gegeweb.eu",
|
"funkwhale.gegeweb.eu",
|
||||||
"shitnoise.monster"
|
"shitnoise.monster"
|
||||||
]
|
],
|
||||||
|
'prefetch_playlist': True
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ def set_defaults(corrected_config=None):
|
||||||
|
|
||||||
|
|
||||||
def check_config():
|
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:
|
with open(conf_file, 'rt') as f:
|
||||||
loaded_config = json.loads(f.read())
|
loaded_config = json.loads(f.read())
|
||||||
correct_conf = {}
|
correct_conf = {}
|
||||||
|
@ -56,6 +57,10 @@ def check_config():
|
||||||
correct_conf[k] = v
|
correct_conf[k] = v
|
||||||
else:
|
else:
|
||||||
logger.warning(f'{k} from config will be removed. Value: {v}')
|
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)
|
set_defaults(correct_conf)
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,6 +70,13 @@ else:
|
||||||
check_config()
|
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
|
@logger.catch
|
||||||
def get_new_funkwhale_servers():
|
def get_new_funkwhale_servers():
|
||||||
# Uses official API network.funkwhale.audio for getting new instances
|
# Uses official API network.funkwhale.audio for getting new instances
|
||||||
|
|
Loading…
Reference in New Issue