#!/bin/bash

cat rss.xml
cd ..

for t in $(ls -1 *.torrent | grep -v latest)
do
  d=$( stat $t -c %y | egrep -o '^.{16}' )
  d=$( date -d "$d UTC" -R )
  echo "		<item>"
  echo "			<title>$t</title>"
  echo "			<pubDate>$d</pubDate>"
  echo "			<category>data</category>"
  echo "			<link>https://osm.cquest.org/torrents/$t</link>"
  echo "			<description>$t</description>"
  echo "			<comments>Source: OpenStreetMap contributors, under ODbL 1.0 licence</comments>"
  echo "			<enclosure url='https://osm.cquest.org/torrents/$t' type='application/x-bittorrent' />"
  echo "		</item>"
done
echo '	</channel>'
echo '</rss>'
