New: simulate funkwhale fs (beta)

This commit is contained in:
localhost_frssoft 2022-07-17 13:57:38 +03:00
parent 64e74bca2f
commit 658d50a825
2 changed files with 33 additions and 3 deletions

View File

@ -1,5 +1,5 @@
{
"instance": "sound.redeyes.club",
"instance": "fw.ponychord.rocks",
"download_selected_track": false,
"tags": [
"8bit",

View File

@ -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'