Feature: added artist menu; fixes

This commit is contained in:
localhost_frssoft 2022-04-07 15:25:33 +03:00
parent 6407e54f36
commit 2c6d67f584

View File

@ -43,16 +43,28 @@ funkwhale_menu_albums()
funkwhale_menu_albums_tracks() funkwhale_menu_albums_tracks()
{ {
sub2_menu=1 if [ $sub2_menu -eq 1 ]; then
get_json=$(curl -s --compressed "$instance_point/tracks?ordering=$ordering&playable=true&album=$1&page_size=50") sub2_menu=2
level=2
else
sub2_menu=1
level=1
fi
tracks_a=$(curl -s --compressed "$instance_point/tracks?ordering=$ordering&playable=true&album=$1&page_size=50")
while [ $sub2_menu -eq 1 ]; do while [ $sub2_menu -eq $level ]; do
titles=$(echo $get_json | jj -l results.#.title | nl -s: -v0 -w1) titles=$(echo $tracks_a | jj -l results.#.title | nl -s: -v0 -w1)
playlist=$(echo $get_json | jj -l results.#.listen_url | sed 's/"//g') playlist=$(echo $tracks_a | jj -l results.#.listen_url | sed 's/"//g')
menu_album_tracks_choice=$(echo "Back\nMain menu\nListen all\n$titles" | fzy) menu_album_tracks_choice=$(echo "Back\nMain menu\nListen all\n$titles" | fzy)
case $menu_album_tracks_choice in case $menu_album_tracks_choice in
"Back") sub2_menu=0 ;; "Back")
if [ $sub2_menu -eq 2 ]; then
sub2_menu=1
else
sub2_menu=0
fi ;;
"Main menu") sub2_menu=0 && sub_menu=0 ;; "Main menu") sub2_menu=0 && sub_menu=0 ;;
"Listen all") "Listen all")
@ -64,12 +76,64 @@ funkwhale_menu_albums_tracks()
*) *)
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:) index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
play_track=$(echo $get_json | jj results.$index.listen_url) play_track=$(echo $tracks_a | jj results.$index.listen_url)
$default_player_command "https://$instance$play_track" ;; $default_player_command "https://$instance$play_track" ;;
esac esac
done done
} }
funkwhale_api_get_artists()
{
curl -s --compressed "$instance_point/artists?ordering=-creation_date&playable=true&page=$1"
}
funkwhale_api_get_artist()
{
curl -s --compressed "$instance_point/artists/$1"
}
funkwhale_menu_artists()
{
echo 'Loading artists...'
get_json=$(funkwhale_api_get_artists $1)
echo "Avalaible $(echo $get_json | jj count) artists"
sub_menu=1
while [ $sub_menu -eq 1 ]; do
names=$(echo $get_json | jj -l 'results.#.name' | nl -s: -v0 -w1)
menu_artists_choice=$(echo "Main menu\n$names" | fzy)
case $menu_artists_choice in
"Main menu") sub_menu=0 ;;
*)
index=$(echo $menu_artists_choice | cut -f 1 -d:)
artist_id=$(echo $get_json | jj results.$index.id)
funkwhale_menu_albums_artist $artist_id
esac
done
}
funkwhale_menu_albums_artist()
{
echo 'Loading albums...'
albums_a=$(funkwhale_api_get_artist $1)
standart_albums='albums.#.title'
count_type='albums.#'
index_type='albums'
echo "Avalaible $(echo $albums_a | jj $count_type) albums"
sub2_menu=1
while [ $sub2_menu -eq 1 ]; do
titles=$(echo $albums_a | jj -l $standart_albums | nl -s: -v0 -w1)
menu_albums_choice=$(echo "Back\nMain menu\n$titles" | fzy)
case $menu_albums_choice in
"Main menu") sub2_menu=0 && sub_menu=0 ;;
"Back") sub2_menu=0 ;;
*)
index=$(echo $menu_albums_choice | cut -f 1 -d:)
album_id=$(echo $albums_a | jj $index_type.$index.id)
funkwhale_menu_albums_tracks $album_id
esac
done
}
funkwhale_api_get_tracks_from_channel() funkwhale_api_get_tracks_from_channel()
{ {
sub2_menu=1 sub2_menu=1
@ -155,13 +219,14 @@ get_all_avalaible_count_tracks
downloadtrackspls='Download tracks in playlist' downloadtrackspls='Download tracks in playlist'
startplayer='Start player' startplayer='Start player'
albumsmenu='Albums' albumsmenu='Albums'
artistmenu='Artists'
podcasts='Podcasts' podcasts='Podcasts'
changepod='Switch instance' changepod='Switch instance'
checkapilimits='Check API limits (debug)' checkapilimits='Check API limits (debug)'
Exit='Exit' Exit='Exit'
while true; do while true; do
choice=$(echo "$downloadtrackspls\n$startplayer\n$albumsmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy) choice=$(echo "$downloadtrackspls\n$startplayer\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
case "$choice" in case "$choice" in
"$downloadtrackspls") "$downloadtrackspls")
@ -187,6 +252,11 @@ case "$choice" in
read page read page
funkwhale_menu_albums $page ;; funkwhale_menu_albums $page ;;
"$artistmenu")
echo 'Enter page number: '
read page
funkwhale_menu_artists $page ;;
"$podcasts") "$podcasts")
echo 'Enter page number: ' echo 'Enter page number: '
read page read page