funkwlmpv/funkwhale-cli.sh

54 lines
1.3 KiB
Bash
Raw Normal View History

2022-03-30 02:47:33 +03:00
#!/bin/sh
instance='sound.redeyes.club'
default_player=mpv
ordering='title'
funkwhale_api_check_api_limits()
{
curl -s "https://$instance/api/v1/rate-limit/" | jj -p
2022-03-30 02:47:33 +03:00
}
funkwhale_api_get_tracks()
{
get_json=$(curl -s "https://$instance/api/v1/tracks?ordering=$ordering&playable=true&page=$1")
export count_all_tracks=$(echo $get_json | jj -l count)
echo $get_json | jj -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
2022-03-30 02:47:33 +03:00
}
funkwhale_api_get_albums()
{
curl -s https://$instance/api/v1/albums/ | jj -p results
2022-03-30 02:47:33 +03:00
}
load_tracks_to_playlist()
{
for i in $(funkwhale_api_get_tracks $1); do
echo "https://$instance$i" >> playlist
done
}
funkwhale_api_get_tracks 1 1>> /dev/null
echo "Tracks avalaible on $instance: $count_all_tracks\n"
2022-03-30 02:47:33 +03:00
downloadtrackspls='Download tracks in playlist'
startplayer='Start player'
checkapilimits='Check API limits (debug)'
Exit='Exit'
while true; do
choice=$(echo "$downloadtrackspls\n$startplayer\n$checkapilimits\n$Exit" | fzy)
if [ "$choice" = "$downloadtrackspls" ]; then
echo 'Enter page number: '
read page
load_tracks_to_playlist $page
elif [ "$choice" = "$startplayer" ]; then
$default_player --no-vid --no-ytdl --playlist=playlist
elif [ "$choice" = "$checkapilimits" ]; then
funkwhale_api_check_api_limits | more
elif [ "$choice" = "$Exit" ]; then
exit 0
fi
done