mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-22 05:39:48 +00:00
Merge functions download tracks to playlist and select avalaible
This commit is contained in:
parent
d0f5d41a70
commit
da859e570e
@ -2,7 +2,7 @@
|
||||
Just for fun. Simple "player" API script for FunkWhale instances.
|
||||
|
||||
Features:
|
||||
* Download tracks url's in playlist per page
|
||||
* Select and listen tracks
|
||||
* Select and listen albums
|
||||
* Select and listen artists
|
||||
* Select and listen podcasts
|
||||
|
@ -36,13 +36,14 @@ funkwhale_api_get_tracks()
|
||||
|
||||
funkwhale_menu_tracks()
|
||||
{
|
||||
sub2_menu=1
|
||||
level=1
|
||||
echo 'Loading tracks...'
|
||||
funkwhale_api_get_tracks 1 $1
|
||||
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
|
||||
level=1
|
||||
|
||||
while [ $sub2_menu -eq $level ]; do
|
||||
titles=$(jj -i preload -l results.#.title | nl -s: -v0 -w1)
|
||||
@ -207,7 +208,7 @@ funkwhale_menu_albums_artist()
|
||||
if [ $count_albums -eq 0 ]; then
|
||||
echo 'failed: no albums, getting tracks...'
|
||||
sub2_menu=1
|
||||
funkwhale_menu_tracks $1
|
||||
funkwhale_menu_tracks 1 $1
|
||||
return 1
|
||||
fi
|
||||
index_type='albums'
|
||||
@ -277,33 +278,6 @@ funkwhale_get_podcasts_artists()
|
||||
done
|
||||
}
|
||||
|
||||
load_tracks_to_playlist()
|
||||
{
|
||||
echo "Loading page $1 ..."
|
||||
echo '#EXTM3U\n' > playlist.m3u8
|
||||
chmod 600 playlist.m3u8
|
||||
counter_titles=0
|
||||
funkwhale_api_get_tracks $1
|
||||
for i in $(jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'); 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()
|
||||
{
|
||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||
@ -319,8 +293,7 @@ get_all_avalaible_count_tracks()
|
||||
|
||||
get_all_avalaible_count_tracks
|
||||
|
||||
downloadtrackspls='Download tracks in playlist'
|
||||
startplayer='Start player'
|
||||
trackspls='Tracks'
|
||||
albumsmenu='Albums'
|
||||
artistmenu='Artists'
|
||||
podcasts='Podcasts'
|
||||
@ -329,10 +302,10 @@ checkapilimits='Check API limits (debug)'
|
||||
Exit='Exit'
|
||||
|
||||
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
|
||||
"$downloadtrackspls")
|
||||
"$trackspls")
|
||||
echo 'Order by (prefix - is DESC ordering):'
|
||||
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
||||
export ordering
|
||||
@ -344,12 +317,8 @@ case "$choice" in
|
||||
export tag
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
load_tracks_to_playlist $page ;;
|
||||
|
||||
funkwhale_menu_tracks $page ;;
|
||||
|
||||
"$startplayer")
|
||||
$default_player_command playlist.m3u8 ;;
|
||||
|
||||
"$albumsmenu")
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
|
Loading…
Reference in New Issue
Block a user