mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2025-02-16 20:24:28 +00:00
Compare commits
4 commits
adfa00aeb4
...
96ce0dfb50
Author | SHA1 | Date | |
---|---|---|---|
|
96ce0dfb50 | ||
|
38212d29b4 | ||
|
4c5cb88a61 | ||
|
35879ac63e |
|
@ -106,7 +106,13 @@ def main():
|
|||
If You want sign in, please visit:
|
||||
https://{current_instance.instance}/settings/applications/new
|
||||
And fill Name funkwhale-cli
|
||||
Scopes: Read, Write (optional): write:favorites write:listenings write:filters
|
||||
Scopes:
|
||||
Read | Write (optional):
|
||||
write:libraries
|
||||
write:favorites
|
||||
write:listenings
|
||||
write:follows
|
||||
write:filters
|
||||
|
||||
Insert token from "Access token" here''')
|
||||
register_token = input()
|
||||
|
|
|
@ -70,7 +70,7 @@ def list_albums(albums=None, pg=None, search=None, artist=None, library=None, in
|
|||
|
||||
|
||||
def play_album(album_id):
|
||||
tracks = get_tracks(album=album_id, include_channels=True)
|
||||
tracks = get_tracks(album=album_id, ordering='disc_number,position', include_channels=True)
|
||||
tracks_results = tracks.get('results')
|
||||
storage = {}
|
||||
for i in tracks_results:
|
||||
|
|
|
@ -100,11 +100,13 @@ def get_audio_file(track_uuid, listen_url=False, download=False,
|
|||
|
||||
|
||||
@logger.catch
|
||||
def get_tracks(page=None, q=None, artist=None, album=None, library=None,
|
||||
def get_tracks(page=None, ordering=None, q=None,
|
||||
artist=None, album=None, library=None,
|
||||
tag=None, favourites=None, include_channels=None, pg=None):
|
||||
'''This function get tracks by params'''
|
||||
params = {
|
||||
'page': page,
|
||||
'ordering': ordering,
|
||||
'q': q,
|
||||
'artist': artist,
|
||||
'album': album,
|
||||
|
@ -178,10 +180,12 @@ def get_artists(page=None, q=None, artist=None, album=None,
|
|||
|
||||
|
||||
@logger.catch
|
||||
def get_albums(page=None, q=None, artist=None, library=None, include_channels=None, refresh=False, pg=None):
|
||||
def get_albums(page=None, q=None, ordering=None,
|
||||
artist=None, library=None, include_channels=None, refresh=False, pg=None):
|
||||
'''This function get artists by params'''
|
||||
params = {
|
||||
'page': page,
|
||||
'ordering': ordering,
|
||||
'q': q,
|
||||
'artist': artist,
|
||||
'library': library,
|
||||
|
@ -306,11 +310,10 @@ def federate_remote_library(fid):
|
|||
|
||||
@logger.catch
|
||||
def scan_remote_library(uuid):
|
||||
'''Scan remote library'''
|
||||
for i in range(attempts_for_federate):
|
||||
try:
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}')
|
||||
f'https://{current_instance.instance}/api/v1/federation/libraries/{uuid}/scan')
|
||||
r.raise_for_status()
|
||||
break
|
||||
except Exception as Err:
|
||||
|
@ -319,6 +322,30 @@ def scan_remote_library(uuid):
|
|||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def follow_on_remote_library(uuid):
|
||||
params = {'target': uuid}
|
||||
for i in range(attempts_for_federate):
|
||||
try:
|
||||
r = current_instance.s.post(
|
||||
f'https://{current_instance.instance}/api/v1/federation/follows/library/',
|
||||
json=params)
|
||||
r.raise_for_status()
|
||||
break
|
||||
except Exception as Err:
|
||||
logger.error(f'Attempt follow {i}: {Err}')
|
||||
time.sleep(3)
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def unfollow_remote_library(uuid):
|
||||
r = current_instance.s.delete(
|
||||
f'https://{current_instance.instance}/api/v1/federation/follows/library/{uuid}/')
|
||||
r.raise_for_status()
|
||||
return r.json()
|
||||
|
||||
|
||||
@logger.catch
|
||||
def record_track_in_history(track_id):
|
||||
params = {
|
||||
|
|
|
@ -55,7 +55,8 @@ def list_artists(pg=None, search=None, library=None, scope=None):
|
|||
|
||||
|
||||
def play_artist(artist_id):
|
||||
tracks = get_tracks(artist=artist_id, include_channels=True, pg=None)
|
||||
tracks = get_tracks(artist=artist_id, ordering='disc_number,position',
|
||||
include_channels=True, pg=None)
|
||||
tracks_next = tracks.get('next')
|
||||
tracks_count = tracks.get('count')
|
||||
storage = {}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from src.fw_api import current_instance, list_libraries, federate_remote_library, scan_remote_library
|
||||
from src.fw_api import current_instance, list_libraries, federate_remote_library, scan_remote_library, follow_on_remote_library
|
||||
from pyfzf.pyfzf import FzfPrompt
|
||||
from loguru import logger
|
||||
import time
|
||||
|
@ -41,13 +41,17 @@ def libraries(pg=None, radio=False):
|
|||
return libraries(pg=libs_prev)
|
||||
elif lib_select[0] == 'Add remote library':
|
||||
print('Search a remote library (url\\fid):')
|
||||
new_library = federate_remote_library(input())
|
||||
new_library = federate_remote_library(input().strip())
|
||||
if new_library.get('detail'):
|
||||
logger.error(new_library['detail'])
|
||||
return
|
||||
if new_library.get('count') > 0:
|
||||
print('Library found')
|
||||
one_lib = new_library['results'][0]
|
||||
if one_lib['privacy_level'] == 'private':
|
||||
logger.warning('This library is private, you should wait until your request is approved')
|
||||
|
||||
follow_on_remote_library(one_lib['uuid'])
|
||||
scan = scan_remote_library(one_lib['uuid'])
|
||||
if scan.get('detail'):
|
||||
logger.error(scan['detail'])
|
||||
|
|
|
@ -9,7 +9,6 @@ from loguru import logger
|
|||
from shlex import quote
|
||||
import threading
|
||||
import time
|
||||
import sys
|
||||
|
||||
fzf = FzfPrompt()
|
||||
|
||||
|
@ -94,8 +93,7 @@ def radio_generator(radio_session_id):
|
|||
player.playlist_current_pos
|
||||
if playlist_remaining <= 2:
|
||||
radio_get_track(radio_session_id)
|
||||
sys.stdout.write('\rRadio generator stopped')
|
||||
sys.stdout.flush()
|
||||
print('\rRadio generator stopped', flush=True)
|
||||
|
||||
|
||||
radio_event_gen = threading.Event()
|
||||
|
|
|
@ -23,6 +23,7 @@ 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')
|
||||
shuffle = False
|
||||
|
||||
|
||||
class player_fw_storage:
|
||||
|
@ -126,14 +127,19 @@ def soft_volume_reduce():
|
|||
def player_menu(header='', storage={}):
|
||||
player_fw_storage.storage.update(storage)
|
||||
player.volume = get_config("mpv_volume")
|
||||
global shuffle
|
||||
while True:
|
||||
try:
|
||||
player_items_menu = ['Next', 'Prev', 'Pause',
|
||||
'Download', 'Info']
|
||||
'Shuffle', 'Download', 'Info']
|
||||
if player.pause:
|
||||
player_items_menu[2] = 'Play'
|
||||
else:
|
||||
player_items_menu[2] = 'Pause'
|
||||
if shuffle:
|
||||
player_items_menu[3] = 'Unshuffle'
|
||||
else:
|
||||
player_items_menu[3] = 'Shuffle'
|
||||
if show_like_button:
|
||||
player_items_menu.append('Like')
|
||||
player_items_menu.extend(['Hide artist', 'Exit'])
|
||||
|
@ -152,10 +158,14 @@ def player_menu(header='', storage={}):
|
|||
elif select == 'Prev':
|
||||
player.playlist_prev()
|
||||
elif select in ('Pause', 'Play'):
|
||||
if player.pause:
|
||||
player.pause = False
|
||||
player.cycle('pause')
|
||||
elif select in ('Shuffle', 'Unshuffle'):
|
||||
if shuffle:
|
||||
shuffle = False
|
||||
player.playlist_unshuffle()
|
||||
else:
|
||||
player.pause = True
|
||||
shuffle = True
|
||||
player.playlist_shuffle()
|
||||
elif select == 'Download':
|
||||
name_downloaded = download_track(player.stream_open_filename)
|
||||
elif select == 'Info':
|
||||
|
|
Loading…
Reference in a new issue