atom.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. # https://mro.name/radio-privatkopie
  3. #
  4. readonly baseurl="http://rec.mro.name"
  5. cd "$(dirname "${0}")/.." || exit 1
  6. readonly stations="../../stations"
  7. readonly enclosures="../../enclosures"
  8. readonly rfc3339='%FT%T%z'
  9. date_now_rfc3339 () {
  10. date +"${rfc3339}" | sed -e 's/\(..\)$/:\1/'
  11. }
  12. date_file_rfc3339 () {
  13. date -r "${1}" +"${rfc3339}" | sed -e 's/\(..\)$/:\1/'
  14. }
  15. readonly self="${baseurl}/podcasts/$(basename "$(pwd)")"
  16. cat <<EOF
  17. <feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
  18. <title>🍊 Oranges</title>
  19. <link href="${self}.atom" rel="self" type="application/atom+xml" />
  20. <id>${self}</id>
  21. <updated>$(date_now_rfc3339)</updated>
  22. <generator uri="https://mro.name/radio-privatkopie" version="2.0">Internet Radio Recorder</generator>
  23. <author>
  24. <name>https://mro.name/radio-privatkopie</name>
  25. </author>
  26. EOF
  27. for id in $(ls --reverse */????/??/??/???? | head -n 50)
  28. do
  29. [ -r "${enclosures}/${id}.mp3" ] || continue
  30. xsltproc \
  31. --stringparam baseurl "${baseurl}" \
  32. --stringparam filesize "$(wc -c < "${enclosures}/${id}.mp3")" \
  33. --stringparam podcast "${self}" \
  34. --stringparam updated "$(date_file_rfc3339 "${enclosures}/${id}.mp3")" \
  35. ../app/broadcast2atom.xslt "${stations}/${id}.xml" \
  36. 2>/dev/null
  37. done
  38. cat <<EOF
  39. </feed>
  40. EOF