From f0ef665ca02ce1b65ec79c082faa0f02d6042249 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Fri, 15 Apr 2022 12:32:53 +0300 Subject: [PATCH] feature: tags from instance --- .gitignore | 1 + config.json | 1 - funkwhale-cli.sh | 33 ++++++++++++++++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index c21d91e..5f49724 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +tags_db playlist.m3u8 preload instance.hist diff --git a/config.json b/config.json index 5725eff..7007197 100644 --- a/config.json +++ b/config.json @@ -1,7 +1,6 @@ { "instance": "sound.redeyes.club", "tags": [ - "TagOFF", "8bit", "Alternative", "Ambient", diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 03d77ff..47c7298 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -27,6 +27,25 @@ funkwhale_api_check_api_limits() default_curl_opt "$instance_point/rate-limit/" | jj -p } +funkwhale_api_tags() +{ + mkdir -p tags_db + if [ ! -f "tags_db/tags_$instance" ]; then + tagsload=$(default_curl_opt "$instance_point/tags?playable=true") + pageindex=$(echo $tagsload | jj next) + echo $tagsload | jj -l results.#.name | sed 's/"//g' > tags_db/tags_$instance + clear + while [ -n "$pageindex" ]; do + echo "Loading... +$(echo $tagsload | jj results.#) tags" + echo $tagsload | jj -l results.#.name | sed 's/"//g' >> tags_db/tags_$instance + pageindex=$(echo $tagsload | jj next) + tagsload=$(default_curl_opt "$pageindex") + sleep 1 + done + fi + tag=$(cat tags_db/tags_$instance | fzy) +} + funkwhale_api_get_tracks() { default_curl_opt \ @@ -310,14 +329,18 @@ case "$choice" in ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy) export ordering echo 'Tags:' - tag=$(jj -l -i config.json tags | sed 's/"//g' | fzy) - if [ "$tag" = "TagOFF" ]; then - tag= - fi + + tag=$(echo "TagOFF\nTags from instance\n$(jj -l -i config.json tags | sed 's/\"//g')" | fzy) + case $tag in + "TagOFF") tag= ;; + "Tags from instance") funkwhale_api_tags ;; + esac export tag echo 'Enter page number: ' read page - funkwhale_menu_tracks $page ;; + funkwhale_menu_tracks $page + tag= + ;; "$albumsmenu") echo 'Enter page number: '