mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-26 05:51:32 +00:00
Compare commits
2 commits
4a0dece097
...
da859e570e
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | da859e570e | ||
localhost_frssoft | d0f5d41a70 |
|
@ -2,7 +2,7 @@
|
||||||
Just for fun. Simple "player" API script for FunkWhale instances.
|
Just for fun. Simple "player" API script for FunkWhale instances.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
* Download tracks url's in playlist per page
|
* Select and listen tracks
|
||||||
* Select and listen albums
|
* Select and listen albums
|
||||||
* Select and listen artists
|
* Select and listen artists
|
||||||
* Select and listen podcasts
|
* Select and listen podcasts
|
||||||
|
|
108
funkwhale-cli.sh
108
funkwhale-cli.sh
|
@ -29,8 +29,63 @@ funkwhale_api_check_api_limits()
|
||||||
|
|
||||||
funkwhale_api_get_tracks()
|
funkwhale_api_get_tracks()
|
||||||
{
|
{
|
||||||
get_json=$(default_curl_opt "$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag" 2>&1 | tee preload)
|
default_curl_opt \
|
||||||
jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
|
"$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag&artist=$2" \
|
||||||
|
2>&1 | tee preload
|
||||||
|
}
|
||||||
|
|
||||||
|
funkwhale_menu_tracks()
|
||||||
|
{
|
||||||
|
sub2_menu=1
|
||||||
|
level=1
|
||||||
|
echo 'Loading tracks...'
|
||||||
|
funkwhale_api_get_tracks $1 $2 1>> /dev/null
|
||||||
|
count_tracks_results=$(jj -i preload 'results.#')
|
||||||
|
echo '#EXTM3U\n' > playlist.m3u8
|
||||||
|
chmod 600 playlist.m3u8
|
||||||
|
counter_titles=0
|
||||||
|
|
||||||
|
while [ $sub2_menu -eq $level ]; do
|
||||||
|
titles=$(jj -i preload -l results.#.title | nl -s: -v0 -w1)
|
||||||
|
playlist=$(jj -i preload -l results.#.listen_url | sed 's/"//g')
|
||||||
|
menu_album_tracks_choice=$(echo "Back\nMain menu\nListen all\n$titles" | fzy)
|
||||||
|
case $menu_album_tracks_choice in
|
||||||
|
"Back")
|
||||||
|
if [ $sub2_menu -eq 2 ]; then
|
||||||
|
sub2_menu=1
|
||||||
|
else
|
||||||
|
sub2_menu=0
|
||||||
|
fi ;;
|
||||||
|
"Main menu") sub2_menu=0 && sub_menu=0 ;;
|
||||||
|
|
||||||
|
"Listen all")
|
||||||
|
echo > playlist.m3u8
|
||||||
|
chmod 600 playlist.m3u8
|
||||||
|
tracks_for_playlist=$(jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g')
|
||||||
|
for i in $tracks_for_playlist; do
|
||||||
|
title=$(jj -i preload results."$counter_titles".title)
|
||||||
|
artist_name=$(jj -i preload results."$counter_titles".artist.name)
|
||||||
|
duration=$(jj -i preload results."$counter_titles".uploads.0.duration)
|
||||||
|
echo "#EXTINF:$duration, $artist_name - $title" >> playlist.m3u8
|
||||||
|
counter_titles=$(expr $counter_titles + 1)
|
||||||
|
if [ -n "$auth" ]; then
|
||||||
|
echo "https://$instance$i&token=$listen_token\n" >> playlist.m3u8
|
||||||
|
else
|
||||||
|
echo "https://$instance$i\n" >> playlist.m3u8
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
$default_player_command playlist.m3u8 ;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
||||||
|
play_track=$(jj -i preload results.$index.listen_url)
|
||||||
|
if [ -n "$auth" ]; then
|
||||||
|
$default_player_command "https://$instance$play_track?token=$listen_token"
|
||||||
|
else
|
||||||
|
$default_player_command "https://$instance$play_track"
|
||||||
|
fi ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
funkwhale_api_get_albums()
|
funkwhale_api_get_albums()
|
||||||
|
@ -149,9 +204,15 @@ funkwhale_menu_albums_artist()
|
||||||
echo 'Loading albums...'
|
echo 'Loading albums...'
|
||||||
albums_a=$(funkwhale_api_get_artist $1)
|
albums_a=$(funkwhale_api_get_artist $1)
|
||||||
standart_albums='albums.#.title'
|
standart_albums='albums.#.title'
|
||||||
count_type='albums.#'
|
count_albums=$(echo $albums_a | jj albums.\#)
|
||||||
|
if [ $count_albums -eq 0 ]; then
|
||||||
|
echo 'failed: no albums, getting tracks...'
|
||||||
|
sub2_menu=1
|
||||||
|
funkwhale_menu_tracks 1 $1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
index_type='albums'
|
index_type='albums'
|
||||||
echo "Avalaible $(echo $albums_a | jj $count_type) albums"
|
echo "Avalaible $count_albums albums"
|
||||||
sub2_menu=1
|
sub2_menu=1
|
||||||
while [ $sub2_menu -eq 1 ]; do
|
while [ $sub2_menu -eq 1 ]; do
|
||||||
titles=$(echo $albums_a | jj -l $standart_albums | nl -s: -v0 -w1)
|
titles=$(echo $albums_a | jj -l $standart_albums | nl -s: -v0 -w1)
|
||||||
|
@ -217,32 +278,6 @@ funkwhale_get_podcasts_artists()
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
load_tracks_to_playlist()
|
|
||||||
{
|
|
||||||
echo "Loading page $1 ..."
|
|
||||||
echo '#EXTM3U\n' > playlist.m3u8
|
|
||||||
chmod 600 playlist.m3u8
|
|
||||||
counter_titles=0
|
|
||||||
for i in $(funkwhale_api_get_tracks $1); do
|
|
||||||
title=$(jj -i preload results."$counter_titles".title)
|
|
||||||
artist_name=$(jj -i preload results."$counter_titles".artist.name)
|
|
||||||
duration=$(jj -i preload results."$counter_titles".uploads.0.duration)
|
|
||||||
echo "#EXTINF:$duration, $artist_name - $title" >> playlist.m3u8
|
|
||||||
counter_titles=$(expr $counter_titles + 1)
|
|
||||||
if [ -n "$auth" ]; then
|
|
||||||
echo "https://$instance$i&token=$listen_token\n" >> playlist.m3u8
|
|
||||||
else
|
|
||||||
echo "https://$instance$i\n" >> playlist.m3u8
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
count_tracks_results=$(jj -i preload 'results.#')
|
|
||||||
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then
|
|
||||||
echo 'Error: Page empty or connection error'
|
|
||||||
else
|
|
||||||
echo "Loaded $count_tracks_results tracks"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
get_all_avalaible_count_tracks()
|
get_all_avalaible_count_tracks()
|
||||||
{
|
{
|
||||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||||
|
@ -258,8 +293,7 @@ get_all_avalaible_count_tracks()
|
||||||
|
|
||||||
get_all_avalaible_count_tracks
|
get_all_avalaible_count_tracks
|
||||||
|
|
||||||
downloadtrackspls='Download tracks in playlist'
|
trackspls='Tracks'
|
||||||
startplayer='Start player'
|
|
||||||
albumsmenu='Albums'
|
albumsmenu='Albums'
|
||||||
artistmenu='Artists'
|
artistmenu='Artists'
|
||||||
podcasts='Podcasts'
|
podcasts='Podcasts'
|
||||||
|
@ -268,10 +302,10 @@ checkapilimits='Check API limits (debug)'
|
||||||
Exit='Exit'
|
Exit='Exit'
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(echo "$downloadtrackspls\n$startplayer\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
choice=$(echo "$trackspls\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
"$downloadtrackspls")
|
"$trackspls")
|
||||||
echo 'Order by (prefix - is DESC ordering):'
|
echo 'Order by (prefix - is DESC ordering):'
|
||||||
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
||||||
export ordering
|
export ordering
|
||||||
|
@ -283,12 +317,8 @@ case "$choice" in
|
||||||
export tag
|
export tag
|
||||||
echo 'Enter page number: '
|
echo 'Enter page number: '
|
||||||
read page
|
read page
|
||||||
load_tracks_to_playlist $page ;;
|
funkwhale_menu_tracks $page ;;
|
||||||
|
|
||||||
|
|
||||||
"$startplayer")
|
|
||||||
$default_player_command playlist.m3u8 ;;
|
|
||||||
|
|
||||||
"$albumsmenu")
|
"$albumsmenu")
|
||||||
echo 'Enter page number: '
|
echo 'Enter page number: '
|
||||||
read page
|
read page
|
||||||
|
|
Loading…
Reference in a new issue