From 658d50a825bbfc262267ebdb9b45d9eccee5f03a Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Sun, 17 Jul 2022 13:57:38 +0300 Subject: [PATCH] New: simulate funkwhale fs (beta) --- config.json | 2 +- funkwhale-cli.sh | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/config.json b/config.json index 0926725..e6100ac 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,5 @@ { - "instance": "sound.redeyes.club", + "instance": "fw.ponychord.rocks", "download_selected_track": false, "tags": [ "8bit", diff --git a/funkwhale-cli.sh b/funkwhale-cli.sh index 6593169..3480e4b 100755 --- a/funkwhale-cli.sh +++ b/funkwhale-cli.sh @@ -2,7 +2,7 @@ instance=$(jj -i config.json instance) instance_hist='instance.hist' -ordering='title' +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) @@ -64,7 +64,7 @@ funkwhale_api_tags() funkwhale_api_get_tracks() { default_curl_opt \ - "$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag&artist=$2" \ + "$instance_point/tracks?ordering=$ordering&playable=true&page_size=50&page=$1&tag=$tag&artist=$2" \ 2>&1 | tee preload } @@ -346,6 +346,36 @@ get_all_avalaible_count_tracks() fi } +funkwhale_pseudofs_load() +{ + # Создаёт дерево каталогов из id исполнителей + # В каждый каталог складывает плейлист с URL треков для прослушивания\закачки + # tree: + # [fwfs_instance.url] + # | + # | -- [id исполнителя] + # | | + # | | -- плейлист с треками + # | ... + mkdir -p "fwfs_$instance" + counter_page=1 + while true; do + tracks=$(funkwhale_api_get_tracks $counter_page) + next_check=$(echo "$tracks" | jj next) + echo "$next_check" + for idartist in $(echo "$tracks" | jj -l 'results.#.artist.id' | delq | sort -u); do + mkdir -p "fwfs_$instance/$idartist" + echo "$tracks" | jj -l "results.#[artist.id=$idartist].uploads.0.listen_url" | delq | sed "s/^/https:\/\/$instance/" | sed "s/$/\&token=$listen_token/" >> "fwfs_$instance/$idartist/playlist.m3u8" + chmod 600 fwfs_$instance/$idartist/playlist.m3u8 + done + if [ -z "$next_check" ]; then + break + fi + counter_page=$(expr $counter_page + 1) + + done +} +# funkwhale_pseudofs_load # beta get_all_avalaible_count_tracks trackspls='Tracks'