mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-27 17:43:02 +00:00
Some patches
This commit is contained in:
parent
31770dfe37
commit
6d7c17dfac
114
funkwhale-cli.sh
114
funkwhale-cli.sh
@ -9,7 +9,7 @@ download_selected_track=$(jj -i config.json download_selected_track)
|
||||
|
||||
touch .auth.json
|
||||
chmod 600 .auth.json
|
||||
auth="$(jj -i .auth.json "$(echo $instance | sed 's/\./\\\./g')")"
|
||||
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
||||
if [ -n "$auth" ]; then
|
||||
default_curl_opt()
|
||||
{
|
||||
@ -39,19 +39,19 @@ funkwhale_api_tags()
|
||||
mkdir -p tags_db
|
||||
if [ ! -f "tags_db/tags_$instance.gz" ]; then
|
||||
tagsload=$(default_curl_opt "$instance_point/tags?playable=true")
|
||||
pageindex=$(echo $tagsload | jj next)
|
||||
echo $tagsload | jj -l results.#.name | delq | gzip > tags_db/tags_$instance.gz
|
||||
pageindex=$(echo "$tagsload" | jj next)
|
||||
echo "$tagsload" | jj -l results.#.name | delq | gzip > tags_db/tags_"$instance".gz
|
||||
clear
|
||||
while [ -n "$pageindex" ]; do
|
||||
echo "Loading... +$(echo $tagsload | jj results.#) tags"
|
||||
echo $tagsload | jj -l results.#.name | delq | gzip >> tags_db/tags_$instance.gz
|
||||
pageindex=$(echo $tagsload | jj next)
|
||||
echo "Loading... +$(echo "$tagsload" | jj results.#) tags"
|
||||
echo "$tagsload" | jj -l results.#.name | delq | gzip >> tags_db/tags_"$instance".gz
|
||||
pageindex=$(echo "$tagsload" | jj next)
|
||||
tagsload=$(default_curl_opt "$pageindex")
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
tag=$(cat tags_db/tags_$instance.gz | gzip -d | fzy)
|
||||
tag=$(cat tags_db/tags_"$instance".gz | gzip -d | fzy)
|
||||
}
|
||||
|
||||
funkwhale_api_get_tracks()
|
||||
@ -86,7 +86,7 @@ funkwhale_menu_tracks()
|
||||
sub2_menu=1
|
||||
level=1
|
||||
echo 'Loading tracks...'
|
||||
funkwhale_api_get_tracks $1 $2 1>> /dev/null
|
||||
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
|
||||
@ -124,12 +124,12 @@ funkwhale_menu_tracks()
|
||||
$default_player_command playlist.m3u8 ;;
|
||||
|
||||
*)
|
||||
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
||||
play_track=$(jj -i preload results.$index.listen_url)
|
||||
download_track=$(jj -i preload results.$index.uploads.0.listen_url)
|
||||
download_ext=$(jj -i preload results.$index.uploads.0.extension)
|
||||
title=$(jj -i preload results.$index.title)
|
||||
artist_name=$(jj -i preload results.$index.artist.name)
|
||||
index=$(echo "$menu_album_tracks_choice" | cut -f 1 -d:)
|
||||
play_track=$(jj -i preload results."$index".listen_url)
|
||||
download_track=$(jj -i preload results."$index".uploads.0.listen_url)
|
||||
download_ext=$(jj -i preload results."$index".uploads.0.extension)
|
||||
title=$(jj -i preload results."$index".title)
|
||||
artist_name=$(jj -i preload results."$index".artist.name)
|
||||
play_or_download_selected
|
||||
;;
|
||||
esac
|
||||
@ -144,7 +144,7 @@ funkwhale_api_get_albums()
|
||||
funkwhale_menu_albums()
|
||||
{
|
||||
echo 'Loading albums...'
|
||||
funkwhale_api_get_albums $1
|
||||
funkwhale_api_get_albums "$1"
|
||||
echo "Avalaible $(jj -i preload count) albums"
|
||||
sub_menu=1
|
||||
while [ $sub_menu -eq 1 ]; do
|
||||
@ -153,13 +153,13 @@ funkwhale_menu_albums()
|
||||
case $menu_albums_choice in
|
||||
"Main menu") sub_menu=0 ;;
|
||||
"Next page")
|
||||
page=$(expr $page + 1)
|
||||
get_json=$(funkwhale_api_get_albums $page)
|
||||
page=$(expr "$page" + 1)
|
||||
get_json=$(funkwhale_api_get_albums "$page")
|
||||
;;
|
||||
*)
|
||||
index=$(echo $menu_albums_choice | cut -f 1 -d:)
|
||||
album_id=$(jj -i preload results.$index.id)
|
||||
funkwhale_menu_albums_tracks $album_id
|
||||
index=$(echo "$menu_albums_choice" | cut -f 1 -d:)
|
||||
album_id=$(jj -i preload results."$index".id)
|
||||
funkwhale_menu_albums_tracks "$album_id"
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -178,8 +178,8 @@ funkwhale_menu_albums_tracks()
|
||||
|
||||
|
||||
while [ $sub2_menu -eq $level ]; do
|
||||
titles=$(echo $tracks_a | jj -l results.#.title | nl -s: -v0 -w1)
|
||||
playlist=$(echo $tracks_a | jj -l results.#.listen_url | delq)
|
||||
titles=$(echo "$tracks_a" | jj -l results.#.title | nl -s: -v0 -w1)
|
||||
playlist=$(echo "$tracks_a" | jj -l results.#.listen_url | delq)
|
||||
menu_album_tracks_choice=$(echo "Back\nMain menu\nListen all\n$titles" | fzy)
|
||||
case $menu_album_tracks_choice in
|
||||
"Back")
|
||||
@ -203,8 +203,8 @@ funkwhale_menu_albums_tracks()
|
||||
$default_player_command playlist.m3u8 ;;
|
||||
|
||||
*)
|
||||
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
||||
play_track=$(echo $tracks_a | jj results.$index.listen_url)
|
||||
index=$(echo "$menu_album_tracks_choice" | cut -f 1 -d:)
|
||||
play_track=$(echo "$tracks_a" | jj results."$index".listen_url)
|
||||
if [ -n "$auth" ]; then
|
||||
$default_player_command "https://$instance$play_track?token=$listen_token"
|
||||
else
|
||||
@ -227,22 +227,22 @@ funkwhale_api_get_artist()
|
||||
funkwhale_menu_artists()
|
||||
{
|
||||
echo 'Loading artists...'
|
||||
get_json=$(funkwhale_api_get_artists $1)
|
||||
echo "Avalaible $(echo $get_json | jj count) artists"
|
||||
get_json=$(funkwhale_api_get_artists "$1")
|
||||
echo "Avalaible $(echo "$get_json" | jj count) artists"
|
||||
sub_menu=1
|
||||
while [ $sub_menu -eq 1 ]; do
|
||||
names=$(echo $get_json | jj -l 'results.#.name' | nl -s: -v0 -w1)
|
||||
names=$(echo "$get_json" | jj -l 'results.#.name' | nl -s: -v0 -w1)
|
||||
menu_artists_choice=$(echo "Main menu\n$names\nNext page" | fzy)
|
||||
case $menu_artists_choice in
|
||||
"Main menu") sub_menu=0 ;;
|
||||
"Next page")
|
||||
page=$(expr $page + 1)
|
||||
get_json=$(funkwhale_api_get_artists $page)
|
||||
page=$(expr "$page" + 1)
|
||||
get_json=$(funkwhale_api_get_artists "$page")
|
||||
;;
|
||||
*)
|
||||
index=$(echo $menu_artists_choice | cut -f 1 -d:)
|
||||
artist_id=$(echo $get_json | jj results.$index.id)
|
||||
funkwhale_menu_albums_artist $artist_id ;;
|
||||
index=$(echo "$menu_artists_choice" | cut -f 1 -d:)
|
||||
artist_id=$(echo "$get_json" | jj results."$index".id)
|
||||
funkwhale_menu_albums_artist "$artist_id" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -250,28 +250,28 @@ funkwhale_menu_artists()
|
||||
funkwhale_menu_albums_artist()
|
||||
{
|
||||
echo 'Loading albums...'
|
||||
albums_a=$(funkwhale_api_get_artist $1)
|
||||
albums_a=$(funkwhale_api_get_artist "$1")
|
||||
standart_albums='albums.#.title'
|
||||
count_albums=$(echo $albums_a | jj albums.\#)
|
||||
if [ $count_albums -eq 0 ]; then
|
||||
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
|
||||
funkwhale_menu_tracks 1 "$1"
|
||||
return 1
|
||||
fi
|
||||
index_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)
|
||||
titles=$(echo "$albums_a" | jj -l $standart_albums | nl -s: -v0 -w1)
|
||||
menu_albums_choice=$(echo "Back\nMain menu\n$titles" | fzy)
|
||||
case $menu_albums_choice in
|
||||
"Main menu") sub2_menu=0 && sub_menu=0 ;;
|
||||
"Back") sub2_menu=0 ;;
|
||||
*)
|
||||
index=$(echo $menu_albums_choice | cut -f 1 -d:)
|
||||
album_id=$(echo $albums_a | jj $index_type.$index.id)
|
||||
funkwhale_menu_albums_tracks $album_id
|
||||
index=$(echo "$menu_albums_choice" | cut -f 1 -d:)
|
||||
album_id=$(echo "$albums_a" | jj $index_type."$index".id)
|
||||
funkwhale_menu_albums_tracks "$album_id"
|
||||
esac
|
||||
done
|
||||
}
|
||||
@ -280,17 +280,17 @@ funkwhale_api_get_tracks_from_channel()
|
||||
{
|
||||
sub2_menu=1
|
||||
track_list=$(default_curl_opt "$instance_point/tracks?channel=$1&playable=true&include_channels=true")
|
||||
echo "Loaded $(echo $track_list | jj count) podcasts"
|
||||
echo "Loaded $(echo "$track_list" | jj count) podcasts"
|
||||
|
||||
while [ $sub2_menu -eq 1 ]; do
|
||||
titles=$(echo $track_list | jj -l 'results.#.title' | nl -s: -v0 -w1)
|
||||
titles=$(echo "$track_list" | jj -l 'results.#.title' | nl -s: -v0 -w1)
|
||||
menu_podcast_choice=$(echo "Back\nMain menu\n$titles" | fzy)
|
||||
case $menu_podcast_choice in
|
||||
"Back") sub2_menu=0 ;;
|
||||
"Main menu") sub2_menu=0 && sub_menu=0 ;;
|
||||
*)
|
||||
index=$(echo $menu_podcast_choice | cut -f 1 -d:)
|
||||
play_track=$(echo $track_list | jj results.$index.listen_url)
|
||||
index=$(echo "$menu_podcast_choice" | cut -f 1 -d:)
|
||||
play_track=$(echo "$track_list" | jj results."$index".listen_url)
|
||||
if [ -n "$auth" ]; then
|
||||
$default_player_command "https://$instance$play_track&token=$listen_token"
|
||||
else
|
||||
@ -314,13 +314,13 @@ funkwhale_get_podcasts_artists()
|
||||
"Main menu") sub_menu=0 ;;
|
||||
|
||||
*)
|
||||
index=$(echo $menu_podcast_choice | cut -f 1 -d:)
|
||||
channel_uuid=$(jj -i preload results.$index.channel.uuid)
|
||||
index=$(echo "$menu_podcast_choice" | cut -f 1 -d:)
|
||||
channel_uuid=$(jj -i preload results."$index".channel.uuid)
|
||||
|
||||
if [ -z $channel_uuid ]; then
|
||||
if [ -z "$channel_uuid" ]; then
|
||||
echo 'Error when loading podcast'
|
||||
else
|
||||
funkwhale_api_get_tracks_from_channel $channel_uuid
|
||||
funkwhale_api_get_tracks_from_channel "$channel_uuid"
|
||||
fi ;;
|
||||
esac
|
||||
done
|
||||
@ -330,9 +330,9 @@ get_all_avalaible_count_tracks()
|
||||
{
|
||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||
count_all_tracks=$(jj -i preload -l count)
|
||||
if [ -z $count_all_tracks ]; then
|
||||
if [ -z "$count_all_tracks" ]; then
|
||||
echo 'Error: Connection error or API limit expired'
|
||||
elif [ $count_all_tracks -eq 0 ]; then
|
||||
elif [ "$count_all_tracks" -eq 0 ]; then
|
||||
echo 'Error: No tracks'
|
||||
else
|
||||
echo "Tracks avalaible on $instance: $count_all_tracks\n"
|
||||
@ -367,24 +367,24 @@ case "$choice" in
|
||||
export tag
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
funkwhale_menu_tracks $page
|
||||
funkwhale_menu_tracks "$page"
|
||||
tag=
|
||||
;;
|
||||
|
||||
"$albumsmenu")
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
funkwhale_menu_albums $page ;;
|
||||
funkwhale_menu_albums "$page" ;;
|
||||
|
||||
"$artistmenu")
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
funkwhale_menu_artists $page ;;
|
||||
funkwhale_menu_artists "$page" ;;
|
||||
|
||||
"$podcasts")
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
funkwhale_get_podcasts_artists $page ;;
|
||||
funkwhale_get_podcasts_artists "$page" ;;
|
||||
|
||||
|
||||
"$changepod")
|
||||
@ -403,18 +403,18 @@ case "$choice" in
|
||||
"Manual input") echo "Type instance (ex. $instance):" && read instance ;;
|
||||
esac
|
||||
if [ $empty -eq 0 ]; then
|
||||
echo $instance >> $instance_hist
|
||||
echo "$instance" >> $instance_hist
|
||||
cat $instance_hist | sort | uniq | tee $instance_hist 1>>/dev/null
|
||||
export instance
|
||||
export instance_point="https://$instance/api/v1"
|
||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||
if [ "$conf_instance_state" = 'Permanent' ]; then
|
||||
jj -i config.json instance -v $instance -o config.json
|
||||
jj -i config.json instance -v "$instance" -o config.json
|
||||
else
|
||||
echo ''
|
||||
fi
|
||||
clear
|
||||
auth="$(jj -i .auth.json "$(echo $instance | sed 's/\./\\\./g')")"
|
||||
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
|
||||
if [ -n "$auth" ]; then
|
||||
default_curl_opt()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user