mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-25 20:21:28 +00:00
Compare commits
4 commits
6be73701cd
...
eefc247b64
Author | SHA1 | Date | |
---|---|---|---|
localhost_frssoft | eefc247b64 | ||
localhost_frssoft | 77c62d575e | ||
localhost_frssoft | 009abf2065 | ||
localhost_frssoft | 8b60996e79 |
|
@ -4,20 +4,21 @@ instance=$(jj -i config.json instance)
|
|||
ordering='title'
|
||||
default_player_command='mpv --no-vid --no-ytdl --network-timeout=30'
|
||||
|
||||
instance_point="https://$instance/api/v1"
|
||||
funkwhale_api_check_api_limits()
|
||||
{
|
||||
curl -s --compressed "https://$instance/api/v1/rate-limit/" | jj -p
|
||||
curl -s --compressed "$instance_point/rate-limit/" | jj -p
|
||||
}
|
||||
|
||||
funkwhale_api_get_tracks()
|
||||
{
|
||||
get_json=$(curl -s --compressed "https://$instance/api/v1/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_tracks_from_channel()
|
||||
{
|
||||
track_list=$(curl -s --compressed "https://$instance/api/v1/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 $track_list | jj -l results.#.title
|
||||
listen_urls=$(echo $track_list | jj -l results.#.listen_url | sed 's/"//g')
|
||||
|
@ -31,7 +32,7 @@ funkwhale_api_get_tracks_from_channel()
|
|||
funkwhale_get_podcasts_artists()
|
||||
{
|
||||
echo 'Loading podcast artists...'
|
||||
curl -s --compressed --output preload "https://$instance/api/v1/artists?ordering=-creation_date&playable=true&include_channels=true&content_category=podcast&page=$1"
|
||||
curl -s --compressed --output preload "$instance_point/artists?ordering=-creation_date&playable=true&include_channels=true&content_category=podcast&page=$1"
|
||||
counter=0
|
||||
count_artists=$(jj -i preload count)
|
||||
echo "$count_artists avalaible"
|
||||
|
@ -62,8 +63,8 @@ load_tracks_to_playlist()
|
|||
echo "https://$instance$i\n" >> playlist.m3u8
|
||||
done
|
||||
count_tracks_results=$(jj -i preload 'results.#')
|
||||
if [ -z $count_tracks_results ]; then
|
||||
echo 'Error: Page empty or 500 Internal Server Error'
|
||||
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then
|
||||
echo 'Error: Page empty or connection error'
|
||||
else
|
||||
echo "Loaded $count_tracks_results tracks"
|
||||
fi
|
||||
|
@ -73,7 +74,13 @@ get_all_avalaible_count_tracks()
|
|||
{
|
||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||
count_all_tracks=$(jj -i preload -l count)
|
||||
echo "Tracks avalaible on $instance: $count_all_tracks\n"
|
||||
if [ -z $count_all_tracks ]; then
|
||||
echo 'Error: Connection error or API limit expired'
|
||||
elif [ $count_all_tracks -eq 0 ]; then
|
||||
echo 'Error: No tracks'
|
||||
else
|
||||
echo "Tracks avalaible on $instance: $count_all_tracks\n"
|
||||
fi
|
||||
}
|
||||
|
||||
get_all_avalaible_count_tracks
|
||||
|
@ -88,7 +95,8 @@ Exit='Exit'
|
|||
while true; do
|
||||
choice=$(echo "$downloadtrackspls\n$startplayer\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
||||
|
||||
if [ "$choice" = "$downloadtrackspls" ]; then
|
||||
case "$choice" in
|
||||
"$downloadtrackspls")
|
||||
echo 'Order by (prefix - is DESC ordering):'
|
||||
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
||||
export ordering
|
||||
|
@ -100,21 +108,29 @@ if [ "$choice" = "$downloadtrackspls" ]; then
|
|||
export tag
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
load_tracks_to_playlist $page
|
||||
elif [ "$choice" = "$startplayer" ]; then
|
||||
$default_player_command playlist.m3u8
|
||||
elif [ "$choice" = "$podcasts" ]; then
|
||||
load_tracks_to_playlist $page ;;
|
||||
|
||||
|
||||
"$startplayer")
|
||||
$default_player_command playlist.m3u8 ;;
|
||||
|
||||
|
||||
"$podcasts")
|
||||
echo 'Enter page number: '
|
||||
read page
|
||||
funkwhale_get_podcasts_artists $page
|
||||
elif [ "$choice" = "$changepod" ]; then
|
||||
funkwhale_get_podcasts_artists $page ;;
|
||||
|
||||
|
||||
"$changepod")
|
||||
if [ 'Choice from list' = "$(echo 'Choice from list\nManual input' | fzy)" ]; then
|
||||
instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy)
|
||||
else
|
||||
echo "Type instance (ex. $instance):"
|
||||
read instance
|
||||
fi
|
||||
|
||||
export instance
|
||||
export instance_point="https://$instance/api/v1"
|
||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||
if [ "$conf_instance_state" = 'Permanent' ]; then
|
||||
jj -i config.json instance -v $instance -o config.json
|
||||
|
@ -122,10 +138,14 @@ elif [ "$choice" = "$changepod" ]; then
|
|||
echo ''
|
||||
fi
|
||||
clear
|
||||
get_all_avalaible_count_tracks
|
||||
elif [ "$choice" = "$checkapilimits" ]; then
|
||||
funkwhale_api_check_api_limits | more
|
||||
elif [ "$choice" = "$Exit" ]; then
|
||||
exit 0
|
||||
fi
|
||||
get_all_avalaible_count_tracks ;;
|
||||
|
||||
|
||||
"$checkapilimits")
|
||||
funkwhale_api_check_api_limits | more ;;
|
||||
|
||||
|
||||
"$Exit")
|
||||
exit 0 ;;
|
||||
esac
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue