From aad56b6fe87b0e96525a19e0532dc7e55be9013c Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Thu, 31 Mar 2022 14:15:43 +0300 Subject: [PATCH] fixes and added tracks counter per page --- funkwhale-cli.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 3889b1f..51f33a2 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -12,8 +12,7 @@ funkwhale_api_check_api_limits() funkwhale_api_get_tracks() { get_json=$(curl -s "https://$instance/api/v1/tracks?ordering=$ordering&playable=true&page=$1" 2>&1 | tee preload) - export count_all_tracks=$(echo $get_json | jj -l count) - echo $get_json | jj -l 'results.#.uploads.0.listen_url' | sed 's/"//g' + jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g' } funkwhale_api_get_albums() @@ -27,16 +26,23 @@ load_tracks_to_playlist() echo '#EXTM3U\n' > playlist.m3u8 counter_titles=0 for i in $(funkwhale_api_get_tracks $1); do - title=$(cat preload | jj results."$counter_titles".title) + title=$(jj -i preload results."$counter_titles".title) echo "#EXTINF:-1, $counter_titles - $title" >> playlist.m3u8 counter_titles=$(expr $counter_titles + 1) echo "https://$instance$i\n" >> playlist.m3u8 done + count_tracks_results=$(jj -i preload 'results.#') + if [ -z $count_tracks_results ]; then + echo 'Error: Page empty or 500 Internal Server Error' + else + echo "Loaded $count_tracks_results tracks" + fi } get_all_avalaible_count_tracks() { funkwhale_api_get_tracks 1 1>> /dev/null + count_all_tracks=$(jj -i preload -l count) echo "Tracks avalaible on $instance: $count_all_tracks\n" } @@ -53,7 +59,7 @@ choice=$(echo "$downloadtrackspls\n$startplayer\n$changepod\n$checkapilimits\n$E if [ "$choice" = "$downloadtrackspls" ]; then echo 'Order by (prefix - is DESC ordering):' - ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom\n-random' | fzy) + ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy) export ordering echo 'Enter page number: ' read page