Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- require './req_gemcook.rb'
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'ext')))
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
- web = Watir::Browser.new :phantomjs
- DB = Sequel.connect('sqlite://clublandlv.sqlite')
- zippy_mp3 = DB[:songsdown].select_map(:zippy_mp3)
- zippy_link = DB[:songsdown].select_map(:zippy_url)
- songsdown = DB[:songsdown]
- index = zippy_link
- index.each do |zip|
- web.goto(zip)
- webtitle = web.title
- webtext = web.text
- if web.link(:id => 'dlbutton').exists?
- songsdown.where(:zippy_url => zip).update(:healthy => 1)
- dl_link = web.link(:id => 'dlbutton').href
- zip_link = songsdown.where(:zippy_url => zip).get(:zippy_url)
- songsdown.where(:zippy_url => zip).update(:zippy_mp3 => dl_link)
- puts "You are viewing: #{webtitle}"
- puts "Got this download link: #{dl_link}"
- easy = Curl::Easy.new autoreferer = true
- easy.headers['User-Agent'] = "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:27.0) Gecko/20100101 Firefox/27.0"
- easy.headers['Referer'] = "#{zip_link}"
- easy.url = dl_link
- filename = songsdown.where(:zippy_url => zip).get(:song_title)
- print "'#{filename}' :"
- File.open(filename, 'w') do|f|
- easy.on_progress {|dl_total, dl_now, ul_total, ul_now| print "="; true }
- easy.on_body {|data| f << data; data.size }
- easy.perform
- puts "=> '#{filename}'"
- puts
- end
- elsif 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 => 0)
- puts "File is expired or mising"
- else
- songsdown.where(:zippy_url => zip).update(:healthy => 2)
- puts "∆∆∆∆∆∆∆∆∆∆This is an ad. Really wish phantomjs supported custom headers∆∆∆∆∆∆∆∆∆∆"
- puts
- end
- sleep(2)
- end
- songsdown.where(:zippy_url => nil).update(:healthy => 2, :zippy_mp3 => nil)
Advertisement
Add Comment
Please, Sign In to add comment