mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 17:43:02 +00:00
Directly load tracks if artist not have albums
This commit is contained in:
parent
4a0dece097
commit
d0f5d41a70
@ -29,8 +29,62 @@ funkwhale_api_check_api_limits()
|
||||
|
||||
funkwhale_api_get_tracks()
|
||||
{
|
||||
get_json=$(default_curl_opt "$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag" 2>&1 | tee preload)
|
||||
jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
|
||||
default_curl_opt \
|
||||
"$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag&artist=$2" \
|
||||
2>&1 | tee preload
|
||||
}
|
||||
|
||||
funkwhale_menu_tracks()
|
||||
{
|
||||
echo 'Loading tracks...'
|
||||
funkwhale_api_get_tracks 1 $1
|
||||
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)
|
||||
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()
|
||||
@ -149,9 +203,15 @@ funkwhale_menu_albums_artist()
|
||||
echo 'Loading albums...'
|
||||
albums_a=$(funkwhale_api_get_artist $1)
|
||||
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
|
||||
return 1
|
||||
fi
|
||||
index_type='albums'
|
||||
echo "Avalaible $(echo $albums_a | jj $count_type) albums"
|
||||
echo "Avalaible $count_albums albums"
|
||||
sub2_menu=1
|
||||
while [ $sub2_menu -eq 1 ]; do
|
||||
titles=$(echo $albums_a | jj -l $standart_albums | nl -s: -v0 -w1)
|
||||
@ -223,7 +283,8 @@ load_tracks_to_playlist()
|
||||
echo '#EXTM3U\n' > playlist.m3u8
|
||||
chmod 600 playlist.m3u8
|
||||
counter_titles=0
|
||||
for i in $(funkwhale_api_get_tracks $1); do
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user