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