Compare commits

..

No commits in common. "125c76bbed0f368a16cd4579d3a13e9744627bb2" and "58255c373586be5f03d4c8290357d5c1bc306900" have entirely different histories.

3 changed files with 13 additions and 49 deletions

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
playlist.m3u8
preload
instance.hist
.auth.json

View file

@ -25,7 +25,6 @@
"Reggae",
"Rock",
"Singler",
"Synth",
"Songwriter",
"Soundtrack",
"Vocal"

View file

@ -4,38 +4,22 @@ instance=$(jj -i config.json instance)
instance_hist='instance.hist'
ordering='title'
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
instance_point="https://$instance/api/v1"
touch .auth.json
chmod 600 .auth.json
auth="$(jj -i .auth.json "$(echo $instance | sed 's/\./\\\./g')")"
if [ -n "$auth" ]; then
default_curl_opt()
{
curl -s --compressed -H "Authorization: Bearer $auth" $1
}
listen_token=$(default_curl_opt "$instance_point/users/me" | jj tokens.listen)
echo '+Authorized account+'
else
default_curl_opt()
{
curl -s --compressed $1
}
fi
instance_point="https://$instance/api/v1"
funkwhale_api_check_api_limits()
{
default_curl_opt "$instance_point/rate-limit/" | jj -p
curl -s --compressed "$instance_point/rate-limit/" | jj -p
}
funkwhale_api_get_tracks()
{
get_json=$(default_curl_opt "$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag" 2>&1 | tee preload)
get_json=$(curl -s --compressed "$instance_point/tracks?ordering=$ordering&playable=true&page=$1&tag=$tag" 2>&1 | tee preload)
jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
}
funkwhale_api_get_albums()
{
get_json=$(default_curl_opt "$instance_point/albums?ordering=$ordering&playable=true&page=$1" 2>&1 | tee preload)
get_json=$(curl -s --compressed "$instance_point/albums?ordering=$ordering&playable=true&page=$1" 2>&1 | tee preload)
}
funkwhale_menu_albums()
@ -67,7 +51,7 @@ funkwhale_menu_albums_tracks()
level=1
fi
tracks_a=$(default_curl_opt "$instance_point/tracks?ordering=$ordering&playable=true&album=$1&page_size=50")
tracks_a=$(curl -s --compressed "$instance_point/tracks?ordering=$ordering&playable=true&album=$1&page_size=50")
while [ $sub2_menu -eq $level ]; do
@ -85,36 +69,27 @@ funkwhale_menu_albums_tracks()
"Listen all")
echo > playlist.m3u8
chmod 600 playlist.m3u8
for i in $playlist; do
if [ -n "$auth" ]; then
echo "https://$instance$i?token=$listen_token\n" >> playlist.m3u8
else
echo "https://$instance$i\n" >> playlist.m3u8
fi
echo "https://$instance$i\n" >> playlist.m3u8
done
$default_player_command playlist.m3u8 ;;
*)
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
play_track=$(echo $tracks_a | jj results.$index.listen_url)
if [ -n "$auth" ]; then
$default_player_command "https://$instance$play_track?token=$listen_token"
else
$default_player_command "https://$instance$play_track"
fi ;;
$default_player_command "https://$instance$play_track" ;;
esac
done
}
funkwhale_api_get_artists()
{
default_curl_opt "$instance_point/artists?ordering=-creation_date&playable=true&page=$1"
curl -s --compressed "$instance_point/artists?ordering=-creation_date&playable=true&page=$1"
}
funkwhale_api_get_artist()
{
default_curl_opt "$instance_point/artists/$1"
curl -s --compressed "$instance_point/artists/$1"
}
funkwhale_menu_artists()
@ -162,7 +137,7 @@ funkwhale_menu_albums_artist()
funkwhale_api_get_tracks_from_channel()
{
sub2_menu=1
track_list=$(default_curl_opt "$instance_point/tracks?channel=$1&playable=true&include_channels=true")
track_list=$(curl -s --compressed "$instance_point/tracks?channel=$1&playable=true&include_channels=true")
echo "Loaded $(echo $track_list | jj count) podcasts"
while [ $sub2_menu -eq 1 ]; do
@ -174,11 +149,7 @@ funkwhale_api_get_tracks_from_channel()
*)
index=$(echo $menu_podcast_choice | cut -f 1 -d:)
play_track=$(echo $track_list | jj results.$index.listen_url)
if [ -n "$auth" ]; then
$default_player_command "https://$instance$play_track&token=$listen_token"
else
$default_player_command "https://$instance$play_track"
fi ;;
$default_player_command "https://$instance$play_track" ;;
esac
done
}
@ -187,7 +158,7 @@ funkwhale_get_podcasts_artists()
{
sub_menu=1
echo 'Loading podcast artists...'
default_curl_opt "$instance_point/artists?ordering=-creation_date&playable=true&include_channels=true&content_category=podcast&page=$1" | tee preload 1>> /dev/null
curl -s --compressed --output preload "$instance_point/artists?ordering=-creation_date&playable=true&include_channels=true&content_category=podcast&page=$1"
while [ $sub_menu -eq 1 ]; do
count_artists=$(jj -i preload count)
echo "$count_artists avalaible"
@ -213,7 +184,6 @@ load_tracks_to_playlist()
{
echo "Loading page $1 ..."
echo '#EXTM3U\n' > playlist.m3u8
chmod 600 playlist.m3u8
counter_titles=0
for i in $(funkwhale_api_get_tracks $1); do
title=$(jj -i preload results."$counter_titles".title)
@ -221,11 +191,7 @@ load_tracks_to_playlist()
duration=$(jj -i preload results."$counter_titles".uploads.0.duration)
echo "#EXTINF:$duration, $artist_name - $title" >> playlist.m3u8
counter_titles=$(expr $counter_titles + 1)
if [ -n "$auth" ]; then
echo "https://$instance$i&token=$listen_token\n" >> playlist.m3u8
else
echo "https://$instance$i\n" >> playlist.m3u8
fi
echo "https://$instance$i\n" >> playlist.m3u8
done
count_tracks_results=$(jj -i preload 'results.#')
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then