mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2025-02-17 02:44:27 +00:00
Compare commits
5 commits
52cf8869b4
...
a92706d24c
Author | SHA1 | Date | |
---|---|---|---|
|
a92706d24c | ||
|
2158019241 | ||
|
77f5d4b0cb | ||
|
fba68e7a70 | ||
|
097051cdef |
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
|||
tags_db
|
||||
music_dl
|
||||
.auth.json
|
||||
config.json
|
||||
|
|
|
@ -8,7 +8,7 @@ Features:
|
|||
* Select and listen albums
|
||||
* Select and listen artists
|
||||
* Search by albums, artists
|
||||
* Switch instance from public list in config.json[1]..
|
||||
* Switch instance from public list[1] and official instanses listing network.funkwhale.audio (if avalaible)
|
||||
* All others features maybe working 50/50
|
||||
|
||||
Depends:
|
||||
|
@ -21,5 +21,5 @@ Python depends:
|
|||
|
||||
Also, thk Inex for FunkWhale instance (set by default instance)
|
||||
|
||||
[1]**Warning:** "Public" list instances in config.json may content _unofficial instance_
|
||||
[1]**Warning:** may content _unofficial instances_
|
||||
|
||||
|
|
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"
|
||||
]
|
||||
}
|
|
@ -11,12 +11,6 @@ from pyfzf.pyfzf import FzfPrompt
|
|||
fzf = FzfPrompt()
|
||||
|
||||
def main():
|
||||
logger.remove()
|
||||
logger.add(sys.stderr, filter='src.fw_api')
|
||||
logger.add(sys.stderr, filter='src.fw_radios')
|
||||
logger.add(sys.stderr, filter='src.fw_artists')
|
||||
logger.add(sys.stderr, filter='src.fw_albums')
|
||||
logger.add(sys.stderr, filter='src.fw_channels')
|
||||
while True:
|
||||
menu = ['Radios',
|
||||
'Artists',
|
||||
|
@ -42,6 +36,7 @@ def main():
|
|||
if search_type == 'Federated':
|
||||
print('Input url:')
|
||||
returned_obj = federate_search_by_url(input())
|
||||
logger.info(str(returned_obj))
|
||||
|
||||
if selected == 'Switch instance':
|
||||
with open('config.json', 'rt') as f:
|
||||
|
|
|
@ -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,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=[]):
|
||||
|
|
|
@ -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",
|
||||
|
@ -31,10 +34,49 @@ defaut_conf = {
|
|||
"listen.knsm.cc",
|
||||
"funkwhale.gegeweb.eu",
|
||||
"shitnoise.monster"
|
||||
]
|
||||
],
|
||||
'prefetch_playlist': True
|
||||
}
|
||||
|
||||
|
||||
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 or add 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}')
|
||||
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)
|
||||
|
||||
|
||||
if not exists(conf_file):
|
||||
set_defaults()
|
||||
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
|
||||
|
@ -63,7 +105,7 @@ def get_new_funkwhale_servers():
|
|||
if results:
|
||||
new_instances_list = results['results']['A']['tables'][0]['rows']
|
||||
for i in new_instances_list:
|
||||
if i[0] not in defaut_conf['public_list_instances'] and i[1]:
|
||||
if i[0] not in default_conf['public_list_instances'] and i[1]:
|
||||
new_instances.append(i[0])
|
||||
return new_instances
|
||||
|
||||
|
|
Loading…
Reference in a new issue