Created
July 17, 2025 12:53
-
-
Save marco79cgn/a568889f330d4dec0e8b006d6a43ce29 to your computer and use it in GitHub Desktop.
Shell script which downloads the latest episode of the "Bits und so" Podcast, converts it to a Tonie format, uploads it to teddyCloud and assigns it to a Tonie figurine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# teddyCloud ip address | |
teddycloud_ip=192.168.178.127 | |
# query podcast feed | |
feed_content=$(curl -s "https://www.bitsundso.de/feed/") | |
# get latest episode | |
latest_feed_episode=$(echo "$feed_content" | sed -n -e '/<item>/,$p' | sed -n 's:.*<title>\(.*\)</title>.*:\1:p' | head -1 | sed 's/#/Folge /g') | |
echo "Latest episode: $latest_feed_episode" | |
# get cached episode name | |
current_episode=$(cat ~/temp/cached_bus.tmp) | |
# download only if new episode exists | |
if [[ -n $latest_feed_episode && "$latest_feed_episode" != "$current_episode" ]]; then | |
# get mp3 url | |
url=$(echo "$feed_content" | sed -n 's/.*url="\([^"]*\).*/\1/p' | head -1) | |
# clean title | |
output_filename_clean=$(echo $latest_feed_episode | sed 's/[^a-zA-Z0-9äöüÄÖÜß ()._-]/_/g') | |
# download episode as opus in stereo | |
echo "Downloading new episode:" | |
docker run -i --rm -v $(pwd):/data mwader/static-ffmpeg:7.1.1 -loglevel quiet -stats -i "$url" -ac 2 -c:a libopus -b:a 96k "/data/$output_filename_clean.opus" | |
# convert to taf (tonie audio format) and upload it to teddycloud | |
echo "Converting to taf and uploading to teddyCloud:" | |
docker run --rm -v $(pwd):/data ghcr.io/marco79cgn/audio2tonie transcode -s /data/"$output_filename_clean.opus" -u $teddycloud_ip | |
# assign content to tonie figurine | |
tonie_id=********500304e0 | |
curl -s "http://$teddycloud_ip/content/json/set/$tonie_id" --data-raw "source=lib://$output_filename_clean.taf" | |
# cache episode name | |
echo $latest_feed_episode > ~/temp/cached_bus.tmp | |
# cleanup | |
rm $output_filename_clean.taf && rm $output_filename_clean.opus | |
else | |
echo "Podcast episode has already been downloaded." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment