Added podcasts section

This commit is contained in:
localhost_frssoft 2022-03-31 19:23:14 +03:00
parent aad56b6fe8
commit 60edd9f52e
2 changed files with 39 additions and 5 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
playlist.m3u8 playlist.m3u8
podcast.m3u8
preload preload

View File

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
instance=$(jj -i config.json instance) instance=$(jj -i config.json instance)
default_player=mpv
ordering='title' ordering='title'
default_player_command='mpv --no-vid --no-ytdl'
funkwhale_api_check_api_limits() funkwhale_api_check_api_limits()
{ {
@ -15,9 +15,37 @@ funkwhale_api_get_tracks()
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_tracks_from_channel()
{ {
curl -s https://$instance/api/v1/albums/ | jj -p results track_list=$(curl -s "https://$instance/api/v1/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')
echo > podcast.m3u8
for i in $listen_urls; do
echo "https://$instance$i\n" >> podcast.m3u8
done
$default_player_command podcast.m3u8
}
funkwhale_get_podcasts_artists()
{
echo 'Loading podcast artists...'
curl -s --output preload "https://$instance/api/v1/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"
artist_channels=$(jj -i preload -l 'results.#.channel.uuid' | sed 's/"//g')
artist_names=$(mktemp)
temp_artists=$(mktemp)
for i in $artist_channels; do
jj -i preload results."$counter".name | sed 's/\./_/g' >> $artist_names
jj -i $temp_artists -v "$i" -o $temp_artists "$(jj -i preload results.$counter.name | sed 's/\./_/g')"
counter=$(expr $counter + 1)
done
menu_artist_choice=$(cat $artist_names | fzy)
channel_uuid=$(jj -i $temp_artists "$menu_artist_choice")
funkwhale_api_get_tracks_from_channel $channel_uuid
} }
load_tracks_to_playlist() load_tracks_to_playlist()
@ -50,12 +78,13 @@ get_all_avalaible_count_tracks
downloadtrackspls='Download tracks in playlist' downloadtrackspls='Download tracks in playlist'
startplayer='Start player' startplayer='Start player'
podcasts='Podcasts'
changepod='Switch instance' changepod='Switch instance'
checkapilimits='Check API limits (debug)' checkapilimits='Check API limits (debug)'
Exit='Exit' Exit='Exit'
while true; do while true; do
choice=$(echo "$downloadtrackspls\n$startplayer\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 if [ "$choice" = "$downloadtrackspls" ]; then
echo 'Order by (prefix - is DESC ordering):' echo 'Order by (prefix - is DESC ordering):'
@ -65,7 +94,11 @@ if [ "$choice" = "$downloadtrackspls" ]; then
read page read page
load_tracks_to_playlist $page load_tracks_to_playlist $page
elif [ "$choice" = "$startplayer" ]; then elif [ "$choice" = "$startplayer" ]; then
$default_player --no-vid --no-ytdl playlist.m3u8 $default_player_command playlist.m3u8
elif [ "$choice" = "$podcasts" ]; then
echo 'Enter page number: '
read page
funkwhale_get_podcasts_artists $page
elif [ "$choice" = "$changepod" ]; then elif [ "$choice" = "$changepod" ]; then
echo "Type instance (ex. $instance):" echo "Type instance (ex. $instance):"
read instance read instance