๐Ÿ“ฆโž”๐Ÿฆ‹ Store and retrieve files on the Atmosphere
35
fork

Configure Feed

Select the types of activity you want to include in your feed.

atfile-radio (examples): add atfile-radio example

Ducky cf685910 49d85a25

+57
+57
examples/atfile-radio.sh
··· 1 + #!/usr/bin/env bash 2 + 3 + source "../atfile.sh" 4 + 5 + library=() 6 + library_item_separator="|" 7 + 8 + function get_library_item_fragment() { 9 + track="$1" 10 + index="$2" 11 + 12 + echo "$(echo $track | cut -d "${library_item_separator}" -f $index)" 13 + } 14 + 15 + while : ; do 16 + uploads="$(atfile.invoke.list $uploads_cursor)" # BUG: jq error when empty 17 + [[ $uploads == *"\"error\":"* ]] && break 18 + uploads_cursor="$(echo $uploads | jq -r '.cursor')" 19 + uploads_list="$(echo $uploads | jq -c '.uploads[]')" 20 + 21 + while IFS=$"\n" read -r c; do 22 + key="$(atfile.util.get_rkey_from_at_uri "$(echo $c | jq -r '.uri')")" 23 + meta_type="$(echo "$c" | jq -r ".value.meta.\"\$type\"")" 24 + mime="$(echo $c | jq -r '.value.file.mimeType')" 25 + name="$(echo "$c" | jq -r ".value.file.name")" 26 + 27 + unset artist 28 + unset title 29 + 30 + if [[ $meta_type == "blue.zio.atfile.meta#audio" ]]; then 31 + artist="$(echo "$c" | jq -r ".value.meta.tags.artist")" 32 + title="$(echo "$c" | jq -r ".value.meta.tags.title")" 33 + fi 34 + 35 + if [[ $mime == audio/* ]]; then 36 + library+=("${key}${library_item_separator}${artist}${library_item_separator}$title") 37 + fi 38 + done <<< "$uploads_list" 39 + done 40 + 41 + library=($(printf "%s\n" "${library[@]}" | shuf)) 42 + 43 + trap exit SIGINT 44 + 45 + for track in "${library[@]}"; do 46 + key="$(get_library_item_fragment "$track" 1)" 47 + artist="$(get_library_item_fragment "$track" 2)" 48 + title="$(get_library_item_fragment "$track" 3)" 49 + 50 + [[ -z "$artist" ]] && artist="(Unknown Artist)" 51 + [[ -z "$title" ]] && title="(Unknown Track)" 52 + 53 + echo "๐ŸŽต [$key] $artist - $title" 54 + atfile.invoke.print $key | ffplay - -autoexit -hide_banner -loglevel error -nodisp 55 + done 56 + 57 + #echo $library