Added option for local "timeline" listing music; retry attempts set 3

This commit is contained in:
localhost_frssoft 2022-07-20 23:51:33 +03:00
parent 97ec7ce352
commit dba175f9a6
2 changed files with 10 additions and 3 deletions

View File

@ -1,6 +1,7 @@
{ {
"instance": "fw.ponychord.rocks", "instance": "fw.ponychord.rocks",
"download_selected_track": false, "download_selected_track": false,
"local_content_only": true,
"tags": [ "tags": [
"8bit", "8bit",
"Alternative", "Alternative",

View File

@ -6,6 +6,7 @@ ordering='-creation_date'
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30' default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
instance_point="https://$instance/api/v1" instance_point="https://$instance/api/v1"
download_selected_track=$(jj -i config.json download_selected_track) download_selected_track=$(jj -i config.json download_selected_track)
local_content_only=$(jj -i config.json local_content_only)
touch .auth.json touch .auth.json
chmod 600 .auth.json chmod 600 .auth.json
@ -16,7 +17,7 @@ make_login()
if [ -n "$auth" ]; then if [ -n "$auth" ]; then
default_curl_opt() 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) listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen)
echo '+Authorized account+' echo '+Authorized account+'
@ -26,7 +27,7 @@ make_login()
export listen_token export listen_token
default_curl_opt() default_curl_opt()
{ {
curl -s --compressed "$@" curl --retry 3 -s --compressed "$@"
} }
fi fi
export default_curl_opt export default_curl_opt
@ -65,8 +66,13 @@ funkwhale_api_tags()
funkwhale_api_get_tracks() funkwhale_api_get_tracks()
{ {
if [ "$local_content_only" = 'true' ]; then
default_scope="domain:$instance"
else
default_scope='all'
fi
default_curl_opt \ 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 2>&1 | tee preload
} }