mirror of
https://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-12-23 12:43:33 +02:00
Some fixes and improvments
This commit is contained in:
parent
658d50a825
commit
bffd430fc8
1 changed files with 38 additions and 7 deletions
|
@ -22,6 +22,8 @@ make_login()
|
|||
echo '+Authorized account+'
|
||||
export listen_token
|
||||
else
|
||||
listen_token=''
|
||||
export listen_token
|
||||
default_curl_opt()
|
||||
{
|
||||
curl -s --compressed "$@"
|
||||
|
@ -336,7 +338,7 @@ funkwhale_get_podcasts_artists()
|
|||
get_all_avalaible_count_tracks()
|
||||
{
|
||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||
count_all_tracks=$(jj -i preload -l count)
|
||||
export count_all_tracks=$(jj -i preload -l count)
|
||||
if [ -z "$count_all_tracks" ]; then
|
||||
echo 'Error: Connection error or API limit expired'
|
||||
elif [ "$count_all_tracks" -eq 0 ]; then
|
||||
|
@ -345,6 +347,7 @@ get_all_avalaible_count_tracks()
|
|||
echo "Tracks avalaible on $instance: $count_all_tracks\n"
|
||||
fi
|
||||
}
|
||||
get_all_avalaible_count_tracks
|
||||
|
||||
funkwhale_pseudofs_load()
|
||||
{
|
||||
|
@ -357,37 +360,62 @@ funkwhale_pseudofs_load()
|
|||
# | |
|
||||
# | | -- плейлист с треками
|
||||
# | ...
|
||||
echo "Processing..."
|
||||
mkdir -p "fwfs_$instance"
|
||||
counter_page=1
|
||||
tracks_counter_watch=0
|
||||
skip_count=0
|
||||
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
|
||||
if [ ! -f "fwfs_$instance/$idartist/playlist.m3u8" ]; then
|
||||
echo '#EXTM3U' > "fwfs_$instance/$idartist/playlist.m3u8"
|
||||
fi
|
||||
|
||||
get_tracks_uuid_by_artist_id=$(echo "$tracks" | jj -l "results.#[artist.id=$idartist]#.uploads.0.uuid" | delq)
|
||||
for track in $get_tracks_uuid_by_artist_id; do
|
||||
artist_name=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].artist.name")
|
||||
album_name=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].album.title")
|
||||
track_name=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].title")
|
||||
extension=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].uploads.0.extension")
|
||||
duration=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].uploads.0.duration")
|
||||
track_filename=$(echo "$artist_name - $album_name - $track_name.$extension")
|
||||
listen_url=$(echo "$tracks" | jj "results.#[uploads.0.uuid="$track"].uploads.0.listen_url")
|
||||
full_url=$(echo $listen_url | delq | sed "s/^/https:\/\/$instance/ ; s/$/\&token=$listen_token\&to=ogg/")
|
||||
echo "adding "$idartist"_$track_filename"
|
||||
exists_test=$(grep -F ""$idartist"_$track_filename" "fwfs_$instance/$idartist/playlist.m3u8")
|
||||
if [ -n "$exists_test" ]; then
|
||||
skip_count=$(expr $skip_count + 1)
|
||||
else
|
||||
echo "#EXTINF:$duration, "$idartist"_$track_filename\n$full_url" >> "fwfs_$instance/$idartist/playlist.m3u8"
|
||||
fi
|
||||
tracks_counter_watch=$(expr $tracks_counter_watch + 1)
|
||||
echo "current: $tracks_counter_watch skipped: $skip_count total: $count_all_tracks"
|
||||
done
|
||||
chmod 600 "fwfs_$instance/$idartist/playlist.m3u8"
|
||||
done
|
||||
if [ -z "$next_check" ]; then
|
||||
break
|
||||
fi
|
||||
counter_page=$(expr $counter_page + 1)
|
||||
echo "page $counter_page"
|
||||
|
||||
done
|
||||
}
|
||||
# funkwhale_pseudofs_load # beta
|
||||
get_all_avalaible_count_tracks
|
||||
|
||||
trackspls='Tracks'
|
||||
albumsmenu='Albums'
|
||||
artistmenu='Artists'
|
||||
podcasts='Podcasts'
|
||||
changepod='Switch instance'
|
||||
load_pseudofs='Create artists local playlist'
|
||||
checkapilimits='Check API limits (debug)'
|
||||
Exit='Exit'
|
||||
|
||||
while true; do
|
||||
choice=$(echo "$trackspls\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
||||
choice=$(echo "$trackspls\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$load_pseudofs\n$checkapilimits\n$Exit" | fzy)
|
||||
|
||||
case "$choice" in
|
||||
"$trackspls")
|
||||
|
@ -454,6 +482,9 @@ case "$choice" in
|
|||
get_all_avalaible_count_tracks
|
||||
fi ;;
|
||||
|
||||
"$load_pseudofs")
|
||||
funkwhale_pseudofs_load ;; # beta
|
||||
|
||||
|
||||
"$checkapilimits")
|
||||
funkwhale_api_check_api_limits | more ;;
|
||||
|
|
Loading…
Reference in a new issue