mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-24 03:43:33 +02:00
Checks config; other changes
This commit is contained in:
parent
097051cdef
commit
fba68e7a70
4 changed files with 37 additions and 66 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
tags_db
|
||||
music_dl
|
||||
.auth.json
|
||||
config.json
|
||||
|
|
64
config.json
64
config.json
|
@ -1,64 +0,0 @@
|
|||
{
|
||||
"instance": "fw.ponychord.rocks",
|
||||
"download_selected_track": false,
|
||||
"local_content_only": true,
|
||||
"tags": [
|
||||
"8bit",
|
||||
"Alternative",
|
||||
"Ambient",
|
||||
"Classical",
|
||||
"Comedy",
|
||||
"Country",
|
||||
"Dance",
|
||||
"Blues",
|
||||
"Electronic",
|
||||
"Hip-Hop",
|
||||
"Industrial",
|
||||
"Instrumental",
|
||||
"J-Pop",
|
||||
"Jazz",
|
||||
"Karaoke",
|
||||
"Latin",
|
||||
"Metal",
|
||||
"Orchestral",
|
||||
"Opera",
|
||||
"Pop",
|
||||
"Progressive",
|
||||
"Reggae",
|
||||
"Rock",
|
||||
"Singler",
|
||||
"Synth",
|
||||
"Songwriter",
|
||||
"Soundtrack",
|
||||
"Vocal"
|
||||
],
|
||||
"public_list_instances": [
|
||||
"open.audio",
|
||||
"audio.securetown.top",
|
||||
"funkwhale.co.uk",
|
||||
"am.pirateradio.social",
|
||||
"audio.liberta.vip",
|
||||
"audio.gafamfree.party",
|
||||
"tanukitunes.com",
|
||||
"funkwhale.juniorjpdj.pl",
|
||||
"tavia.mle.party",
|
||||
"funkwhale.thurk.org",
|
||||
"buzzworkers.com",
|
||||
"soundship.de",
|
||||
"funkwhale.kameha.click",
|
||||
"music.chosto.me",
|
||||
"zik.goe.land",
|
||||
"music.humanoids.be",
|
||||
"music.hempton.us",
|
||||
"mizik.o-k-i.net",
|
||||
"klh.radiolivre.org",
|
||||
"hudba.feildel.fr",
|
||||
"funkwhale.mita.me",
|
||||
"funk.deko.cloud",
|
||||
"audio.graz.social",
|
||||
"funkwhale.desmu.fr",
|
||||
"listen.knsm.cc",
|
||||
"funkwhale.gegeweb.eu",
|
||||
"shitnoise.monster"
|
||||
]
|
||||
}
|
|
@ -41,6 +41,9 @@ def play_artist(artist_id):
|
|||
storage = {}
|
||||
if tracks_count > 50:
|
||||
print(f'Loading {tracks_count} tracks...')
|
||||
elif tracks_count == 0:
|
||||
logger.warning('Empty tracks. Nothing to do')
|
||||
return
|
||||
while True:
|
||||
tracks_results = tracks.get('results')
|
||||
tracks_next = tracks.get('next')
|
||||
|
@ -52,4 +55,5 @@ def play_artist(artist_id):
|
|||
tracks = get_tracks(artist=artist_id, include_channels=True, pg=tracks_next)
|
||||
else:
|
||||
break
|
||||
player_menu("Artist playing...", storage)
|
||||
artist_name = tracks.get('results')[0].get('artist').get('name')
|
||||
player_menu(f"Artist {artist_name} playing...", storage)
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
import json, requests, time
|
||||
from os.path import exists
|
||||
from loguru import logger
|
||||
|
||||
defaut_conf = {
|
||||
conf_file = 'config.json'
|
||||
|
||||
default_conf = {
|
||||
'instance': 'fw.ponychord.rocks',
|
||||
'public_list_instances': [
|
||||
"open.audio",
|
||||
|
@ -35,6 +38,33 @@ defaut_conf = {
|
|||
}
|
||||
|
||||
|
||||
def set_defaults(corrected_config=None):
|
||||
conf_rewrite = default_conf
|
||||
if corrected_config:
|
||||
conf_rewrite = corrected_config
|
||||
with open(conf_file, 'wt') as f:
|
||||
f.write(json.dumps(conf_rewrite, indent=4))
|
||||
|
||||
|
||||
def check_config():
|
||||
'''Check config and remove keys if not found in default config'''
|
||||
with open(conf_file, 'rt') as f:
|
||||
loaded_config = json.loads(f.read())
|
||||
correct_conf = {}
|
||||
for k, v in loaded_config.items():
|
||||
if k in default_conf.keys():
|
||||
correct_conf[k] = v
|
||||
else:
|
||||
logger.warning(f'{k} from config will be removed. Value: {v}')
|
||||
set_defaults(correct_conf)
|
||||
|
||||
|
||||
if not exists(conf_file):
|
||||
set_defaults()
|
||||
else:
|
||||
check_config()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def get_new_funkwhale_servers():
|
||||
# Uses official API network.funkwhale.audio for getting new instances
|
||||
|
|
Loading…
Reference in a new issue