Skip to content

Instantly share code, notes, and snippets.

@wari
Last active December 14, 2015 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wari/5010992 to your computer and use it in GitHub Desktop.
Save wari/5010992 to your computer and use it in GitHub Desktop.
Easy to use video services downloader Rakefile
# Easy to use downloader Rakefile
# Add as many URLs you want in a file called download
# Requires youtube-dl - http://rg3.github.com/youtube-dl/
#
# echo URL >> download
# rake hq
#
# If you use a different source file, then run as follows:
#
# rake SOURCEFILE=some_other_file.txt
#
# Will use your credentials if you provide a proper cookies.txt file (Works
# with Firefox Export Cookies plugin -
# https://addons.mozilla.org/en-us/firefox/addon/export-cookies/ no luck with
# Chrome though)
#
# Downloads will go to downloads/uploader/*.mp4
# PS: I'm just lazy :P Modify as you see fit.
sourcefile = ENV['SOURCEFILE'] || 'download'
extraopts = ''
extraopts += '--cookies cookies.txt' if File::exists? 'cookies.txt'
targetfilenames = "-o 'downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s'"
task :default => :lq
desc "Blanking out everything"
task :clean do
sh "rm -rf downloads"
sh "echo -n > download"
end
desc "High quality downloads"
task :hq => :download
desc "Default: Normal good (enough) quality for mobile devices"
task :lq do
extraopts += ' -f 18 '
Rake::Task[:download].invoke
end
desc "Update youtube-dl"
task :update do
sh 'youtube-dl --update'
end
task :download do
sh "youtube-dl #{extraopts} #{targetfilenames} -a #{sourcefile}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment