Skip to content

Instantly share code, notes, and snippets.

@ckahle33
Last active June 27, 2019 07:22
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ckahle33/b50d43f2d7c00c5e6082edb0b1c92cb1 to your computer and use it in GitHub Desktop.
Save ckahle33/b50d43f2d7c00c5e6082edb0b1c92cb1 to your computer and use it in GitHub Desktop.
# 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
@alotofnoodles
Copy link

@lmiller1990
Copy link

No luck with this ):

@ckahle33
Copy link
Author

Hey. Just realized there were people using this! I just tested it out.. still seems to work for me. Just updated to return some more useful errors if no episode attrs are found. Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment