-
-
Save jaeyson/c7f49c1bfd3209469848d745d13a0ac2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # gem install mechanize | |
| require 'mechanize' | |
| class Download | |
| def initialize(site, email, pass) | |
| @options = {site: site, email: email, pass: pass} | |
| end | |
| def call | |
| agent = Mechanize.new | |
| page = agent.get("#{@options[:site]}/screencasts/users/sign_in") | |
| form = page.forms.first | |
| form['user[email]'] = @options[:email] | |
| form['user[password]'] = @options[:pass] | |
| form.submit | |
| agent.page.links[1].click | |
| arr = agent.page.search('.episode') | |
| if arr.any? | |
| puts ".episode attribute found!" | |
| arr.each_with_index do |l, i| | |
| agent.get(l.search('a').attribute('href')) | |
| title = agent.page.title.strip | |
| agent.get( agent.page.search('script').text.split("\"")[7]) | |
| agent.page.save("#{i} - #{title}.mp4") | |
| puts "Downloading #{i} - #{title}..." | |
| title = "" | |
| 2.times { agent.back } | |
| end | |
| else | |
| puts "No .episode attribute found!" | |
| end | |
| end | |
| end | |
| Download.new('https://www.destroyallsoftware.com', 'your@email.com', 'yourPass').call |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment