Compare commits

..

2 commits

Author SHA1 Message Date
localhost_frssoft e9bf201065 implement transcode switcher 2022-07-18 02:10:58 +03:00
localhost_frssoft bffd430fc8 Some fixes and improvments 2022-07-18 01:44:39 +03:00

View file

@ -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,73 @@ 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
funkwhale_pseudofs_transcode_switch()
{
echo "Transcode to"
transcode_ch=$(echo "none\nogg\nmp3" | fzy)
if [ "$transcode_ch" = 'none' ]; then
find "fwfs_$instance" -type f -exec sed -i 's/to=.*/to=/' {} +
else
find "fwfs_$instance" -type f -exec sed -i "s/to=.*/to=$transcode_ch/" {} +
fi
}
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 +493,9 @@ case "$choice" in
get_all_avalaible_count_tracks
fi ;;
"$load_pseudofs")
funkwhale_pseudofs_load ;; # beta
"$checkapilimits")
funkwhale_api_check_api_limits | more ;;