Watchful11

Dropbox

Nov 9th, 2012
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. --name dropbox
  2. --version 1
  3.  
  4. function download(address)
  5.     site = http.get(address)
  6.     if site == nil then
  7.         print("No file")
  8.     else
  9.         code = site.readAll()
  10.         name = nil
  11.         start = string.find(code, "name")
  12.         if start ~= nil then
  13.             length = string.find(code, "\n", start)
  14.             name = string.sub(code, start+5, length-1)
  15.             print("Downloaded: "..name)
  16.         end
  17.         start = string.find(code, "version")
  18.         if start ~= nil then
  19.             length = string.find(code, "\n", start)
  20.             version = string.sub(code, start+8, length-1)
  21.             print("Version: "..version)
  22.         end
  23.         if name ~= nil then
  24.             file = fs.open(name,"w")
  25.             file.write(code)
  26.             file.close()
  27.         else
  28.             print("no name")
  29.         end
  30.     end
  31. end
  32.  
  33. function files()
  34.     file = fs.open("dropboxfiles","r")
  35.     hasline = true
  36.     files = {}
  37.     i = 1
  38.     while hasline do
  39.         line = file.readLine()
  40.         if line == nil then
  41.             hasline = false
  42.         else
  43.             files[i] = line
  44.         end
  45.         i = i + 1
  46.     end
  47.     return files
  48. end
  49.  
  50. urls = files()
  51. for i=1,#urls do
  52.     download(urls[i])
  53. end
Advertisement
Add Comment
Please, Sign In to add comment