2022-03-29 23:47:33 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2022-03-30 22:48:53 +00:00
|
|
|
instance=$(jj -i config.json instance)
|
2022-03-29 23:47:33 +00:00
|
|
|
default_player=mpv
|
|
|
|
ordering='title'
|
|
|
|
|
|
|
|
funkwhale_api_check_api_limits()
|
|
|
|
{
|
2022-03-30 12:04:30 +00:00
|
|
|
curl -s "https://$instance/api/v1/rate-limit/" | jj -p
|
2022-03-29 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
funkwhale_api_get_tracks()
|
|
|
|
{
|
2022-03-30 15:36:18 +00:00
|
|
|
get_json=$(curl -s "https://$instance/api/v1/tracks?ordering=$ordering&playable=true&page=$1" 2>&1 | tee preload)
|
2022-03-30 12:04:30 +00:00
|
|
|
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-29 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
funkwhale_api_get_albums()
|
|
|
|
{
|
2022-03-30 12:04:30 +00:00
|
|
|
curl -s https://$instance/api/v1/albums/ | jj -p results
|
2022-03-29 23:47:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
load_tracks_to_playlist()
|
|
|
|
{
|
2022-03-30 15:36:18 +00:00
|
|
|
echo "Loading page $1 ..."
|
|
|
|
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)
|
2022-03-30 16:08:26 +00:00
|
|
|
echo "#EXTINF:-1, $counter_titles - $title" >> playlist.m3u8
|
2022-03-30 15:36:18 +00:00
|
|
|
counter_titles=$(expr $counter_titles + 1)
|
|
|
|
echo "https://$instance$i\n" >> playlist.m3u8
|
2022-03-29 23:47:33 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2022-03-30 16:58:30 +00:00
|
|
|
get_all_avalaible_count_tracks()
|
|
|
|
{
|
|
|
|
funkwhale_api_get_tracks 1 1>> /dev/null
|
|
|
|
echo "Tracks avalaible on $instance: $count_all_tracks\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_all_avalaible_count_tracks
|
2022-03-30 12:04:30 +00:00
|
|
|
|
2022-03-29 23:47:33 +00:00
|
|
|
downloadtrackspls='Download tracks in playlist'
|
|
|
|
startplayer='Start player'
|
2022-03-30 16:58:30 +00:00
|
|
|
changepod='Switch instance'
|
2022-03-29 23:47:33 +00:00
|
|
|
checkapilimits='Check API limits (debug)'
|
|
|
|
Exit='Exit'
|
|
|
|
|
|
|
|
while true; do
|
2022-03-30 22:48:53 +00:00
|
|
|
choice=$(echo "$downloadtrackspls\n$startplayer\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
2022-03-29 23:47:33 +00:00
|
|
|
|
|
|
|
if [ "$choice" = "$downloadtrackspls" ]; then
|
2022-03-30 18:13:25 +00:00
|
|
|
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)
|
|
|
|
export ordering
|
2022-03-29 23:47:33 +00:00
|
|
|
echo 'Enter page number: '
|
|
|
|
read page
|
|
|
|
load_tracks_to_playlist $page
|
|
|
|
elif [ "$choice" = "$startplayer" ]; then
|
2022-03-30 15:36:18 +00:00
|
|
|
$default_player --no-vid --no-ytdl playlist.m3u8
|
2022-03-30 16:58:30 +00:00
|
|
|
elif [ "$choice" = "$changepod" ]; then
|
|
|
|
echo "Type instance (ex. $instance):"
|
|
|
|
read instance
|
|
|
|
export instance
|
2022-03-30 22:48:53 +00:00
|
|
|
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
|
|
|
if [ "$conf_instance_state" = 'Permanent' ]; then
|
|
|
|
jj -i config.json instance -v $instance -o config.json
|
|
|
|
else
|
|
|
|
echo ''
|
|
|
|
fi
|
2022-03-30 16:58:30 +00:00
|
|
|
clear
|
|
|
|
get_all_avalaible_count_tracks
|
2022-03-29 23:47:33 +00:00
|
|
|
elif [ "$choice" = "$checkapilimits" ]; then
|
|
|
|
funkwhale_api_check_api_limits | more
|
|
|
|
elif [ "$choice" = "$Exit" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|