mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-26 09:01:28 +00:00
Compare commits
No commits in common. "125c76bbed0f368a16cd4579d3a13e9744627bb2" and "58255c373586be5f03d4c8290357d5c1bc306900" have entirely different histories.
125c76bbed
...
58255c3735
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
playlist.m3u8
|
playlist.m3u8
|
||||||
preload
|
preload
|
||||||
instance.hist
|
instance.hist
|
||||||
.auth.json
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
"Reggae",
|
"Reggae",
|
||||||
"Rock",
|
"Rock",
|
||||||
"Singler",
|
"Singler",
|
||||||
"Synth",
|
|
||||||
"Songwriter",
|
"Songwriter",
|
||||||
"Soundtrack",
|
"Soundtrack",
|
||||||
"Vocal"
|
"Vocal"
|
||||||
|
|
|
@ -4,38 +4,22 @@ instance=$(jj -i config.json instance)
|
||||||
instance_hist='instance.hist'
|
instance_hist='instance.hist'
|
||||||
ordering='title'
|
ordering='title'
|
||||||
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
|
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
|
||||||
instance_point="https://$instance/api/v1"
|
|
||||||
|
|
||||||
touch .auth.json
|
instance_point="https://$instance/api/v1"
|
||||||
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
|
|
||||||
funkwhale_api_check_api_limits()
|
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()
|
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'
|
jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
funkwhale_api_get_albums()
|
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()
|
funkwhale_menu_albums()
|
||||||
|
@ -67,7 +51,7 @@ funkwhale_menu_albums_tracks()
|
||||||
level=1
|
level=1
|
||||||
fi
|
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
|
while [ $sub2_menu -eq $level ]; do
|
||||||
|
@ -85,36 +69,27 @@ funkwhale_menu_albums_tracks()
|
||||||
|
|
||||||
"Listen all")
|
"Listen all")
|
||||||
echo > playlist.m3u8
|
echo > playlist.m3u8
|
||||||
chmod 600 playlist.m3u8
|
|
||||||
for i in $playlist; do
|
for i in $playlist; do
|
||||||
if [ -n "$auth" ]; then
|
echo "https://$instance$i\n" >> playlist.m3u8
|
||||||
echo "https://$instance$i?token=$listen_token\n" >> playlist.m3u8
|
|
||||||
else
|
|
||||||
echo "https://$instance$i\n" >> playlist.m3u8
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
$default_player_command playlist.m3u8 ;;
|
$default_player_command playlist.m3u8 ;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
index=$(echo $menu_album_tracks_choice | cut -f 1 -d:)
|
||||||
play_track=$(echo $tracks_a | jj results.$index.listen_url)
|
play_track=$(echo $tracks_a | jj results.$index.listen_url)
|
||||||
if [ -n "$auth" ]; then
|
$default_player_command "https://$instance$play_track" ;;
|
||||||
$default_player_command "https://$instance$play_track?token=$listen_token"
|
|
||||||
else
|
|
||||||
$default_player_command "https://$instance$play_track"
|
|
||||||
fi ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
funkwhale_api_get_artists()
|
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()
|
funkwhale_api_get_artist()
|
||||||
{
|
{
|
||||||
default_curl_opt "$instance_point/artists/$1"
|
curl -s --compressed "$instance_point/artists/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
funkwhale_menu_artists()
|
funkwhale_menu_artists()
|
||||||
|
@ -162,7 +137,7 @@ funkwhale_menu_albums_artist()
|
||||||
funkwhale_api_get_tracks_from_channel()
|
funkwhale_api_get_tracks_from_channel()
|
||||||
{
|
{
|
||||||
sub2_menu=1
|
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"
|
echo "Loaded $(echo $track_list | jj count) podcasts"
|
||||||
|
|
||||||
while [ $sub2_menu -eq 1 ]; do
|
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:)
|
index=$(echo $menu_podcast_choice | cut -f 1 -d:)
|
||||||
play_track=$(echo $track_list | jj results.$index.listen_url)
|
play_track=$(echo $track_list | jj results.$index.listen_url)
|
||||||
if [ -n "$auth" ]; then
|
$default_player_command "https://$instance$play_track" ;;
|
||||||
$default_player_command "https://$instance$play_track&token=$listen_token"
|
|
||||||
else
|
|
||||||
$default_player_command "https://$instance$play_track"
|
|
||||||
fi ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -187,7 +158,7 @@ funkwhale_get_podcasts_artists()
|
||||||
{
|
{
|
||||||
sub_menu=1
|
sub_menu=1
|
||||||
echo 'Loading podcast artists...'
|
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
|
while [ $sub_menu -eq 1 ]; do
|
||||||
count_artists=$(jj -i preload count)
|
count_artists=$(jj -i preload count)
|
||||||
echo "$count_artists avalaible"
|
echo "$count_artists avalaible"
|
||||||
|
@ -213,7 +184,6 @@ load_tracks_to_playlist()
|
||||||
{
|
{
|
||||||
echo "Loading page $1 ..."
|
echo "Loading page $1 ..."
|
||||||
echo '#EXTM3U\n' > playlist.m3u8
|
echo '#EXTM3U\n' > playlist.m3u8
|
||||||
chmod 600 playlist.m3u8
|
|
||||||
counter_titles=0
|
counter_titles=0
|
||||||
for i in $(funkwhale_api_get_tracks $1); do
|
for i in $(funkwhale_api_get_tracks $1); do
|
||||||
title=$(jj -i preload results."$counter_titles".title)
|
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)
|
duration=$(jj -i preload results."$counter_titles".uploads.0.duration)
|
||||||
echo "#EXTINF:$duration, $artist_name - $title" >> playlist.m3u8
|
echo "#EXTINF:$duration, $artist_name - $title" >> playlist.m3u8
|
||||||
counter_titles=$(expr $counter_titles + 1)
|
counter_titles=$(expr $counter_titles + 1)
|
||||||
if [ -n "$auth" ]; then
|
echo "https://$instance$i\n" >> playlist.m3u8
|
||||||
echo "https://$instance$i&token=$listen_token\n" >> playlist.m3u8
|
|
||||||
else
|
|
||||||
echo "https://$instance$i\n" >> playlist.m3u8
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
count_tracks_results=$(jj -i preload 'results.#')
|
count_tracks_results=$(jj -i preload 'results.#')
|
||||||
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then
|
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then
|
||||||
|
|
Loading…
Reference in a new issue