Imgoodisher

Make Downloader

Jun 11th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.59 KB | None | 0 0
  1. local args = {...}
  2.  
  3. -- Usage: make url name
  4. if not args[2] then
  5.     print("Usage: "..shell.getRunningProgram().." <url> <path>")
  6.     return
  7. end
  8.  
  9. local url = "http://imgood.us.to/cc/"..args[1]
  10. local path = args[2]
  11.  
  12. local savepath
  13. if path:find("/") then
  14.     local dir, name = path:match("^(.-/)([^/]+)$")
  15.     savepath = dir .. "_" .. name
  16. else
  17.     savepath = "_" .. path
  18. end
  19.  
  20. local f = io.open(path, "w")
  21. f:write([[
  22. local f1 = http.get("]]..url..[[")
  23. local f2 = io.open("]]..savepath..[[", "w")
  24. f2:write(f1.readAll())
  25. f2:close()
  26. print("Starting...")
  27. shell.run("]]..savepath..[[")]])
  28. f:close()
Add Comment
Please, Sign In to add comment