Skip to content

Instantly share code, notes, and snippets.

@naoto
Created October 7, 2009 13:40
Show Gist options
  • Save naoto/204026 to your computer and use it in GitHub Desktop.
Save naoto/204026 to your computer and use it in GitHub Desktop.
saymove downloader
require 'rubygems'
require 'hpricot'
require 'open-uri'
def getSearch(search_uri)
html = Hpricot(open(search_uri))
html.search("a").each { |a|
if a.inner_text != "" && a.attributes['href'] =~ /comeplay\.php/
name = a.inner_text
href = a.attributes['href']
uri = get_player(href)
if uri != ""
downlooad(name,uri)
end
end
}
end
def get_player(uri)
html = Hpricot(open(uri))
html.search("a").each{ |a|
if a.attributes['href'] =~ /flv$/
return a.attributes['href']
end
}
return ""
end
def downlooad(name,uri)
puts "#{name} - #{uri}"
open("#{name}",'w') do |output|
open(uri) do |data|
output.write(data.read)
end
puts("#{name} [OK]")
end
end
search_uri = ARGV[0]
getSearch("http://say-move.org/comesearch.php?q=#{search_uri}&sort=view&genre=&sitei=&mode=&p=1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment