Some fixes

This commit is contained in:
localhost_frssoft 2022-04-29 22:38:00 +03:00
parent 6d7c17dfac
commit 64e74bca2f
1 changed files with 29 additions and 36 deletions

View File

@ -9,20 +9,27 @@ 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')")"
if [ -n "$auth" ]; then make_login()
default_curl_opt() {
{ auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")"
curl -s --compressed -H "Authorization: Bearer $auth" "$@" if [ -n "$auth" ]; then
} default_curl_opt()
listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen) {
echo '+Authorized account+' curl -s --compressed -H "Authorization: Bearer $auth" "$@"
else }
default_curl_opt() listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen)
{ echo '+Authorized account+'
curl -s --compressed "$@" export listen_token
} else
fi default_curl_opt()
{
curl -s --compressed "$@"
}
fi
export default_curl_opt
}
make_login
delq() delq()
{ {
@ -40,11 +47,11 @@ funkwhale_api_tags()
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
@ -178,8 +185,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")
@ -308,7 +315,7 @@ funkwhale_get_podcasts_artists()
while [ $sub_menu -eq 1 ]; do while [ $sub_menu -eq 1 ]; do
count_artists=$(jj -i preload count) count_artists=$(jj -i preload count)
echo "$count_artists avalaible" echo "$count_artists avalaible"
podcast_names=$(jj -l -i preload results.#.name | nl -s: -v0 -w1) podcast_names=$(jj -l -i preload 'results.#.name' | nl -s: -v0 -w1)
menu_podcast_choice=$(echo "Main menu\n$podcast_names" | fzy) menu_podcast_choice=$(echo "Main menu\n$podcast_names" | fzy)
case $menu_podcast_choice in case $menu_podcast_choice in
"Main menu") sub_menu=0 ;; "Main menu") sub_menu=0 ;;
@ -405,8 +412,7 @@ case "$choice" in
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 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
@ -414,20 +420,7 @@ case "$choice" in
echo '' echo ''
fi fi
clear clear
auth="$(jj -i .auth.json "$(echo "$instance" | sed 's/\./\\\./g')")" make_login
if [ -n "$auth" ]; then
default_curl_opt()
{
curl -s --compressed -H "Authorization: Bearer $auth" "$@"
}
listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen)
echo '+Authorized account+'
else
default_curl_opt()
{
curl -s --compressed "$@"
}
fi
get_all_avalaible_count_tracks get_all_avalaible_count_tracks
fi ;; fi ;;