mirror of
http://gitea.phreedom.club/localhost_frssoft/funkwlmpv
synced 2024-11-22 13:41: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'
|
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"
|
||||||
funkwhale_api_check_api_limits()
|
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()
|
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'
|
jj -i preload -l 'results.#.uploads.0.listen_url' | sed 's/"//g'
|
||||||
}
|
}
|
||||||
|
|
||||||
funkwhale_api_get_tracks_from_channel()
|
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 "Loaded $(echo $track_list | jj count) podcasts"
|
||||||
echo $track_list | jj -l results.#.title
|
echo $track_list | jj -l results.#.title
|
||||||
listen_urls=$(echo $track_list | jj -l results.#.listen_url | sed 's/"//g')
|
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()
|
funkwhale_get_podcasts_artists()
|
||||||
{
|
{
|
||||||
echo 'Loading podcast 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
|
counter=0
|
||||||
count_artists=$(jj -i preload count)
|
count_artists=$(jj -i preload count)
|
||||||
echo "$count_artists avalaible"
|
echo "$count_artists avalaible"
|
||||||
|
@ -62,8 +63,8 @@ load_tracks_to_playlist()
|
||||||
echo "https://$instance$i\n" >> playlist.m3u8
|
echo "https://$instance$i\n" >> playlist.m3u8
|
||||||
done
|
done
|
||||||
count_tracks_results=$(jj -i preload 'results.#')
|
count_tracks_results=$(jj -i preload 'results.#')
|
||||||
if [ -z $count_tracks_results ]; then
|
if [ -z $count_tracks_results ] || [ $count_tracks_results -eq 0 ]; then
|
||||||
echo 'Error: Page empty or 500 Internal Server Error'
|
echo 'Error: Page empty or connection error'
|
||||||
else
|
else
|
||||||
echo "Loaded $count_tracks_results tracks"
|
echo "Loaded $count_tracks_results tracks"
|
||||||
fi
|
fi
|
||||||
|
@ -73,7 +74,13 @@ get_all_avalaible_count_tracks()
|
||||||
{
|
{
|
||||||
funkwhale_api_get_tracks 1 1>> /dev/null
|
funkwhale_api_get_tracks 1 1>> /dev/null
|
||||||
count_all_tracks=$(jj -i preload -l count)
|
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
|
get_all_avalaible_count_tracks
|
||||||
|
@ -88,7 +95,8 @@ Exit='Exit'
|
||||||
while true; do
|
while true; do
|
||||||
choice=$(echo "$downloadtrackspls\n$startplayer\n$podcasts\n$changepod\n$checkapilimits\n$Exit" | fzy)
|
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):'
|
echo 'Order by (prefix - is DESC ordering):'
|
||||||
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
ordering=$(echo 'title\n-title\ncreation_date\n-creation_date\nrelease_date\n-release_date\nrandom' | fzy)
|
||||||
export ordering
|
export ordering
|
||||||
|
@ -100,21 +108,29 @@ if [ "$choice" = "$downloadtrackspls" ]; then
|
||||||
export tag
|
export tag
|
||||||
echo 'Enter page number: '
|
echo 'Enter page number: '
|
||||||
read page
|
read page
|
||||||
load_tracks_to_playlist $page
|
load_tracks_to_playlist $page ;;
|
||||||
elif [ "$choice" = "$startplayer" ]; then
|
|
||||||
$default_player_command playlist.m3u8
|
|
||||||
elif [ "$choice" = "$podcasts" ]; then
|
"$startplayer")
|
||||||
|
$default_player_command playlist.m3u8 ;;
|
||||||
|
|
||||||
|
|
||||||
|
"$podcasts")
|
||||||
echo 'Enter page number: '
|
echo 'Enter page number: '
|
||||||
read page
|
read page
|
||||||
funkwhale_get_podcasts_artists $page
|
funkwhale_get_podcasts_artists $page ;;
|
||||||
elif [ "$choice" = "$changepod" ]; then
|
|
||||||
|
|
||||||
|
"$changepod")
|
||||||
if [ 'Choice from list' = "$(echo 'Choice from list\nManual input' | fzy)" ]; then
|
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)
|
instance=$(jj -l -i config.json public_list_instances | sed 's/"//g' | fzy)
|
||||||
else
|
else
|
||||||
echo "Type instance (ex. $instance):"
|
echo "Type instance (ex. $instance):"
|
||||||
read instance
|
read instance
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export instance
|
export instance
|
||||||
|
export instance_point="https://$instance/api/v1"
|
||||||
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
conf_instance_state=$(echo 'Permanent\nTemporaly' | fzy)
|
||||||
if [ "$conf_instance_state" = 'Permanent' ]; then
|
if [ "$conf_instance_state" = 'Permanent' ]; then
|
||||||
jj -i config.json instance -v $instance -o config.json
|
jj -i config.json instance -v $instance -o config.json
|
||||||
|
@ -122,10 +138,14 @@ elif [ "$choice" = "$changepod" ]; then
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
clear
|
clear
|
||||||
get_all_avalaible_count_tracks
|
get_all_avalaible_count_tracks ;;
|
||||||
elif [ "$choice" = "$checkapilimits" ]; then
|
|
||||||
funkwhale_api_check_api_limits | more
|
|
||||||
elif [ "$choice" = "$Exit" ]; then
|
"$checkapilimits")
|
||||||
exit 0
|
funkwhale_api_check_api_limits | more ;;
|
||||||
fi
|
|
||||||
|
|
||||||
|
"$Exit")
|
||||||
|
exit 0 ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in a new issue