Skip to content

Instantly share code, notes, and snippets.

@lengshuiyulangcn
Created February 14, 2015 13:41
Show Gist options
  • Save lengshuiyulangcn/726afc098c98387c5ba8 to your computer and use it in GitHub Desktop.
Save lengshuiyulangcn/726afc098c98387c5ba8 to your computer and use it in GitHub Desktop.
a script for parsing adult video torrents
# usage:
# ruby parse_torrent.rb keyword page_numbers
require "mechanize"
agent=Mechanize.new
term=ARGV[0]
offset=0
offset=ARGV[1].to_i if ARGV[1]!=nil
torrent_links=[]
for i in 0..offset
page=agent.get("http://sukebei.nyaa.se/?page=search&cats=8_30&filter=0&term=#{term}&offset=#{offset}")
page.links.each do |link|
torrent_links << link.href if link.href.include? "download"
end
end
file_list=[]
torrent_links.each do |link|
file=agent.get(link)
if file.filename.include? ".mp4" and !file_list.include? file.filename
puts file.filename
file_list << file.filename
file.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment