feature: tags from instance

This commit is contained in:
localhost_frssoft 2022-04-15 12:32:53 +03:00
parent d0772a5003
commit f0ef665ca0
3 changed files with 29 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
tags_db
playlist.m3u8 playlist.m3u8
preload preload
instance.hist instance.hist

View File

@ -1,7 +1,6 @@
{ {
"instance": "sound.redeyes.club", "instance": "sound.redeyes.club",
"tags": [ "tags": [
"TagOFF",
"8bit", "8bit",
"Alternative", "Alternative",
"Ambient", "Ambient",

View File

@ -27,6 +27,25 @@ funkwhale_api_check_api_limits()
default_curl_opt "$instance_point/rate-limit/" | jj -p 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() funkwhale_api_get_tracks()
{ {
default_curl_opt \ 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) ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
export ordering export ordering
echo 'Tags:' echo 'Tags:'
tag=$(jj -l -i config.json tags | sed 's/"//g' | fzy)
if [ "$tag" = "TagOFF" ]; then tag=$(echo "TagOFF\nTags from instance\n$(jj -l -i config.json tags | sed 's/\"//g')" | fzy)
tag= case $tag in
fi "TagOFF") tag= ;;
"Tags from instance") funkwhale_api_tags ;;
esac
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=
;;
"$albumsmenu") "$albumsmenu")
echo 'Enter page number: ' echo 'Enter page number: '