Last active
June 27, 2019 07:22
-
-
Save ckahle33/b50d43f2d7c00c5e6082edb0b1c92cb1 to your computer and use it in GitHub Desktop.
This file contains 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', '[email protected]', 'yourPass').call |
No luck with this ):
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
You'll need to update https://gist.github.com/ckahle33/b50d43f2d7c00c5e6082edb0b1c92cb1#file-das-rb-L18 from
[1]
to[2]
to work