Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require './req_gemcook.rb'
- #require 'logger'
- web = Watir::Browser.new :phantomjs
- DB = Sequel.connect('sqlite://clublandlv.sqlite')
- DB.sql_log_level = :debug
- # DB.loggers << Logger.new($stdout)
- # its = DB[:subgenres___a].join(:songs___b, [:subgenre]).select(:subgenre)
- # songsd = DB[:songsdown].join(:songs, [:song_id]).select(:song_id)
- zippy_link = DB[:songsdown].select_map(:zippy_url)
- songsdown = DB[:songsdown]
- #I make the script go to these three pages before the script starts because it seems
- #that zippyshare loads a few ad pages in the session before letting you access their page.
- =begin
- web.goto "http://www58.zippyshare.com/v/72367277/file.html"
- puts web.title
- web.goto "http://www63.zippyshare.com/v/31341153/file.html"
- puts web.title
- web.goto "http://www66.zippyshare.com/v/91667079/file.html"
- puts web.title
- puts
- =end
- index = zippy_link
- index.each do |zip|
- webtitle = web.title
- webtext = web.text
- web.goto(zip)
- if webtitle.include? "Zippyshare.com"
- puts "OK, were on Zippyshare @ #{webtitle}"
- else
- web.goto(zip)
- puts "WTF? #{webtitle}"
- end
- if webtext.include? "File does not exist on this server" && "File has expired and does not exist anymore on this server"
- songsdown.where(:zippy_url => zip).update(:healthy => false)
- puts "This shit is broken"
- elsif web.link(:id => 'dlbutton').exists?
- songsdown.where(:zippy_url => zip).update(:healthy => true)
- dl_link = web.link(:id => 'dlbutton').href
- puts "Got this #{dl_link}"
- puts
- else
- puts "Couldnt grab the file link, health set to 0"
- puts
- end
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment