From 2a74f746d18e37cbd6145419506b8fa62abb808e Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 4 Apr 2022 02:46:47 +0300 Subject: [PATCH] Added view albums --- funkwhale-cli.sh | 49 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 5a05f3e..95bbe5c 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -17,6 +17,48 @@ funkwhale_api_get_tracks() jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g' } +funkwhale_api_get_albums() +{ + get_json=$(curl -s --compressed "$instance_point/albums?ordering=$ordering&playable=true&page=$1" 2>&1 | tee preload) +} + +funkwhale_menu_albums() +{ + echo 'Loading albums...' + funkwhale_api_get_albums $1 + echo "Avalaible $(jj -i preload count) albums" + sub_menu=1 + while [ $sub_menu -eq 1 ]; do + titles=$(jj -i preload -l 'results.#.title') + menu_albums_choice=$(echo "Main menu\n$titles" | fzy) + case $menu_albums_choice in + "Main menu") sub_menu=0 ;; + *) + album_id=$(jj -i preload results.#[title="$menu_albums_choice"].id) + funkwhale_menu_albums_tracks $album_id + esac + done +} + +funkwhale_menu_albums_tracks() +{ + sub2_menu=1 + get_json=$(curl -s --compressed "$instance_point/tracks?ordering=$ordering&playable=true&album=$1&page_size=50") + + + while [ $sub2_menu -eq 1 ]; do + titles=$(echo $get_json | jj -l results.#.title) + menu_album_tracks_choice=$(echo "Back\nMain menu\n$titles" | fzy) + case $menu_album_tracks_choice in + "Back") sub2_menu=0 ;; + "Main menu") sub2_menu=0 && sub_menu=0 ;; + *) + play_track=$(echo $get_json | jj results.#[title="$menu_album_tracks_choice"].listen_url) + $default_player_command "https://$instance$play_track" ;; + esac + done +} + funkwhale_api_get_tracks_from_channel() { sub2_menu=1 @@ -99,13 +141,14 @@ get_all_avalaible_count_tracks downloadtrackspls='Download tracks in playlist' startplayer='Start player' +albumsmenu='Albums' podcasts='Podcasts' changepod='Switch instance' checkapilimits='Check API limits (debug)' Exit='Exit' while true; do -choice=$(echo "$downloadtrackspls\n$startplayer\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy) +choice=$(echo "$downloadtrackspls\n$startplayer\n$albumsmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy) case "$choice" in "$downloadtrackspls") @@ -126,6 +169,10 @@ case "$choice" in "$startplayer") $default_player_command playlist.m3u8 ;; + "$albumsmenu") + echo 'Enter page number: ' + read page + funkwhale_menu_albums $page ;; "$podcasts") echo 'Enter page number: '