Skip to content

Instantly share code, notes, and snippets.

@xpepper
Last active January 1, 2019 01:37
Show Gist options
  • Save xpepper/5872399 to your computer and use it in GitHub Desktop.
Save xpepper/5872399 to your computer and use it in GitHub Desktop.
This script will download all the published rubytapas. Each episode, with all the attachments, will be downloaded in a folder named after the episode number. For example, in the folder "64" will be downloaded: 064-yield-or-enumerate.html, 064-yield-or-enumerate.mp4, 064-yield-or-enumerate.rb You need to set your credentials (username and passwor…
# username = "my_username"
# pwd = "my_password"
# target_path = "my_target_path"
# saving auth cookie
system %Q{wget --save-cookies /tmp/cookie.txt --keep-session-cookies --post-data "username=#{username}&password=#{pwd}" -O - \
https://rubytapas.dpdcart.com/subscriber/login?__dpd_cart=d08391e6-5fe2-4400-8b27-2dc17b413027}
(25..600).each do |i|
%x[wget -q -S --spider --load-cookies /tmp/cookie.txt https://rubytapas.dpdcart.com/subscriber/download?file_id=#{i} > spider.log 2>&1]
head_log = File.read("spider.log")
if head_log =~ /Content-Disposition.*filename="(.+)\.(.+)"/
name, extension = $1, $2
puts "Processing #{name}.#{extension}..."
if name && extension && !name.empty? && !extension.empty?
if Dir.glob("#{target_path}/**/#{name}.#{extension}").size == 0
puts "Downloading #{name}.#{extension}..."
filename = "#{name}.#{extension}"
if filename =~ /.*(\d{3}).*/
target_folder = $1
target_fullpath = "#{target_path}/#{target_folder}"
Dir.mkdir(target_fullpath) unless File.exist?(target_fullpath)
puts "*** wget --load-cookies /tmp/cookie.txt --output-document='#{target_path}/#{target_folder}/#{name}.#{extension}' https://rubytapas.dpdcart.com/subscriber/download?file_id=#{i}"
system "wget --load-cookies /tmp/cookie.txt --output-document='#{target_path}/#{target_folder}/#{name}.#{extension}' https://rubytapas.dpdcart.com/subscriber/download?file_id=#{i}"
end
end
end
end
end
@DanielleSucher
Copy link

Heya. I was getting a bunch of "No such file or directory" errors from wget until I added a few lines creating the target folder for each episode if it doesn't already exist. After making that change, this works beautifully for me, thanks!

Pull requests don't exist in the gist UI, else I'd just send you one, but you can still update from my fork to grab my changes if you want.

@mfilej
Copy link

mfilej commented Jun 28, 2013

Thanks so much! I was running behind just because there wasn't a good way for me to quickly access the videos.

@kevinjonesevans-zz
Copy link

Tried this and it would not work. After about an hour and a half, I realized it was my password! It doesn't take into account passwords which contain special characters. After reviewing the options such as using -i for interactive or using a .netrc, I ended up going the lazy route and just changing my password :P.

Thanks

@xpepper
Copy link
Author

xpepper commented Jul 15, 2013

@DanielleSucher thanks for improving the script... I updated my version too.

@xpepper
Copy link
Author

xpepper commented Jul 15, 2013

@kevinjonesevans I'm sorry, this script is really quick & dirty, so I didn't consider password with special chars... But I guess you should simply URL-encode the password before using it in the WGET request, isn't it?

@ahirschberg
Copy link

To anyone who wants downloads past episode 114, I would advise against this script. In order to get the latest episodes, I tweaked the max for the id range from 600 to 56000, but the files on rubytapas.dpdcart.com aren't in sequential order, so the brute force id scan wastes a lot of time trying to locate files on the server.

@fanaugen
Copy link

fanaugen commented Feb 5, 2017

In case you’re looking to download the video files from the new RubyTapas 2.0, check out my downloader

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