mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 01:23:02 +00:00
autopep8 fixes
This commit is contained in:
parent
6c5113abcc
commit
86bbdcf0ea
@ -10,13 +10,16 @@ from src.fw_playlists import list_playlists
|
|||||||
from src.fw_fav_tracks import list_favorites_tracks
|
from src.fw_fav_tracks import list_favorites_tracks
|
||||||
import src.settings as settings
|
import src.settings as settings
|
||||||
import src.mpv_control
|
import src.mpv_control
|
||||||
import json, sys, time
|
import json
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
from shlex import quote
|
from shlex import quote
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -78,7 +81,8 @@ def main():
|
|||||||
conf = json.loads(f.read())
|
conf = json.loads(f.read())
|
||||||
public_server_list_instances = settings.get_new_funkwhale_servers()
|
public_server_list_instances = settings.get_new_funkwhale_servers()
|
||||||
new_ins_count = len(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
|
list_instances = conf.get(
|
||||||
|
'public_list_instances') + public_server_list_instances
|
||||||
instance = fzf.prompt(list_instances,
|
instance = fzf.prompt(list_instances,
|
||||||
'--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))[0]
|
'--header='+quote(f'Select instance\nServer instances: +{new_ins_count}'))[0]
|
||||||
current_instance.select_instance(instance)
|
current_instance.select_instance(instance)
|
||||||
@ -106,8 +110,8 @@ Insert token from "Access token" here''')
|
|||||||
print(support_message)
|
print(support_message)
|
||||||
input()
|
input()
|
||||||
if selected == 'Player':
|
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__':
|
if __name__ == '__main__':
|
||||||
|
@ -7,6 +7,7 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_albums(albums=None, pg=None, search=None, artist=None, include_channels=None, refresh=False):
|
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')
|
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
|
albums_prev = None
|
||||||
play_artist_albums = False
|
play_artist_albums = False
|
||||||
if not albums:
|
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_next = albums.get('next')
|
||||||
albums_prev = albums.get('previous')
|
albums_prev = albums.get('previous')
|
||||||
albums_results = albums.get('results')
|
albums_results = albums.get('results')
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
from src.mpv_control import set_http_header
|
from src.mpv_control import set_http_header
|
||||||
from src.settings import get_config
|
from src.settings import get_config
|
||||||
import requests, json, time
|
import requests
|
||||||
|
import json
|
||||||
|
import time
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import os
|
import os
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
@ -57,13 +59,15 @@ if current_instance.token:
|
|||||||
set_http_header(['Authorization: ' + 'Bearer ' + current_instance.token])
|
set_http_header(['Authorization: ' + 'Bearer ' + current_instance.token])
|
||||||
else:
|
else:
|
||||||
current_instance.s.headers.update({"Accept-encoding": 'gzip'})
|
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()
|
set_http_header()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_instance_settings():
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +103,8 @@ def get_tracks(page=None, q=None, artist=None, album=None,
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -115,7 +120,8 @@ def get_favorires_tracks(page=None, q=None, scope=None, include_channels=None, p
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -133,7 +139,8 @@ def get_artists(page=None, q=None, artist=None, album=None, favourites=None, ref
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -150,7 +157,8 @@ def get_albums(page=None, q=None, artist=None, include_channels=None, refresh=Fa
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -164,7 +172,8 @@ def get_channels(page=None, q=None, tag=None, pg=None):
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +189,8 @@ def get_playlists(page=None, page_size=None, q=None, ordering='-modification_dat
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
r.raise_for_status()
|
||||||
return r.json()
|
return r.json()
|
||||||
|
|
||||||
@ -191,7 +201,8 @@ def get_playlist_tracks(playlist_id, pg=None):
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -206,9 +217,11 @@ def list_libraries(page=None, page_size=None, q=None, scope='all', pg=None):
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_tags(q=None, pg=None):
|
def get_tags(q=None, pg=None):
|
||||||
params = {
|
params = {
|
||||||
@ -217,7 +230,8 @@ def get_tags(q=None, pg=None):
|
|||||||
if pg:
|
if pg:
|
||||||
r = current_instance.s.get(pg)
|
r = current_instance.s.get(pg)
|
||||||
else:
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -226,7 +240,8 @@ def federate_search_by_url(object):
|
|||||||
params = {
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@ -235,21 +250,24 @@ def record_track_in_history(track_id):
|
|||||||
params = {
|
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()
|
r.raise_for_status()
|
||||||
return r.json
|
return r.json
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def favorite_track(track_id):
|
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()
|
r.raise_for_status()
|
||||||
return r.json
|
return r.json
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def unfavorite_track(track_id):
|
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()
|
r.raise_for_status()
|
||||||
return r.json
|
return r.json
|
||||||
|
|
||||||
@ -257,24 +275,27 @@ def unfavorite_track(track_id):
|
|||||||
@logger.catch
|
@logger.catch
|
||||||
def hide_content(content):
|
def hide_content(content):
|
||||||
'''This function hide content (write permission)'''
|
'''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()
|
r.raise_for_status()
|
||||||
return r.json
|
return r.json
|
||||||
|
|
||||||
|
|
||||||
# [FunkWhale radios]
|
# [FunkWhale radios]
|
||||||
def get_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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
def post_radio_session(requested_radio):
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def get_track_radio(radio_session):
|
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()
|
return r.json()
|
||||||
|
|
||||||
|
@ -6,9 +6,10 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_artists(pg=None, search=None):
|
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_next = artists.get('next')
|
||||||
artists_prev = artists.get('previous')
|
artists_prev = artists.get('previous')
|
||||||
artists_results = artists.get('results')
|
artists_results = artists.get('results')
|
||||||
@ -52,7 +53,8 @@ def play_artist(artist_id):
|
|||||||
storage[track_url_to_uuid(listen_url)] = i
|
storage[track_url_to_uuid(listen_url)] = i
|
||||||
player.loadfile(listen_url, 'append-play')
|
player.loadfile(listen_url, 'append-play')
|
||||||
if tracks_next:
|
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:
|
else:
|
||||||
break
|
break
|
||||||
artist_name = tracks.get('results')[0]['artist']['name']
|
artist_name = tracks.get('results')[0]['artist']['name']
|
||||||
|
@ -34,4 +34,5 @@ def list_channels(pg=None, search=None):
|
|||||||
refresh = False
|
refresh = False
|
||||||
if channels_results[int(select)].get('artist').get('is_local') == False:
|
if channels_results[int(select)].get('artist').get('is_local') == False:
|
||||||
refresh = True
|
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)
|
||||||
|
@ -5,6 +5,7 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_favorites_tracks(pg=None, search=None, scope=None):
|
def list_favorites_tracks(pg=None, search=None, scope=None):
|
||||||
tracks = get_favorires_tracks(q=search, scope=scope, pg=pg)
|
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)
|
play_track(track=i['track'], multi=True)
|
||||||
elif len(select) > 1:
|
elif len(select) > 1:
|
||||||
for i in select:
|
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:
|
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):
|
def play_track(track, multi=False):
|
||||||
|
@ -21,7 +21,8 @@ def libraries(pg=None):
|
|||||||
lib_name = lib_i.get('name')
|
lib_name = lib_i.get('name')
|
||||||
lib_by = lib_i.get('actor').get('full_username')
|
lib_by = lib_i.get('actor').get('full_username')
|
||||||
libraries_listing.append(f'{index}.{lib_name} | by {lib_by}')
|
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':
|
if lib_select[0] == 'Next':
|
||||||
libraries(pg=libs_next)
|
libraries(pg=libs_next)
|
||||||
elif lib_select[0] == 'Prev':
|
elif lib_select[0] == 'Prev':
|
||||||
@ -31,4 +32,3 @@ def libraries(pg=None):
|
|||||||
lib_name = lib_select[1]
|
lib_name = lib_select[1]
|
||||||
lib_uuid = libs[int(lib_addr)].get('uuid')
|
lib_uuid = libs[int(lib_addr)].get('uuid')
|
||||||
return None, 'library', lib_name, lib_uuid
|
return None, 'library', lib_name, lib_uuid
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_playlists(pg=None, search=None):
|
def list_playlists(pg=None, search=None):
|
||||||
playlists = get_playlists(q=search, pg=pg)
|
playlists = get_playlists(q=search, pg=pg)
|
||||||
@ -32,6 +33,7 @@ def list_playlists(pg=None, search=None):
|
|||||||
else:
|
else:
|
||||||
play_playlist(playlist_id=playlists_results[int(select)].get('id'))
|
play_playlist(playlist_id=playlists_results[int(select)].get('id'))
|
||||||
|
|
||||||
|
|
||||||
def play_playlist(playlist_id):
|
def play_playlist(playlist_id):
|
||||||
tracks = get_playlist_tracks(playlist_id, pg=None)
|
tracks = get_playlist_tracks(playlist_id, pg=None)
|
||||||
tracks_next = tracks.get('next')
|
tracks_next = tracks.get('next')
|
||||||
|
@ -28,12 +28,14 @@ def list_radios():
|
|||||||
if descr and descr != "":
|
if descr and descr != "":
|
||||||
radio_option += f' | {descr}'
|
radio_option += f' | {descr}'
|
||||||
view.append(f'{index}.{radio_option}')
|
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('Favourites')
|
||||||
view.append('Less listened')
|
view.append('Less listened')
|
||||||
view.extend(['Tag', 'Random', 'Libraries', 'Users', 'Recently Added'])
|
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:
|
if 'Favourites' in selected:
|
||||||
radio_load(id_radio, 'favorites', name='your favorites tracks')
|
radio_load(id_radio, 'favorites', name='your favorites tracks')
|
||||||
elif 'Tag' in selected:
|
elif 'Tag' in selected:
|
||||||
@ -58,7 +60,8 @@ def list_radios():
|
|||||||
lib_addr = input()
|
lib_addr = input()
|
||||||
radio_load(None, 'actor-content', lib_addr, lib_addr)
|
radio_load(None, 'actor-content', lib_addr, lib_addr)
|
||||||
elif 'Recently Added' in selected:
|
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:
|
elif 'Less listened' in selected:
|
||||||
radio_load(id_radio, 'less-listened', name="Less listened tracks")
|
radio_load(id_radio, 'less-listened', name="Less listened tracks")
|
||||||
else:
|
else:
|
||||||
@ -77,11 +80,13 @@ def radio_generator(radio_session_id):
|
|||||||
count_t += 1
|
count_t += 1
|
||||||
if count_t >= 60:
|
if count_t >= 60:
|
||||||
count_t = 0
|
count_t = 0
|
||||||
playlist_remaining = len(player.playlist) - player.playlist_current_pos
|
playlist_remaining = len(player.playlist) - \
|
||||||
|
player.playlist_current_pos
|
||||||
if playlist_remaining <= 2:
|
if playlist_remaining <= 2:
|
||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
logger.info('Radio generator stopped')
|
logger.info('Radio generator stopped')
|
||||||
|
|
||||||
|
|
||||||
radio_event_gen = threading.Event()
|
radio_event_gen = threading.Event()
|
||||||
|
|
||||||
|
|
||||||
@ -99,7 +104,8 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||||||
radio_get_track(radio_session_id)
|
radio_get_track(radio_session_id)
|
||||||
|
|
||||||
radio_event_gen.set()
|
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()
|
radio_task.start()
|
||||||
player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info']
|
player_items_menu = ['Next', 'Prev', 'Pause', 'Download', 'Info']
|
||||||
|
|
||||||
@ -112,11 +118,14 @@ def radio_load(id_radio=None, type_radio='custom', name=None, related_object=Non
|
|||||||
player_items_menu[2] = 'Play'
|
player_items_menu[2] = 'Play'
|
||||||
else:
|
else:
|
||||||
player_items_menu[2] = 'Pause'
|
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':
|
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:
|
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()
|
player.playlist_next()
|
||||||
elif select == 'Prev':
|
elif select == 'Prev':
|
||||||
player.playlist_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')
|
name_aa = track.get(i).get('name')
|
||||||
if not name_aa:
|
if not name_aa:
|
||||||
name_aa = track[i]['title']
|
name_aa = track[i]['title']
|
||||||
print(i + ': '+ name_aa)
|
print(i + ': ' + name_aa)
|
||||||
key = track.get(i)
|
key = track.get(i)
|
||||||
if key and isinstance(key, str):
|
if key and isinstance(key, str):
|
||||||
print(i + ': ' + key)
|
print(i + ': ' + key)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
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':
|
elif select == 'Exit':
|
||||||
try:
|
try:
|
||||||
radio_event_gen.clear()
|
radio_event_gen.clear()
|
||||||
@ -180,6 +190,5 @@ def radio_get_track(radio_session_id):
|
|||||||
track = radio_context.get('track')
|
track = radio_context.get('track')
|
||||||
listen_url = track['listen_url']
|
listen_url = track['listen_url']
|
||||||
player_fw_storage.storage[track_url_to_uuid(listen_url)] = track
|
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')
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_tags(pg=None, search=None):
|
def list_tags(pg=None, search=None):
|
||||||
tags = get_tags(q=search, pg=pg)
|
tags = get_tags(q=search, pg=pg)
|
||||||
@ -30,4 +31,3 @@ def list_tags(pg=None, search=None):
|
|||||||
return list_tags(search=input())
|
return list_tags(search=input())
|
||||||
else:
|
else:
|
||||||
return tags_results[int(select)].get('name')
|
return tags_results[int(select)].get('name')
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ from loguru import logger
|
|||||||
|
|
||||||
fzf = FzfPrompt()
|
fzf = FzfPrompt()
|
||||||
|
|
||||||
|
|
||||||
@logger.catch
|
@logger.catch
|
||||||
def list_tracks(pg=None, search=None, tag=None):
|
def list_tracks(pg=None, search=None, tag=None):
|
||||||
tracks = get_tracks(q=search, pg=pg, tag=tag)
|
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)
|
play_track(track=i, multi=True)
|
||||||
else:
|
else:
|
||||||
play_track(track=tracks_results[int(select)])
|
play_track(track=tracks_results[int(select)])
|
||||||
|
|
||||||
|
@ -10,7 +10,8 @@ fzf = FzfPrompt()
|
|||||||
|
|
||||||
player = mpv.MPV()
|
player = mpv.MPV()
|
||||||
player.ytdl = False # Prevent attempts load track with yt-dlp
|
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.volume = get_config('mpv_volume')
|
||||||
|
player.prefetch_playlist = get_config('prefetch_playlist')
|
||||||
show_like_button = get_config('show_like_button')
|
show_like_button = get_config('show_like_button')
|
||||||
track_activity_history = get_config('track_activity_history')
|
track_activity_history = get_config('track_activity_history')
|
||||||
|
|
||||||
@ -86,16 +87,18 @@ def player_menu(header='', storage={}):
|
|||||||
name_aa = track.get(i).get('name')
|
name_aa = track.get(i).get('name')
|
||||||
if not name_aa:
|
if not name_aa:
|
||||||
name_aa = track.get(i).get('title')
|
name_aa = track.get(i).get('title')
|
||||||
print(i + ': '+ name_aa)
|
print(i + ': ' + name_aa)
|
||||||
key = track.get(i)
|
key = track.get(i)
|
||||||
if key and isinstance(key, str):
|
if key and isinstance(key, str):
|
||||||
print(i + ': ' + key)
|
print(i + ': ' + key)
|
||||||
input()
|
input()
|
||||||
elif select == 'Like':
|
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':
|
elif select == 'Hide artist':
|
||||||
track = player_fw_storage.storage.get(track_url_to_uuid())
|
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':
|
elif select == 'Exit':
|
||||||
player.playlist_clear()
|
player.playlist_clear()
|
||||||
player.stop()
|
player.stop()
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
import json, requests, time
|
import json
|
||||||
|
import requests
|
||||||
|
import time
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
from pyfzf.pyfzf import FzfPrompt
|
from pyfzf.pyfzf import FzfPrompt
|
||||||
@ -117,4 +119,3 @@ def get_new_funkwhale_servers():
|
|||||||
if i[0] not in default_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])
|
new_instances.append(i[0])
|
||||||
return new_instances
|
return new_instances
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ def download_track(url, name=None):
|
|||||||
dl += len(data)
|
dl += len(data)
|
||||||
f.write(data)
|
f.write(data)
|
||||||
done = int(50 * dl / total_length)
|
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()
|
sys.stdout.flush()
|
||||||
return name
|
return name
|
||||||
|
Loading…
Reference in New Issue
Block a user