From 60eb998226809b43bec8e47ab729c5fa6898c90d Mon Sep 17 00:00:00 2001 From: Simon Doppler Date: Mon, 7 Aug 2017 16:33:12 +0200 Subject: Create feed from magnet links --- README.md | 2 +- al32-mktorrent.sh | 7 ++++++- magnet2feed.py | 30 ++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 magnet2feed.py diff --git a/README.md b/README.md index 38b80df..427daca 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ If no date is specified, the script will prompt for a date during the process. * [ ] Upload the torrent file to a server via SSH (for sharing) * [ ] Upload the torrent to transmission-server * [ ] Inform the world of the new torrent file - * [ ] Add the magnet link to a RSS feed + * [x] Add the magnet link to a RSS feed * [ ] Upload the new RSS feed to the server * [ ] Send an email to the arch-ports list diff --git a/al32-mktorrent.sh b/al32-mktorrent.sh index 1103364..3fdb196 100644 --- a/al32-mktorrent.sh +++ b/al32-mktorrent.sh @@ -103,5 +103,10 @@ fi mktorrent --announce=http://dopsi.ch:6969/announce --web-seed="$(join_by ',' "${available_mirrors[@]}")" "$iso_string" echo -e "$fg_reset${fg_bold}Create magnet link...$fg_reset" -transmission-show --magnet "$iso_string.torrent" +magnet_link="$(transmission-show --magnet "$iso_string.torrent")" +echo "$magnet_link" + +echo -e "$fg_reset${fg_bold}Create RSS feed files...$fg_reset" +python magnet2feed.py "$magnet_link" "$iso_date" + # vim: set ts=4 sw=4: diff --git a/magnet2feed.py b/magnet2feed.py new file mode 100644 index 0000000..5dc767f --- /dev/null +++ b/magnet2feed.py @@ -0,0 +1,30 @@ +from feedgenerator import Rss201rev2Feed +import sys +from os.path import basename + +feed_url = 'https://static.dopsi.ch/al32/feed_{arch}.rss' +architectures = ['i686', 'dual'] + + +def main(link, date): + for arch in architectures: + feed = Rss201rev2Feed(title='ArchLinux32 torrent download feed ({arch} ISO)'.format(arch=arch), + link=feed_url, + description="A torrent feed to download the latest ArchLinux32 {arch} iso".format( + arch=arch + ), + language='en') + + feed.add_item(title='ArchLinux32 {arch} {date}'.format(arch=arch, date=date), + link=link, + description='ArchLinux32 {arch} {date}'.format(arch=arch, date=date)) + + with open(basename(feed_url).format(arch=arch), mode='w') as feed_file: + feed.write(feed_file, 'utf-8') + + +if __name__ == '__main__': + if len(sys.argv) != 3: + print('Error: {cmd} magnet date'.format(cmd=sys.argv[0])) + + main(link=sys.argv[1], date=sys.argv[2]) -- cgit v1.2.3-70-g09d2