From dba175f9a6f77f8baf5cb0ed98c8ff3c27a06e43 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Wed, 20 Jul 2022 23:51:33 +0300 Subject: [PATCH] Added option for local "timeline" listing music; retry attempts set 3 --- config.json | 1 + funkwhale-cli.sh | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index e6100ac..4b41ed4 100644 --- a/config.json +++ b/config.json @@ -1,6 +1,7 @@ { "instance": "fw.ponychord.rocks", "download_selected_track": false, + "local_content_only": true, "tags": [ "8bit", "Alternative", diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 24807f3..a80b1a9 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -6,6 +6,7 @@ ordering='-creation_date' default_player_command='mpv --no-vid --no-ytdl --network-timeout=30' instance_point="https://$instance/api/v1" download_selected_track=$(jj -i config.json download_selected_track) +local_content_only=$(jj -i config.json local_content_only) touch .auth.json chmod 600 .auth.json @@ -16,7 +17,7 @@ make_login() if [ -n "$auth" ]; then default_curl_opt() { - curl -s --compressed -H "Authorization: Bearer $auth" "$@" + curl --retry 3 -s --compressed -H "Authorization: Bearer $auth" "$@" } listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen) echo '+Authorized account+' @@ -26,7 +27,7 @@ make_login() export listen_token default_curl_opt() { - curl -s --compressed "$@" + curl --retry 3 -s --compressed "$@" } fi export default_curl_opt @@ -65,8 +66,13 @@ funkwhale_api_tags() funkwhale_api_get_tracks() { + if [ "$local_content_only" = 'true' ]; then + default_scope="domain:$instance" + else + default_scope='all' + fi default_curl_opt \ - "$instance_point/tracks?ordering=$ordering&playable=true&page_size=50&page=$1&tag=$tag&artist=$2" \ + "$instance_point/tracks?ordering=$ordering&playable=true&scope=$default_scope&page_size=50&page=$1&tag=$tag&artist=$2" \ 2>&1 | tee preload }