rss.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 rfc822='%a, %d %b %Y %T %z'
  9. date_now_rfc822 () {
  10. LANG=C date +"${rfc822}"
  11. }
  12. date_file_rfc822 () {
  13. LANG=C date -r "${1}" +"${rfc822}"
  14. }
  15. readonly self="${baseurl}/podcasts/$(basename "$(pwd)")"
  16. cat <<EOF
  17. <rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:atom="http://www.w3.org/2005/Atom">
  18. <channel>
  19. <link>${self}</link>
  20. <!-- validate https://validator.w3.org/feed/check.cgi?url=${self}.rss -->
  21. <atom:link href="${self}.rss" rel="self" type="application/rss+xml" />
  22. <title>Q3 bei Galaxy Mixed</title>
  23. <itunes:subtitle>🧶</itunes:subtitle>
  24. <description>🔥 https://mro.name/radio-privatkopie</description>
  25. <itunes:summary>Strickt sich gut.</itunes:summary>
  26. <itunes:category text="Society &amp; Culture"/>
  27. <itunes:owner>
  28. <itunes:name>Your Name</itunes:name>
  29. <itunes:email>your-email@example.com</itunes:email>
  30. </itunes:owner>
  31. <itunes:explicit>no</itunes:explicit>
  32. <language>de</language>
  33. <lastBuildDate>$(date_now_rfc822)</lastBuildDate>
  34. <pubDate>$(date_now_rfc822)</pubDate>
  35. EOF
  36. for id in $(ls -t */????/??/??/???? | head -n 50)
  37. do
  38. encfi="$(ls "${enclosures}/${id}".??? 2>/dev/null)"
  39. [ "" = "${encfi}" ] && continue
  40. xsltproc \
  41. --stringparam baseurl "${baseurl}" \
  42. --stringparam enclosure "${baseurl}/foo/bar/${encfi}" \
  43. --stringparam filesize "$(wc -c < "${encfi}")" \
  44. --stringparam mimetype "$(file --brief --mime-type "${encfi}")" \
  45. --stringparam podcast "${self}" \
  46. --stringparam pubDate "$(date_file_rfc822 "${encfi}")" \
  47. ../app/broadcast2rss.xslt "${stations}/${id}.xml" \
  48. 2>/dev/null
  49. done
  50. cat <<EOF
  51. </channel>
  52. </rss>
  53. EOF