autopep8 fixes

This commit is contained in:
localhost_frssoft 2022-12-18 04:02:53 +03:00
parent 6c5113abcc
commit 86bbdcf0ea
14 changed files with 215 additions and 166 deletions

View file

@ -10,13 +10,16 @@ from src.fw_playlists import list_playlists
from src.fw_fav_tracks import list_favorites_tracks
import src.settings as settings
import src.mpv_control
import json, sys, time
import json
import sys
import time
from shlex import quote
from loguru import logger
from pyfzf.pyfzf import FzfPrompt
fzf = FzfPrompt()
def main():
while True:
@ -33,9 +36,9 @@ def main():
except:
time.sleep(1)
main_menu_header = quote(f'''Connection failed'''.strip())
menu = ['Radios',
'Artists',
menu = ['Radios',
'Artists',
'Albums',
'Tracks',
'Channels',
@ -78,8 +81,9 @@ def main():
conf = json.loads(f.read())
public_server_list_instances = settings.get_new_funkwhale_servers()
new_ins_count = len(settings.get_new_funkwhale_servers())
list_instances = conf.get('public_list_instances') + public_server_list_instances
instance = fzf.prompt(list_instances,
list_instances = conf.get(
'public_list_instances') + public_server_list_instances
instance = fzf.prompt(list_instances,
'--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))[0]
current_instance.select_instance(instance)
if selected == 'Sign in':
@ -106,8 +110,8 @@ Insert token from "Access token" here''')
print(support_message)
input()
if selected == 'Player':
src.mpv_control.player_menu(storage=src.mpv_control.player_fw_storage.storage)
src.mpv_control.player_menu(
storage=src.mpv_control.player_fw_storage.storage)
if __name__ == '__main__':

View file

@ -7,6 +7,7 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_albums(albums=None, pg=None, search=None, artist=None, include_channels=None, refresh=False):
show_artist_name_in_albums = get_config('show_artist_name_in_albums')
@ -14,7 +15,8 @@ def list_albums(albums=None, pg=None, search=None, artist=None, include_channels
albums_prev = None
play_artist_albums = False
if not albums:
albums = get_albums(q=search, artist=artist, include_channels=include_channels, refresh=refresh, pg=pg)
albums = get_albums(q=search, artist=artist,
include_channels=include_channels, refresh=refresh, pg=pg)
albums_next = albums.get('next')
albums_prev = albums.get('previous')
albums_results = albums.get('results')

View file

@ -1,6 +1,8 @@
from src.mpv_control import set_http_header
from src.settings import get_config
import requests, json, time
import requests
import json
import time
import urllib.parse
import os
from loguru import logger
@ -30,7 +32,7 @@ class current_instance:
s = requests.Session()
instance = get_config('instance')
token = auth.get(instance)
@logger.catch
def select_instance(new_instance=None):
current_instance.instance = new_instance
@ -38,13 +40,13 @@ class current_instance:
auth = json.loads(f.read())
new_token = auth.get(current_instance.instance)
current_instance.s.headers.update({"Authorization": None,
"Accept-encoding": 'gzip'})
"Accept-encoding": 'gzip'})
set_http_header()
if new_token:
s.get(f'https://{current_instance.instance}')
s.headers.update({
"Authorization": "Bearer " + new_token,
"Accept-encoding": 'gzip'
"Authorization": "Bearer " + new_token,
"Accept-encoding": 'gzip'
})
set_http_header(['Authorization: ' + 'Bearer ' + new_token])
@ -57,24 +59,26 @@ if current_instance.token:
set_http_header(['Authorization: ' + 'Bearer ' + current_instance.token])
else:
current_instance.s.headers.update({"Accept-encoding": 'gzip'})
current_instance.s.get(f'https://{current_instance.instance}/') # Get cookies from unauthorized instance for working some functionality (radios)
# Get cookies from unauthorized instance for working some functionality (radios)
current_instance.s.get(f'https://{current_instance.instance}/')
set_http_header()
@logger.catch
def get_instance_settings():
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/instance/settings')
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/instance/settings')
return r.json()
@logger.catch
def get_audio_file(track_uuid, listen_url=False, download=False,
def get_audio_file(track_uuid, listen_url=False, download=False,
transcoding=get_config('enable_server_transcoding'), to='ogg'):
if not transcoding:
to = None
params = {
"download": download,
"to": to
"download": download,
"to": to
}
if listen_url:
url = f'https://{current_instance.instance}{track_uuid}?'
@ -88,18 +92,19 @@ def get_tracks(page=None, q=None, artist=None, album=None,
tag=None, favourites=None, include_channels=None, pg=None):
'''This function get tracks by params'''
params = {
'page': page,
'q': q,
'artist': artist,
'album': album,
'tag': tag,
'favourites': favourites,
'include_channels': include_channels
'page': page,
'q': q,
'artist': artist,
'album': album,
'tag': tag,
'favourites': favourites,
'include_channels': include_channels
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/tracks', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/tracks', params=params)
return r.json()
@ -107,15 +112,16 @@ def get_tracks(page=None, q=None, artist=None, album=None,
def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, pg=None):
'''This function get favorites tracks (not only for user)'''
params = {
'page': page,
'q': q,
'scope': scope,
'include_channels': include_channels
'page': page,
'q': q,
'scope': scope,
'include_channels': include_channels
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/favorites/tracks/', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/favorites/tracks/', params=params)
return r.json()
@ -123,17 +129,18 @@ def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, p
def get_artists(page=None, q=None, artist=None, album=None, favourites=None, refresh=False, pg=None):
'''This function get artists by params'''
params = {
'page': page,
'q': q,
'artist': artist,
'album': album,
'favourites': favourites,
'refresh': refresh
'page': page,
'q': q,
'artist': artist,
'album': album,
'favourites': favourites,
'refresh': refresh
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/artists', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/artists', params=params)
return r.json()
@ -141,30 +148,32 @@ def get_artists(page=None, q=None, artist=None, album=None, favourites=None, ref
def get_albums(page=None, q=None, artist=None, include_channels=None, refresh=False, pg=None):
'''This function get artists by params'''
params = {
'page': page,
'q': q,
'artist': artist,
'include_channels': include_channels,
'refresh': refresh
'page': page,
'q': q,
'artist': artist,
'include_channels': include_channels,
'refresh': refresh
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/albums', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/albums', params=params)
return r.json()
@logger.catch
def get_channels(page=None, q=None, tag=None, pg=None):
params = {
'page': page,
'q': q,
'tag': tag
'page': page,
'q': q,
'tag': tag
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/channels', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/channels', params=params)
return r.json()
@ -172,15 +181,16 @@ def get_channels(page=None, q=None, tag=None, pg=None):
def get_playlists(page=None, page_size=None, q=None, ordering='-modification_date', pg=None):
'''List playlists'''
params = {
'page': page,
'page_size': page_size,
'q': q,
'ordering': ordering
'page': page,
'page_size': page_size,
'q': q,
'ordering': ordering
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/playlists', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/playlists', params=params)
r.raise_for_status()
return r.json()
@ -191,90 +201,101 @@ def get_playlist_tracks(playlist_id, pg=None):
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/playlists/{playlist_id}/tracks')
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/playlists/{playlist_id}/tracks')
return r.json()
@logger.catch
def list_libraries(page=None, page_size=None, q=None, scope='all', pg=None):
params = {
'page': page,
'page_size': page_size,
'q': q,
'scope': scope,
'page': page,
'page_size': page_size,
'q': q,
'scope': scope,
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/libraries', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/libraries', params=params)
return r.json()
@logger.catch
def get_tags(q=None, pg=None):
params = {
'q': q,
'q': q,
}
if pg:
r = current_instance.s.get(pg)
else:
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/tags', params=params)
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/tags', params=params)
return r.json()
@logger.catch
def federate_search_by_url(object):
params = {
'object': object
'object': object
}
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/federation/fetches', json=params)
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/federation/fetches', json=params)
return r.json()
@logger.catch
def record_track_in_history(track_id):
params = {
'track': int(track_id)
'track': int(track_id)
}
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/history/listenings', json=params)
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/history/listenings', json=params)
r.raise_for_status()
return r.json
@logger.catch
def favorite_track(track_id):
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/favorites/tracks', json={'track': int(track_id)})
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/favorites/tracks', json={'track': int(track_id)})
r.raise_for_status()
return r.json
@logger.catch
def unfavorite_track(track_id):
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/favorites/tracks/delete', json={'track': int(track_id)})
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/favorites/tracks/delete', json={'track': int(track_id)})
r.raise_for_status()
return r.json
return r.json
@logger.catch
def hide_content(content):
'''This function hide content (write permission)'''
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/moderation/content-filters/', json=content)
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/moderation/content-filters/', json=content)
r.raise_for_status()
return r.json
# [FunkWhale radios]
def get_radios():
r = current_instance.s.get(f'https://{current_instance.instance}/api/v1/radios/radios/')
r = current_instance.s.get(
f'https://{current_instance.instance}/api/v1/radios/radios/')
return r.json()
def post_radio_session(requested_radio):
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/radios/sessions/', json=requested_radio)
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/radios/sessions/', json=requested_radio)
return r.json()
@logger.catch
def get_track_radio(radio_session):
r = current_instance.s.post(f'https://{current_instance.instance}/api/v1/radios/tracks/', json=radio_session)
r = current_instance.s.post(
f'https://{current_instance.instance}/api/v1/radios/tracks/', json=radio_session)
return r.json()

View file

@ -6,9 +6,10 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_artists(pg=None, search=None):
artists = get_artists(q=search,pg=pg)
artists = get_artists(q=search, pg=pg)
artists_next = artists.get('next')
artists_prev = artists.get('previous')
artists_results = artists.get('results')
@ -52,7 +53,8 @@ def play_artist(artist_id):
storage[track_url_to_uuid(listen_url)] = i
player.loadfile(listen_url, 'append-play')
if tracks_next:
tracks = get_tracks(artist=artist_id, include_channels=True, pg=tracks_next)
tracks = get_tracks(
artist=artist_id, include_channels=True, pg=tracks_next)
else:
break
artist_name = tracks.get('results')[0]['artist']['name']

View file

@ -34,4 +34,5 @@ def list_channels(pg=None, search=None):
refresh = False
if channels_results[int(select)].get('artist').get('is_local') == False:
refresh = True
list_albums(artist=channels_results[int(select)].get('artist').get('id'), include_channels=True, refresh=refresh)
list_albums(artist=channels_results[int(select)].get(
'artist').get('id'), include_channels=True, refresh=refresh)

View file

@ -5,6 +5,7 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_favorites_tracks(pg=None, search=None, scope=None):
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
@ -48,9 +49,11 @@ Limit the results to a given user or pod:
play_track(track=i['track'], multi=True)
elif len(select) > 1:
for i in select:
play_track(track=tracks_results[int(i.split('.', 1)[0])]['track'], multi=True)
play_track(track=tracks_results[int(
i.split('.', 1)[0])]['track'], multi=True)
else:
play_track(track=tracks_results[int(select[0].split('.', 1)[0])]['track'])
play_track(track=tracks_results[int(
select[0].split('.', 1)[0])]['track'])
def play_track(track, multi=False):

View file

@ -21,7 +21,8 @@ def libraries(pg=None):
lib_name = lib_i.get('name')
lib_by = lib_i.get('actor').get('full_username')
libraries_listing.append(f'{index}.{lib_name} | by {lib_by}')
lib_select = fzf.prompt(libraries_listing, f'--header=\'found {libs_count} libraries\'')[0].split('.', 1)
lib_select = fzf.prompt(
libraries_listing, f'--header=\'found {libs_count} libraries\'')[0].split('.', 1)
if lib_select[0] == 'Next':
libraries(pg=libs_next)
elif lib_select[0] == 'Prev':
@ -31,4 +32,3 @@ def libraries(pg=None):
lib_name = lib_select[1]
lib_uuid = libs[int(lib_addr)].get('uuid')
return None, 'library', lib_name, lib_uuid

View file

@ -5,6 +5,7 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_playlists(pg=None, search=None):
playlists = get_playlists(q=search, pg=pg)
@ -32,6 +33,7 @@ def list_playlists(pg=None, search=None):
else:
play_playlist(playlist_id=playlists_results[int(select)].get('id'))
def play_playlist(playlist_id):
tracks = get_playlist_tracks(playlist_id, pg=None)
tracks_next = tracks.get('next')

View file

@ -19,7 +19,7 @@ def list_radios():
results = radios.get('results')
view = []
for i in results:
for i in results:
index = results.index(i)
id_radio = i.get('id')
name = i.get('name')
@ -28,12 +28,14 @@ def list_radios():
if descr and descr != "":
radio_option += f' | {descr}'
view.append(f'{index}.{radio_option}')
if current_instance.s.headers.get('Authorization'): # Radios avalaible only for auth user
# Radios avalaible only for auth user
if current_instance.s.headers.get('Authorization'):
view.append('Favourites')
view.append('Less listened')
view.extend(['Tag', 'Random', 'Libraries', 'Users', 'Recently Added'])
selected = fzf.prompt(view, f'--header \'Found {count} radios\' --read0', delimiter="\0")[0].split('.', 1)
selected = fzf.prompt(
view, f'--header \'Found {count} radios\' --read0', delimiter="\0")[0].split('.', 1)
if 'Favourites' in selected:
radio_load(id_radio, 'favorites', name='your favorites tracks')
elif 'Tag' in selected:
@ -58,7 +60,8 @@ def list_radios():
lib_addr = input()
radio_load(None, 'actor-content', lib_addr, lib_addr)
elif 'Recently Added' in selected:
radio_load(id_radio, 'recently-added', name='Newest content on the network')
radio_load(id_radio, 'recently-added',
name='Newest content on the network')
elif 'Less listened' in selected:
radio_load(id_radio, 'less-listened', name="Less listened tracks")
else:
@ -72,16 +75,18 @@ def radio_generator(radio_session_id):
count_t = 0
while radio_session_id != '':
time.sleep(1)
if not radio_event_gen.wait(0):
if not radio_event_gen.wait(0):
break
count_t += 1
if count_t >= 60:
count_t = 0
playlist_remaining = len(player.playlist) - player.playlist_current_pos
if playlist_remaining <= 2:
playlist_remaining = len(player.playlist) - \
player.playlist_current_pos
if playlist_remaining <= 2:
radio_get_track(radio_session_id)
logger.info('Radio generator stopped')
radio_event_gen = threading.Event()
@ -90,18 +95,19 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
show_like_button = get_config('show_like_button')
player.volume = get_config('mpv_volume')
requested_radio = {
'custom_radio': id_radio,
'radio_type': type_radio,
'related_object_id': related_object
}
'custom_radio': id_radio,
'radio_type': type_radio,
'related_object_id': related_object
}
radio_session_id = post_radio_session(requested_radio).get('id')
for i in range(0, 2):
radio_get_track(radio_session_id)
radio_event_gen.set()
radio_task = threading.Thread(target=radio_generator, args=(radio_session_id,), daemon=True)
radio_task = threading.Thread(
target=radio_generator, args=(radio_session_id,), daemon=True)
radio_task.start()
player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info']
player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info']
if show_like_button:
player_items_menu.append('Like')
@ -112,11 +118,14 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
player_items_menu[2] = 'Play'
else:
player_items_menu[2] = 'Pause'
select = fzf.prompt(player_items_menu, f"--header=\'Radio {name} playing...\'")[0]
select = fzf.prompt(player_items_menu,
f"--header=\'Radio {name} playing...\'")[0]
if select == 'Next':
playlist_remaining = len(player.playlist) - player.playlist_current_pos
playlist_remaining = len(
player.playlist) - player.playlist_current_pos
if playlist_remaining <= 2:
threading.Thread(target=radio_get_track, args=(radio_session_id,), daemon=True).start()
threading.Thread(target=radio_get_track, args=(
radio_session_id,), daemon=True).start()
player.playlist_next()
elif select == 'Prev':
player.playlist_prev()
@ -134,13 +143,14 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
name_aa = track.get(i).get('name')
if not name_aa:
name_aa = track[i]['title']
print(i + ': '+ name_aa)
print(i + ': ' + name_aa)
key = track.get(i)
if key and isinstance(key, str):
print(i + ': ' + key)
input()
elif select == 'Like':
favorite_track(player_fw_storage.storage.get(track_url_to_uuid())['id'])
favorite_track(player_fw_storage.storage.get(
track_url_to_uuid())['id'])
elif select == 'Exit':
try:
radio_event_gen.clear()
@ -151,7 +161,7 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
player.stop()
player_fw_storage.storage = {}
break
except:
except:
try:
radio_event_gen.clear()
except:
@ -180,6 +190,5 @@ def radio_get_track(radio_session_id):
track = radio_context.get('track')
listen_url = track['listen_url']
player_fw_storage.storage[track_url_to_uuid(listen_url)] = track
player.loadfile(get_audio_file(listen_url, listen_url=True), 'append-play')
player.loadfile(get_audio_file(
listen_url, listen_url=True), 'append-play')

View file

@ -4,6 +4,7 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_tags(pg=None, search=None):
tags = get_tags(q=search, pg=pg)
@ -30,4 +31,3 @@ def list_tags(pg=None, search=None):
return list_tags(search=input())
else:
return tags_results[int(select)].get('name')

View file

@ -6,6 +6,7 @@ from loguru import logger
fzf = FzfPrompt()
@logger.catch
def list_tracks(pg=None, search=None, tag=None):
tracks = get_tracks(q=search, pg=pg, tag=tag)
@ -38,4 +39,3 @@ def list_tracks(pg=None, search=None, tag=None):
play_track(track=i, multi=True)
else:
play_track(track=tracks_results[int(select)])

View file

@ -9,8 +9,9 @@ import time
fzf = FzfPrompt()
player = mpv.MPV()
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
player.ytdl = False # Prevent attempts load track with yt-dlp
player.volume = get_config('mpv_volume')
player.prefetch_playlist = get_config('prefetch_playlist')
show_like_button = get_config('show_like_button')
track_activity_history = get_config('track_activity_history')
@ -29,14 +30,14 @@ def track_url_to_uuid(listen_url=None):
return uuid
if track_activity_history:
if track_activity_history:
@player.property_observer('time-pos')
@logger.catch
def time_observer(_name, value):
# Here, _value is either None if nothing is playing or a float containing
# fractional seconds since the beginning of the file.
if value and player.http_header_fields != [] and player.pause is False:
if value >= 30.0 and value <= 30.1:
if value >= 30.0 and value <= 30.1:
# detect 30 secs for reporting listen activity
track = player_fw_storage.storage.get(track_url_to_uuid())
track_id = track.get('id')
@ -58,7 +59,7 @@ def player_menu(header='', storage={}):
while True:
try:
player_items_menu = ['Next', 'Prev', 'Pause',
'Download', 'Info']
'Download', 'Info']
if player.pause:
player_items_menu[2] = 'Play'
else:
@ -86,16 +87,18 @@ def player_menu(header='', storage={}):
name_aa = track.get(i).get('name')
if not name_aa:
name_aa = track.get(i).get('title')
print(i + ': '+ name_aa)
print(i + ': ' + name_aa)
key = track.get(i)
if key and isinstance(key, str):
print(i + ': ' + key)
input()
elif select == 'Like':
src.fw_api.favorite_track(player_fw_storage.storage.get(track_url_to_uuid())['id'])
src.fw_api.favorite_track(
player_fw_storage.storage.get(track_url_to_uuid())['id'])
elif select == 'Hide artist':
track = player_fw_storage.storage.get(track_url_to_uuid())
src.fw_api.hide_content({'target': {'id': track.get('artist').get('id'), 'type': 'artist'}})
src.fw_api.hide_content(
{'target': {'id': track.get('artist').get('id'), 'type': 'artist'}})
elif select == 'Exit':
player.playlist_clear()
player.stop()

View file

@ -1,4 +1,6 @@
import json, requests, time
import json
import requests
import time
from os.path import exists
from loguru import logger
from pyfzf.pyfzf import FzfPrompt
@ -8,42 +10,42 @@ fzf = FzfPrompt()
conf_file = 'config.json'
default_conf = {
'instance': 'fw.ponychord.rocks',
'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"
],
'enable_server_transcoding': False,
'track_activity_history': False,
'prefetch_playlist': True,
'mpv_volume': 100,
'show_like_button': True,
'show_artist_name_in_albums': False
'instance': 'fw.ponychord.rocks',
'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"
],
'enable_server_transcoding': False,
'track_activity_history': False,
'prefetch_playlist': True,
'mpv_volume': 100,
'show_like_button': True,
'show_artist_name_in_albums': False
}
@ -71,7 +73,7 @@ def check_config():
logger.warning(f'{k} added in config. Value: {v}')
set_defaults(correct_conf)
return correct_conf
if not exists(conf_file):
set_defaults()
@ -97,15 +99,15 @@ def get_new_funkwhale_servers():
'from': f"{timeback}",
'to': f"{now}",
'queries': [
{
'refId': "A",
'intervalMs': 60000,
'maxDataPoints': 1174,
'datasourceId': 1,
'rawSql': "SELECT * FROM (\n SELECT\n DISTINCT on (c.domain) c.domain as \"Name\",\n c.up as \"Is up\",\n coalesce(c.open_registrations, false) as \"Open registrations\",\n coalesce(anonymous_can_listen, false) as \"Anonymous can listen\",\n coalesce(c.usage_users_total, 0) as \"Total users\",\n coalesce(c.usage_users_active_month, 0) as \"Active users (this month)\",\n coalesce(c.software_version_major, 0)::text || '.' || coalesce(c.software_version_minor, 0)::text || '.' || coalesce(c.software_version_patch, 0)::text as \"Version\",\n c.time as \"Last checked\",\n d.first_seen as \"First seen\"\n FROM checks as c\n INNER JOIN domains AS d ON d.name = c.domain\n WHERE d.blocked = false AND c.up = true AND c.time > now() - INTERVAL '7 days'\n AND c.anonymous_can_listen IN ('true')\n AND c.open_registrations IN ('true','false')\n\n ORDER BY c.domain, c.time DESC\n) as t ORDER BY \"Active users (this month)\" DESC",
'format': "table"
}
]
{
'refId': "A",
'intervalMs': 60000,
'maxDataPoints': 1174,
'datasourceId': 1,
'rawSql': "SELECT * FROM (\n SELECT\n DISTINCT on (c.domain) c.domain as \"Name\",\n c.up as \"Is up\",\n coalesce(c.open_registrations, false) as \"Open registrations\",\n coalesce(anonymous_can_listen, false) as \"Anonymous can listen\",\n coalesce(c.usage_users_total, 0) as \"Total users\",\n coalesce(c.usage_users_active_month, 0) as \"Active users (this month)\",\n coalesce(c.software_version_major, 0)::text || '.' || coalesce(c.software_version_minor, 0)::text || '.' || coalesce(c.software_version_patch, 0)::text as \"Version\",\n c.time as \"Last checked\",\n d.first_seen as \"First seen\"\n FROM checks as c\n INNER JOIN domains AS d ON d.name = c.domain\n WHERE d.blocked = false AND c.up = true AND c.time > now() - INTERVAL '7 days'\n AND c.anonymous_can_listen IN ('true')\n AND c.open_registrations IN ('true','false')\n\n ORDER BY c.domain, c.time DESC\n) as t ORDER BY \"Active users (this month)\" DESC",
'format': "table"
}
]
}
r = requests.post(public_server_api, json=request_public_servers)
@ -117,4 +119,3 @@ def get_new_funkwhale_servers():
if i[0] not in default_conf['public_list_instances'] and i[1]:
new_instances.append(i[0])
return new_instances

View file

@ -13,7 +13,7 @@ def get_remote_file_name(url):
def download_track(url, name=None):
url = url.split('?')[0] # Stripe all params from url
url = url.split('?')[0] # Stripe all params from url
r = src.fw_api.current_instance.s.get(url, stream=True)
if not name:
name = get_remote_file_name(url)
@ -24,7 +24,7 @@ def download_track(url, name=None):
print(f"Downloading {name}")
total_length = r.headers.get('content-length')
if total_length is None: # no content length header
if total_length is None: # no content length header
f.write(r.content)
else:
dl = 0
@ -33,6 +33,7 @@ def download_track(url, name=None):
dl += len(data)
f.write(data)
done = int(50 * dl / total_length)
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)) ) # base progress bar
# base progress bar
sys.stdout.write("\r[%s%s]" % ('=' * done, ' ' * (50-done)))
sys.stdout.flush()
return name