Created
November 17, 2010 06:37
-
-
Save ssig33/703070 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "datamapper" | |
require "mechanize" | |
require "uri" | |
DataMapper.setup(:default, "sqlite:///テキトウなディレクトリとファイル名(DataMapper のドキュメント読め)") | |
class Torrent | |
include DataMapper::Resource | |
property :url, Text, :key => true | |
property :title, Text | |
end | |
#Torrent.auto_migrate! | |
def jibiki | |
ulrs = ["http://sukebei.nyaatorrents.org/?page=torrents&catid=7&subcat=26"] | |
ulrs.each{|u| | |
page = agent.get URI.parse u | |
page.root.xpath("//tr[@class='tlistrow']").to_ary.each do |a| | |
url = a.children[3].children.first.attributes.to_hash["href"].to_s | |
title = a.children[1].children.first.attributes.to_hash["title"].to_s | |
unless Torrent.get(url) | |
begin | |
system "transmissioncli '#{url}' -p ポート -w 'ダウンロードディレクトリ'" | |
puts "save #{title}:#{url}" | |
t = Torrent.new | |
t.url = url | |
t.title = title | |
t.save | |
rescue | |
end | |
end | |
end | |
} | |
end | |
def agent | |
Mechanize.new | |
end | |
while true | |
jibiki | |
sleep 300 | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment