Compare commits

..

No commits in common. "e9bf20106585a54c16860e3f957e2fa14d3ccd8f" and "658d50a825bbfc262267ebdb9b45d9eccee5f03a" have entirely different histories.

View file

@ -22,8 +22,6 @@ make_login()
echo '+Authorized account+' echo '+Authorized account+'
export listen_token export listen_token
else else
listen_token=''
export listen_token
default_curl_opt() default_curl_opt()
{ {
curl -s --compressed "$@" curl -s --compressed "$@"
@ -338,7 +336,7 @@ funkwhale_get_podcasts_artists()
get_all_avalaible_count_tracks() get_all_avalaible_count_tracks()
{ {
funkwhale_api_get_tracks 1 1>> /dev/null funkwhale_api_get_tracks 1 1>> /dev/null
export count_all_tracks=$(jj -i preload -l count) count_all_tracks=$(jj -i preload -l count)
if [ -z "$count_all_tracks" ]; then if [ -z "$count_all_tracks" ]; then
echo 'Error: Connection error or API limit expired' echo 'Error: Connection error or API limit expired'
elif [ "$count_all_tracks" -eq 0 ]; then elif [ "$count_all_tracks" -eq 0 ]; then
@ -347,7 +345,6 @@ get_all_avalaible_count_tracks()
echo "Tracks avalaible on $instance: $count_all_tracks\n" echo "Tracks avalaible on $instance: $count_all_tracks\n"
fi fi
} }
get_all_avalaible_count_tracks
funkwhale_pseudofs_load() funkwhale_pseudofs_load()
{ {
@ -360,73 +357,37 @@ funkwhale_pseudofs_load()
# | | # | |
# | | -- плейлист с треками # | | -- плейлист с треками
# | ... # | ...
echo "Processing..."
mkdir -p "fwfs_$instance" mkdir -p "fwfs_$instance"
counter_page=1 counter_page=1
tracks_counter_watch=0
skip_count=0
while true; do while true; do
tracks=$(funkwhale_api_get_tracks $counter_page) tracks=$(funkwhale_api_get_tracks $counter_page)
next_check=$(echo "$tracks" | jj next) next_check=$(echo "$tracks" | jj next)
echo "$next_check"
for idartist in $(echo "$tracks" | jj -l 'results.#.artist.id' | delq | sort -u); do for idartist in $(echo "$tracks" | jj -l 'results.#.artist.id' | delq | sort -u); do
mkdir -p "fwfs_$instance/$idartist" mkdir -p "fwfs_$instance/$idartist"
if [ ! -f "fwfs_$instance/$idartist/playlist.m3u8" ]; then 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"
echo '#EXTM3U' > "fwfs_$instance/$idartist/playlist.m3u8" chmod 600 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 done
if [ -z "$next_check" ]; then if [ -z "$next_check" ]; then
break break
fi fi
counter_page=$(expr $counter_page + 1) counter_page=$(expr $counter_page + 1)
echo "page $counter_page"
done done
} }
# funkwhale_pseudofs_load # beta
funkwhale_pseudofs_transcode_switch() get_all_avalaible_count_tracks
{
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' trackspls='Tracks'
albumsmenu='Albums' albumsmenu='Albums'
artistmenu='Artists' artistmenu='Artists'
podcasts='Podcasts' podcasts='Podcasts'
changepod='Switch instance' changepod='Switch instance'
load_pseudofs='Create artists local playlist'
checkapilimits='Check API limits (debug)' checkapilimits='Check API limits (debug)'
Exit='Exit' Exit='Exit'
while true; do while true; do
choice=$(echo "$trackspls\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$load_pseudofs\n$checkapilimits\n$Exit" | fzy) choice=$(echo "$trackspls\n$albumsmenu\n$artistmenu\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
case "$choice" in case "$choice" in
"$trackspls") "$trackspls")
@ -493,9 +454,6 @@ case "$choice" in
get_all_avalaible_count_tracks get_all_avalaible_count_tracks
fi ;; fi ;;
"$load_pseudofs")
funkwhale_pseudofs_load ;; # beta
"$checkapilimits") "$checkapilimits")
funkwhale_api_check_api_limits | more ;; funkwhale_api_check_api_limits | more ;;