Guest User

Untitled

a guest
Feb 25th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.11 KB | None | 0 0
  1. #!/usr/bin/env ruby
  2. require './req_gemcook.rb'
  3. #require 'logger'
  4.  
  5.  web = Watir::Browser.new :phantomjs
  6.  
  7.     DB = Sequel.connect('sqlite://clublandlv.sqlite')
  8.     DB.sql_log_level = :debug
  9.    # DB.loggers << Logger.new($stdout)
  10.  
  11.     # its = DB[:subgenres___a].join(:songs___b, [:subgenre]).select(:subgenre)
  12.     # songsd = DB[:songsdown].join(:songs, [:song_id]).select(:song_id)
  13.       zippy_link = DB[:songsdown].select_map(:zippy_url)
  14.       songsdown = DB[:songsdown]
  15.  
  16.         #I make the script go to these three pages before the script starts because it seems
  17.         #that zippyshare loads a few ad pages in the session before letting you access their page.
  18. =begin
  19.           web.goto "http://www58.zippyshare.com/v/72367277/file.html"
  20.           puts web.title
  21.           web.goto "http://www63.zippyshare.com/v/31341153/file.html"
  22.           puts web.title
  23.           web.goto "http://www66.zippyshare.com/v/91667079/file.html"
  24.           puts web.title
  25.           puts
  26. =end
  27.  
  28.           index = zippy_link
  29.             index.each do |zip|
  30.               webtitle = web.title
  31.               webtext = web.text
  32.  
  33.                web.goto(zip)
  34.                 if webtitle.include? "Zippyshare.com"
  35.                   puts "OK, were on Zippyshare @ #{webtitle}"
  36.                 else
  37.                   web.goto(zip)
  38.                     puts "WTF? #{webtitle}"
  39.                 end
  40.  
  41.                     if webtext.include? "File does not exist on this server" && "File has expired and does not exist anymore on this server"
  42.                       songsdown.where(:zippy_url => zip).update(:healthy => false)
  43.                       puts "This shit is broken"
  44.                     elsif web.link(:id => 'dlbutton').exists?
  45.                         songsdown.where(:zippy_url => zip).update(:healthy => true)
  46.                         dl_link = web.link(:id => 'dlbutton').href
  47.                             puts "Got this #{dl_link}"
  48.                             puts
  49.                     else
  50.                       puts "Couldnt grab the file link, health set to 0"
  51.                       puts
  52.                     end
  53.  
  54. sleep(1)
  55.             end
Advertisement
Add Comment
Please, Sign In to add comment