Skip to content

Instantly share code, notes, and snippets.

@dagbrown
Created December 8, 2008 05:55
Show Gist options
  • Save dagbrown/33369 to your computer and use it in GitHub Desktop.
Save dagbrown/33369 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
#
# tvrss - a BitTorrent torrent-RSS puller
#
# Make a directory called ~/.tvrss
# Make another called ~/.tvrss/torrents
# Put URLs of RSS feeds in ~/.tvrss/feeds
# Bob's your uncle!
require 'rubygems'
require 'simple-rss'
require 'open-uri'
urls = []
File.open(ENV["HOME"]+"/.tvrss/feeds").each_line do |line|
next if line =~ /^#/ or line =~ /^\s*$/
urls.unshift(line.chomp)
end
Dir.chdir(ENV["HOME"]+"/.tvrss/torrents")
urls.each do |url|
rss = SimpleRSS.parse open(url).read
rss.entries.each do |entry|
next if File.exists? entry.title+".torrent"
File.open(entry.title+".torrent","w") do |fh|
fh.write open(entry.link).read
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment