Skip to content

Instantly share code, notes, and snippets.

@tansengming
Created August 13, 2012 09:28
Show Gist options
  • Select an option

  • Save tansengming/3338651 to your computer and use it in GitHub Desktop.

Select an option

Save tansengming/3338651 to your computer and use it in GitHub Desktop.
download.rake
namespace :download do
DownloadPath = Pathname.new('Downloads')
ListFile = DownloadPath + 'list'
task :all do
ListFiles = Pathname.glob('Downloads/**/list')
next if ListFiles.empty?
ListFiles.each do |listfile|
list = listfile.read.split.compact.reject(&:empty?)
while list.any?
url = list.shift
cd listfile.dirname do
if url[/(vimeo|youtube)\.com/]
sh "youtube-dl -lic --format 38/37/22/35/34/18/6/5/17/13 '#{url}'"
else
Cocaine::CommandLine.new("wget", "-c -U 'QuickTime/7.6.2' '#{url}'").run
end
end
File.open(listfile, 'w') {|f| f.write list.join("\n")}
end
listfile.delete
end
end
task :fix_filenames do
cd DownloadPath do
Pathname.glob('makeplaylist.*').reject{|p| p.to_s[/mp4$/]}.each do |f|
f.rename(f.to_s + '.mp4')
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment