From 4c5cb88a61137f15912701ecd33fb5b5bb8ae407 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 15 Jun 2023 16:28:28 +0300 Subject: [PATCH 1/5] reorder for album tracks and artist tracks --- src/fw_albums.py | 2 +- src/fw_api.py | 8 ++++++-- src/fw_artists.py | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/fw_albums.py b/src/fw_albums.py index 6611f5d..9a533d9 100644 --- a/src/fw_albums.py +++ b/src/fw_albums.py @@ -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: diff --git a/src/fw_api.py b/src/fw_api.py index 1147784..786ff50 100644 --- a/src/fw_api.py +++ b/src/fw_api.py @@ -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, diff --git a/src/fw_artists.py b/src/fw_artists.py index 8b28667..3e52b1f 100644 --- a/src/fw_artists.py +++ b/src/fw_artists.py @@ -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 = {} From 38212d29b4dc9b6fc345b182c4393513bc4a7dda Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 15 Jun 2023 17:42:03 +0300 Subject: [PATCH 2/5] print with flush replace sys --- src/fw_radios.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/fw_radios.py b/src/fw_radios.py index d44fd82..7dda1df 100644 --- a/src/fw_radios.py +++ b/src/fw_radios.py @@ -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() From 96ce0dfb500f7daabe927b7ffaadf12a4bfc4324 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 15 Jun 2023 17:43:36 +0300 Subject: [PATCH 3/5] barebones shuffle button (cycle shuffle no work) --- src/mpv_control.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mpv_control.py b/src/mpv_control.py index 5b24bdb..e8c2bfd 100644 --- a/src/mpv_control.py +++ b/src/mpv_control.py @@ -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': From d689a4c34e611e32c092f601c778ac8062b2c12f Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 15 Jun 2023 19:04:11 +0300 Subject: [PATCH 4/5] Fix for termux, close EOF --- src/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index a1e70d6..eacc30c 100644 --- a/src/utils.py +++ b/src/utils.py @@ -69,4 +69,4 @@ def track_info_output(track): else: output.append(f'{k}: {v}') output = '\n'.join(output) - os.system(f'less < Date: Thu, 15 Jun 2023 19:07:56 +0300 Subject: [PATCH 5/5] Also close EOF's --- funkwhale_cli.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/funkwhale_cli.py b/funkwhale_cli.py index 3d28352..2bb36bf 100755 --- a/funkwhale_cli.py +++ b/funkwhale_cli.py @@ -128,7 +128,7 @@ Insert token from "Access token" here''') current_instance.select_instance(current_instance.instance) if selected == 'Donate': - os.system(f'less <