Advertisement
Guest User

a

a guest
Feb 5th, 2013
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.16 KB | None | 0 0
  1. --[[ Variables ]]--
  2. local sourceFolder = "ccYouTube"
  3. os.loadAPI("ccYouTube/apis/loadingScreen")
  4. count = 4
  5. --local downloadsFolder = sourceFolder .. "/" .. "downloads"
  6. --local apisFolder = sourceFolder .. "/" .. "apis"
  7.  
  8. -- Tables
  9. local t_Programs = {}
  10. local t_Folders = {
  11.     { sFolderName = "downloads", sPath = sourceFolder .. "/" .. "downloads" },
  12.     { sFolderName = "apis", sPath = sourceFolder .. "/" .. "apis" },
  13. }
  14. local t_NeededFiles = {
  15.     apis = {
  16.         { sFileName = "loadingScreen", sUrl = "zeG34tu6", sPath = "apis/loadingScreen"}
  17.     }
  18. }
  19. local t_startLogo = {
  20. "                 f  f       eeeee   e      ",
  21. "                 f  f         e     e      ",
  22. " 9999  9999      ffff fff f f e e e eee eee",
  23. "9     9             f f f f f e e e e e e e",
  24. "9     9     ffff    f f f f f e e e e e eee",
  25. "9     9             f f f f f e e e e e e  ",
  26. " 9999  9999      ffff fff fff e eee eee eee",
  27. }
  28. --[[ End of Variables ]]--
  29.  
  30. term.clear() term.setCursorPos(1, 1)
  31.  
  32. term.setTextColour(colours.red)
  33. if not term.isColor() then
  34.     print("Error; Advanced Computer Required.")
  35.     term.setTextColour(colours.black)
  36.     return
  37. elseif not http then
  38.     print("Error; HTTP needs to be enabled.")
  39.     term.setTextColour(colours.black)
  40.     return
  41. end
  42. term.setTextColour(colours.black)
  43.  
  44. function getCount()
  45.     local count = 0
  46.     if not fs.isDir(sourceFolder) then
  47.         count = count + 1
  48.     end
  49.     for i = 1, #t_Folders do
  50.         if not fs.exists(t_Folders[i].sPath) then
  51.             count = count + 1
  52.         end
  53.     end
  54.     for i = 1, #t_NeededFiles do
  55.         if not fs.exists(t_NeededFiles[i].sPath) then
  56.             count = count + 1
  57.             if t_NeededFiles[i].sType == "api" then count = count + 1 end
  58.         end
  59.     end
  60.     return count
  61. end
  62.  
  63. function updateProgramList()
  64.     t_Programs = {}
  65.     local response = http.get("http://cc-youtube.webs.com/apps/links/")
  66.     local sourceText = response.readAll()
  67.     response.close()
  68.  
  69.     index = 1
  70.     for code in sourceText:gmatch('><a href="http://pastebin.com/(.-)" target="_blank">') do
  71.         t_Programs[index] = {}
  72.         t_Programs[index].code = code
  73.         index = index + 1
  74.     end
  75.  
  76.     index = 1
  77.     for k = 1, #t_Programs do
  78.         for title in sourceText:gmatch('<a href="http://pastebin.com/' .. t_Programs[k].code .. '" target="_blank">(.-)</a>') do
  79.             t_Programs[index].name = title
  80.         end
  81.         index = index + 1
  82.     end
  83.  
  84.     index = 1
  85.     for desc in sourceText:gmatch('<p class="linkDescription">(.-)</p>') do
  86.         t_Programs[index].desc = desc
  87.         index = index + 1
  88.     end
  89.  
  90.     index = 1
  91.     for pDate in sourceText:gmatch([[<div class="linkTimestamp">
  92.                               Posted (.-)
  93.                             </div>]]) do
  94.         t_Programs[index].postDate = pDate
  95.         index = index + 1
  96.     end
  97. end
  98.  
  99. local function initiate()
  100.     -- Checking the required files and folders
  101.         bar:setMessage("")
  102.         bar:triggerUpdate( "Checking source folder... (" .. ( bar:getCurrentProgress() + 1 ) .. "/" .. count .. ")..." )
  103.         sleep(0.5)
  104.         if not fs.isDir(sourceFolder) then
  105.             error("Source folder does not exist! Please re-install using the installer.")
  106.         end
  107.         bar:triggerUpdate( "Checking folders... (" .. ( bar:getCurrentProgress() + 1 ) .. "/" .. count .. ")..." )
  108.         sleep(0.5)
  109.         for i = 1, #t_Folders do
  110.             if not fs.exists(t_Folders[i].sPath) then
  111.                 error(t_Folders[i].sPath .. " does not exist! Please re-install using the installer.")
  112.             end
  113.         end
  114.         bar:triggerUpdate( "Checking files... (" .. ( bar:getCurrentProgress() + 1 ) .. "/" .. count .. ")..." )
  115.         sleep(0.5)
  116.         for i = 1, #t_NeededFiles do
  117.             for k = 1, #t_NeededFiles[i] do
  118.                 if not fs.exists(t_NeededFiles[i][k].sPath) then
  119.                     error(t_NeededFiles[i][k].sPath .. " does not exist! Please re-install using the installer.")
  120.                 end
  121.             end
  122.         end
  123.        
  124.     -- Loading APIS
  125.     for i = 1, #t_NeededFiles.apis do
  126.         os.loadAPI(t_NeededFiles.apis[i].sPath)
  127.         bar:triggerUpdate( "Loading API: " .. fs.getName(t_NeededFiles.apis[i].sPath) .. " (" .. ( bar:getCurrentProgress() + 1 ) .. "/" .. count .. ")..." )
  128.     end
  129. end
  130.  
  131. --[[ Main part of the program ]]--
  132. --local count = getCount()
  133.  
  134. bar = loadingScreen.init( loadingScreen.STANDARD, t_startLogo, (3 + #t_NeededFiles.apis), 30, 14, colors.red, "Starting up...", "", "By remiX" )
  135.  
  136. local function dobar()
  137.     bar:run( true )
  138. end
  139.  
  140. parallel.waitForAll( dobar, initiate )
  141.  
  142. updateProgramList()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement