Advertisement
Etsukazu_Aoi

ytcpop

Jun 7th, 2015
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 36.23 KB | None | 0 0
  1. local sides = { "top", "bottom", "left", "right", "front", "back" }
  2. for i = 1, #sides do
  3.   if peripheral.isPresent(sides[i]) then
  4.         if peripheral.getType(sides[i]) == "openperipheral_bridge" then
  5.             glass = peripheral.wrap(sides[i])
  6.         elseif peripheral.getType(sides[i]) == "WebScreen" then
  7.             ecran  = peripheral.wrap(sides[i])
  8.         end
  9.   end
  10. end
  11. setcolor = ""
  12. timetotal = ""
  13. webData = ""
  14. Ordre = ""
  15. titre = ""
  16. premierordre = false
  17. decalage = 0
  18. etaterreur = false
  19.  
  20. if fs.exists("config-s8UqqBJy") == false then
  21.         local random = math.random(0,100000)
  22.         os.setComputerLabel("WebDisplayYt"..random)
  23.         temporaire = fs.open("config-s8UqqBJy","w")
  24.         temporaire.writeLine("WebDisplayYt"..random)
  25.         temporaire.close()
  26.         temporaire = fs.open("startup","w")
  27.         temporaire.write('while true do shell.run("pastebin run s8UqqBJy") end')
  28.         temporaire.close()
  29.         temporaire = fs.open("log-s8UqqBJy","w")
  30.         temporaire.writeLine("reboot auto")
  31.         temporaire.close()
  32.         os.reboot()
  33. end
  34. --     Function de base     ------
  35. function setbackground()
  36.         local mainBox = glass.addBox(20, 20, 1, 48, 0xa0a0a0, 0.7)
  37.         local outlineT = glass.addBox(18,18,2,2,setcolor,0.7)
  38.         local outlineB = glass.addBox(18,68,2,2,setcolor,0.7)
  39.         mainBox.setWidth(136)
  40.         outlineT.setWidth(140)
  41.         outlineB.setWidth(140)
  42.         mainBox.setHeight(48)
  43. end
  44.  
  45. function geturl(url, noCancel)
  46.         http.request(url)
  47.         while true do
  48.                 local e, rUrl, rmsg = os.pullEvent()
  49.                 if (e == "http_success") and (rUrl == url) then
  50.                         if rmsg then
  51.                                 local data = rmsg.readAll()
  52.                                 rmsg.close()
  53.                                 if data then
  54.                                         return "success", data
  55.                                 else
  56.                                         sleep(1)
  57.                                         http.request(url)
  58.                                 end
  59.                         else
  60.                                 sleep(1)
  61.                                 http.request(url)
  62.                         end
  63.                 elseif (e == "http_failure") and (rUrl == url) then
  64.                         return "failure"
  65.                 elseif (e == "chat_command") and ((trimText(rUrl:lower()) == "cancel") or (trimText(rUrl:lower()) == "home")) and not(noCancel) then
  66.                         return "cancel"
  67.                 end
  68.         end
  69. end
  70.  
  71. function centerText(text, object, scalelen)
  72.         object.setScale(1)
  73.         object.setX(math.ceil(((136-22)/2)-(string.len(text)*scalelen)))
  74.         object.setText(text)
  75.         object.setScale(scalelen)
  76. end
  77. ------     Init     ------
  78.  
  79. while ecran.isLinked() == false do
  80.         glass.clear()
  81.         setcolor = 0xff0000
  82.         setbackground()
  83.         local header = glass.addText(75,25,"Ecran No", setcolor)
  84.         header.setScale(2)
  85.         centerText("Ecran No", header, 2)
  86.         local header2 = glass.addText(53,48,"Linked", setcolor)
  87.         header2.setScale(2)
  88.         centerText("Linked", header2, 2)
  89.         glass.sync()
  90. end
  91.  
  92. glass.clear()
  93. setcolor = 0xffff4d
  94. setbackground()
  95. local header = glass.addText(75,25,"En Attente", setcolor)
  96. header.setScale(2)
  97. centerText("En Attente", header, 2)
  98. local header2 = glass.addText(53,48,"$$link youtube", setcolor)
  99. header2.setScale(1)
  100. centerText("$$link youtube", header2, 1)
  101. ecran.setUrl("http://youtube.com/embed/")
  102. glass.sync()
  103. config = {}
  104. getconfig = fs.open("config-s8UqqBJy","r")
  105. config["label"] = getconfig.readLine()
  106. config["getAuto"] = getconfig.readLine()
  107. if config["getAuto"] == "Repeat activer" then
  108.         config["playlist"] = getconfig.readLine()
  109.         config["idvideo"] = getconfig.readLine()
  110.         if config["playlist"] == "true" then
  111.                 playlists = {}
  112.                 playlistactuel = 1
  113.                 idPlaylist = ""
  114.                 idPlaylist = Ordre:match([[https://www.youtube.com/playlist%?list=([^>]+)]])
  115.                 resp, webData = geturl("https://www.youtube.com/playlist?list="..idPlaylist, true)
  116.                 for w in string.gmatch(webData, '<a class=%"pl%-video%-title%-link yt%-uix%-tile%-link yt%-uix%-sessionlink  spf%-link %" dir=%"ltr%" href=%"%/watch%?v=([^>]+)%&amp;list=') do
  117.                         playlists[playlistactuel] = w
  118.                         playlistactuel = playlistactuel+1
  119.                 end
  120.                 for v,idvideo in pairs(playlists) do
  121.                         playlistmax = v
  122.                 end
  123.                 playlistactuel = 1
  124.                 idvideo = playlists[1]
  125.         else
  126.                 idvideo = config["idvideo"]
  127.         end
  128.         ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  129.         resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  130.         titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  131.         print("test1")
  132.         idvideoo = idvideo
  133.         if string.find(idvideoo,"-") == 1 then
  134.         print("test2")
  135.         idvideoo = string.sub(idvideoo,2)
  136.         print("test3")
  137.         resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  138.         print("test4")
  139.         else
  140.         resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  141.         print("test5")
  142.         end
  143.         timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  144.         print("test6")
  145.         timerRestart = true
  146.         premierordre = true
  147.         decalage = 0
  148.         sleep(1)
  149.         ecran.click(0.5555,0.5555)
  150.         setcolor = 0x00ff00
  151.         etat = "Repeat On"
  152. else
  153.         etat = "En Attente"
  154.         setcolor = 0xffff4d
  155. end
  156. getconfig.close()
  157.  
  158. --     Gestion D'ordre      -------
  159. function getordre()
  160.         while true do
  161.                 getordree()
  162.         end
  163. end
  164.  
  165. function getordree()
  166.         while true do
  167.                 event,face,pseudo,uuid,Ordre = os.pullEvent("glasses_chat_command")
  168.                 if Ordre == "reboot" or Ordre == "restart" then
  169.                         log(pseudo.." > a demander un redemarage")
  170.                         os.reboot()
  171.                 elseif Ordre == "shutdown" then
  172.                         ecran.setUrl("about:blank")
  173.                         glass.clear()
  174.                         glass.sync()
  175.                         log(pseudo.." > a demander un arret")
  176.                         os.shutdown()
  177.                 elseif Ordre == "start" or Ordre == "pause" then
  178.                         ecran.click(0.5555,0.5555)
  179.                         if idvideo == nil then
  180.                                 return getordre
  181.                         end
  182.                         if etat == "En Cour" then
  183.                         etat = "En Pause"
  184.                         setcolor = 0xff5500
  185.                         log(pseudo.." > a mis en pause la lecture")
  186.                         else
  187.                         etat = "En Cour"
  188.                         setcolor = 0x00ff00
  189.                         log(pseudo.." > a demarrer la lecture")
  190.                         end
  191.                 elseif Ordre.find(Ordre,"youtube") ~= nil then
  192.                         setcolor = 0xffff4d
  193.                         if string.find(Ordre,"watch") ~= nil then
  194.                                 if string.find(Ordre,"list") ~= nil then
  195.                                         playlist = true
  196.                                         playlists = {}
  197.                                         v = 1
  198.                                         idvideo = Ordre:match('https://www.youtube.com/watch%?v=([^>]+)%&')
  199.                                         if string.find(Ordre,"index") then
  200.                                                 idvideo = Ordre:match('https://www.youtube.com/watch%?v=([^>]+)%&index')
  201.                                                 playlistactuel = tonumber(Ordre:match('https://www.youtube.com/watch%?v='..idvideo..'%&index=([^>]+)&'))
  202.                                                  print(playlistactuel)
  203.                                                  print(idvideo)
  204.                                                 idPlaylist = Ordre:match('https://www.youtube.com/watch%?v='..idvideo..'%&index='..playlistactuel..'%&list=([^>]+)')
  205.                                         else
  206.                                                 playlistactuel = 1
  207.                                                 idvideo = Ordre:match('https://www.youtube.com/watch%?v=([^>]+)%&')
  208.                                                 idPlaylist = Ordre:match('https://www.youtube.com/watch%?v='..idvideo..'%&list=([^>]+)')
  209.                                         end
  210.                                         resp, webData = geturl("https://www.youtube.com/playlist?list="..playlistactuel, true)
  211.                                         titreplaylist = webData:match([[<title>([^>]+) %- YouTube</title>]])
  212.                                         for w in string.gmatch(webData, '<a class=%"pl%-video%-title%-link yt%-uix%-tile%-link yt%-uix%-sessionlink  spf%-link %" dir=%"ltr%" href=%"%/watch%?v=([^>]+)%&amp;list=') do
  213.                                                 playlists[v] = w
  214.                                                 v = v+1
  215.                                         end
  216.                                         for v,idvideo in pairs(playlists) do
  217.                                                 playlistmax = v
  218.                                         end
  219.                                         idvideo = playlists[playlistactuel]
  220.                                 else
  221.                                         idvideo = Ordre:match([[https://www.youtube.com/watch%?v=([^>]+)]])
  222.                                         playlist = false
  223.                                 end
  224.                         elseif string.find(Ordre,"embed") ~= nil then
  225.                                 idvideo = Ordre:match([[https://www.youtube.com/embed/([^>]+)]])
  226.                                 playlist = false
  227.                         elseif string.find(Ordre,"playlist") ~= nil then
  228.                                 playlist = true
  229.                                 playlists = {}
  230.                                 playlistactuel = 1
  231.                                 idPlaylist = Ordre:match([[https://www.youtube.com/playlist%?list=([^>]+)]])
  232.                                 resp, webData = geturl("https://www.youtube.com/playlist?list="..idPlaylist, true)
  233.                                 titreplaylist = webData:match([[<title>([^>]+) %- YouTube</title>]])
  234.                                 for w in string.gmatch(webData, '<a class=%"pl%-video%-title%-link yt%-uix%-tile%-link yt%-uix%-sessionlink  spf%-link %" dir=%"ltr%" href=%"%/watch%?v=([^>]+)%&amp;list=') do
  235.                                         playlists[playlistactuel] = w
  236.                                         playlistactuel = playlistactuel+1
  237.                                 end
  238.                                 for v,idvideo in pairs(playlists) do
  239.                                         playlistmax = v
  240.                                 end
  241.                                 playlistactuel = 1
  242.                                 idvideo = playlists[1]
  243.                         else
  244.                                 erreur("URL Invalide",pseudo,Ordre)
  245.                                 return
  246.                         end
  247.                         ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  248.                         resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  249.                         titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  250.                         if string.find(idvideo,"-") == 1 then
  251.                                 idvideoo = string.sub(idvideo,2)
  252.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  253.                         else
  254.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  255.                         end
  256.                         timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  257.                         timerRestart = true
  258.                         premierordre = true
  259.                         decalage = 0
  260.                         if playlist == true then
  261.                                 log(pseudo.." > "..titre.." - "..timetotal)
  262.                         else
  263.                                 log(pseudo.." > "..titre.." - "..timetotal)
  264.                         end
  265.                         setconfig = fs.open("config-s8UqqBJy","w")
  266.                         setconfig.writeLine(config["label"])
  267.                         setconfig.close()
  268.                         etat = "En Attente"
  269.                 elseif Ordre == "auto" then
  270.                         ecran.setUrl("http://youtube.com/tv#/settings")
  271.                         ecran.click(0.5555,0.5555)
  272.                         glass.clear()
  273.                         glass.sync()
  274.                 elseif Ordre == "repeat" then
  275.                         if etat == "Repeat On" then
  276.                                 setconfig = fs.open("config-s8UqqBJy","w")
  277.                                 setconfig.writeLine(config["label"])
  278.                                 setconfig.close()
  279.                                 etat = "En Cour"
  280.                         elseif etat == "En Cour" then
  281.                                 if playlist == true then
  282.                                         setconfig = fs.open("config-s8UqqBJy","a")
  283.                                         setconfig.writeLine("Repeat activer")
  284.                                         setconfig.writeLine(true)
  285.                                         setconfig.writeLine(idPlaylist)
  286.                                         setconfig.close()
  287.                                         etat = "Repeat On"
  288.                                 else
  289.                                         setconfig = fs.open("config-s8UqqBJy","a")
  290.                                         setconfig.writeLine("Repeat activer")
  291.                                         setconfig.writeLine(false)
  292.                                         setconfig.writeLine(idvideo)
  293.                                         setconfig.close()
  294.                                         etat = "Repeat On"
  295.                                 end
  296.                         else
  297.                                 erreur("Erreur repeat",pseudo,Ordre)
  298.                         end
  299.                 elseif Ordre == "next" then
  300.                                 playlistactuel = playlistactuel+1
  301.                                 idvideo = playlists[playlistactuel]
  302.                                 ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  303.                                 resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  304.                                 titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  305.                                 if string.find(idvideo,"-") == 1 then
  306.                                 idvideoo = string.sub(idvideo,2)
  307.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  308.                                 else
  309.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  310.                                 end
  311.                                 timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  312.                                 timerRestart = true
  313.                                 premierordre = true
  314.                                 decalage = 0
  315.                                 sleep(5)
  316.                                 ecran.click(0.5555,0.5555)
  317.                         elseif string.find(Ordre,"goto") ~= nil then
  318.                                 playlistactuel = Ordre:match([[goto ([^>]+)]])
  319.                                 idvideo = playlists[playlistactuel]
  320.                                 write(idvideo..">"..playlistactuel) sleep(2)
  321.                                 ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  322.                                 resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  323.                                 titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  324.                                 if string.find(idvideo,"-") == 1 then
  325.                                 idvideoo = string.sub(idvideo,2)
  326.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  327.                                 else
  328.                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  329.                                 end
  330.                                 timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  331.                                 timerRestart = true
  332.                                 premierordre = true
  333.                                 decalage = 0
  334.                                 sleep(5)
  335.                                 ecran.click(0.5555,0.5555)
  336.                 else
  337.                         erreur("Command Invalide",pseudo,Ordre)
  338.                 end
  339.         end
  340. end
  341.  
  342. --     update     ------
  343.  
  344. function updatetime()
  345.         heures = 0
  346.         minutes = 0
  347.         secondes = 0
  348.         timer = ""
  349.         while true do
  350.                 if etat == "En Cour" or etat == "Repeat On" then
  351.                         if timerRestart == true then
  352.                                 timerRestart = false
  353.                                 secondes = 0
  354.                                 minutes = 0
  355.                                 heures = 0
  356.                         end
  357.                         if timer == timetotal then
  358.                                 heures = 0
  359.                                 minutes = 0
  360.                                 secondes = 0
  361.                                 timer = ""
  362.                                 if playlist == true then
  363.                                         playlistactuel = playlistactuel+1
  364.                                 end
  365.                                 if etat == "Repeat On" then
  366.                                         if playlist == true then
  367.                                                 if tonumber(playlistactuel) <= tonumber(playlistmax) then
  368.                                                         idvideo = playlists[tonumber(playlistactuel)]
  369.                                                         ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  370.                                                         resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  371.                                                         titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  372.                                                         if string.find(idvideo,"-") == 1 then
  373.                                                                 idvideoo = string.sub(idvideo,2)
  374.                                                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  375.                                                         else
  376.                                                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  377.                                                         end
  378.                                                         timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  379.                                                         sleep(5)
  380.                                                         ecran.click(0.5555,0.5555)
  381.                                                         timerRestart = true                                                    
  382.                                                 else
  383.                                                         playlistactuel = 1
  384.                                                         idvideo = playlists[tonumber(playlistactuel)]
  385.                                                         ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  386.                                                         resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  387.                                                         titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  388.                                                         if string.find(idvideo,"-") == 1 then
  389.                                                                 idvideoo = string.sub(idvideo,2)
  390.                                                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  391.                                                         else
  392.                                                                 resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  393.                                                         end
  394.                                                         timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  395.                                                         sleep(5)
  396.                                                         ecran.click(0.5555,0.5555)
  397.                                                         timerRestart = true    
  398.                                                 end
  399.                                         else
  400.                                                 ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  401.                                                 sleep(5)
  402.                                                 ecran.click(0.5555,0.5555)
  403.                                                 timerRestart = true
  404.                                         end
  405.                                 elseif playlist == true then
  406.                                         if playlistactuel <= tonumber(playlistmax) then
  407.                                                 idvideo = playlists[playlistactuel]
  408.                                                 ecran.setUrl("http://youtube.com/embed/"..idvideo.."?controls=0")
  409.                                                 resp, webData = geturl("https://www.youtube.com/watch?v="..idvideo, true)
  410.                                                 titre = ""
  411.                                                 timetotal = ""
  412.                                                 titre = webData:match([[<title>([^>]+) %- YouTube</title>]])
  413.                                                 if string.find(idvideo,"-") == 1 then
  414.                                                         idvideoo = string.sub(idvideo,2)
  415.                                                         resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideoo, true);
  416.                                                 else
  417.                                                         resp, webData = geturl("https://www.youtube.com/results?search_query="..idvideo, true);
  418.                                                 end
  419.                                                 timetotal = webData:match([[<span class=%"video%-time%" aria%-hidden=%"true%">([^>]+)</span></a>]])
  420.                                                 sleep(5)
  421.                                                 ecran.click(0.5555,0.5555)
  422.                                                 timerRestart = true    
  423.                                         end
  424.                                 else
  425.                                 etat = "En Attente"
  426.                                 setcolor = 0xffff4d
  427.                                 timerRestart = true
  428.                                 end
  429.                         else
  430.                                 if secondes == 60 then
  431.                                         minutes = minutes+1
  432.                                         secondes = 0
  433.                                 end
  434.                                 if secondes <= 9 then
  435.                                         fsecondes = "0"..secondes
  436.                                 else
  437.                                         fsecondes = secondes
  438.                                 end
  439.                                 if minutes == 60 then
  440.                                         heures = heures+1
  441.                                         minutes = 0
  442.                                 end
  443.                                 if heures >= 1 then
  444.                                         timer = heures..":"..minutes..":"..fsecondes
  445.                                 else
  446.                                         timer = minutes..":"..fsecondes
  447.                                 end
  448.                                 secondes = secondes+1
  449.                         end
  450.                 end
  451.                 sleep(1)
  452.         end
  453. end
  454.  
  455. function titledefile(titree)
  456.         if titree.len(titree) <= 20 then
  457.                 return titree
  458.         else
  459.                 titlelen = string.len(titree)
  460.                 if decalage == titlelen-20 then
  461.                         titlesave = titree
  462.                         titletemp = titlesave.." | "..titlesave
  463.                 elseif decalage <= titlelen-21 then
  464.                         titletemp = titree
  465.                 end
  466.                 titlefinal = titletemp.sub(titletemp, decalage, decalage+20)
  467.                 decalage = decalage + 1
  468.                 if decalage == titlelen then
  469.                         decalage = 0
  470.                         titletemp = titree
  471.                 end
  472.                 return titlefinal
  473.         end
  474. end
  475.  
  476. --     Affichage     ------
  477.  
  478. function Affichage()
  479. header1 = nil
  480. header2 = nil
  481. header3 = nil
  482.         while true do
  483.                 if etaterreur ~= true then
  484.                         if etat == "En Cour" then
  485.                                 glass.clear()
  486.                                 setbackground()
  487.                                 if playlist == true then
  488.                                         headerplaylist = glass.addText(50,40,"("..playlistactuel.."/"..playlistmax..")", setcolor)
  489.                                         centerText("("..playlistactuel.."/"..playlistmax..")", headerplaylist, 1)
  490.                                 end
  491.                                 header1 = glass.addText(50,25,"En Cour", setcolor)
  492.                                 centerText("En Cour", header1, 2)
  493.                                 header2 = glass.addText(30,48,titledefile(titre), setcolor)
  494.                                 header3 = glass.addText(30,58,timer.."/"..timetotal, setcolor)
  495.                                 header4 = glass.addText(145,49,"β†’", 0xff0000)
  496.                                 header4.setScale(3)
  497.                                 centerText(titledefile(titre), header2, 1)
  498.                                 centerText(timer.."/"..timetotal, header3, 1)
  499.                                 glass.sync()
  500.                         elseif etat == "En Attente" then
  501.                                 if premierordre == true then
  502.                                         glass.clear()
  503.                                         setbackground()
  504.                                         if playlist == true then
  505.                                                 headerplaylist = glass.addText(50,40,"("..playlistactuel.."/"..playlistmax..")", setcolor)
  506.                                                 centerText("("..playlistactuel.."/"..playlistmax..")", headerplaylist, 1)
  507.                                         end
  508.                                         header1 = glass.addText(50,25,"En Attente", setcolor)
  509.                                         centerText("En Attente", header1, 2)
  510.                                         header2 = glass.addText(30,48,titledefile(titre), setcolor)
  511.                                         header3 = glass.addText(30,58,"0:00/"..timetotal, setcolor)
  512.                                         header4 = glass.addText(145,49,"β†’", 0xff0000)
  513.                                         header4.setScale(3)
  514.                                         centerText(titledefile(titre), header2, 1)
  515.                                         centerText("0:00/"..timetotal, header3, 1)
  516.                                         glass.sync()
  517.                                 else
  518.                                         glass.clear()
  519.                                         setcolor = 0xffff4d
  520.                                         setbackground()
  521.                                         local header1 = glass.addText(75,25,"En Attente", setcolor)
  522.                                         centerText("En Attente", header1, 2)
  523.                                         local header2 = glass.addText(53,48,"$$link youtube", setcolor)
  524.                                         centerText("$$link youtube", header2, 1)
  525.                                         glass.sync()
  526.                                 end
  527.                         elseif etat == "En Pause" then
  528.                                 glass.clear()
  529.                                 setbackground()
  530.                                 if playlist == true then
  531.                                         headerplaylist = glass.addText(50,40,"("..playlistactuel.."/"..playlistmax..")", setcolor)
  532.                                         centerText("("..playlistactuel.."/"..playlistmax..")", headerplaylist, 1)
  533.                                 end
  534.                                 header1 = glass.addText(50,25,"En Pause", setcolor)
  535.                                 centerText("En Pause", header1, 2)
  536.                                 header2 = glass.addText(30,48,titledefile(titre), setcolor)
  537.                                 header3 = glass.addText(30,58,timer.."/"..timetotal, setcolor)
  538.                                 header4 = glass.addText(145,49,"β†’", 0xff0000)
  539.                                 header4.setScale(3)
  540.                                 centerText(titledefile(titre), header2, 1)
  541.                                 centerText(timer.."/"..timetotal, header3, 1)
  542.                                 glass.sync()
  543.                         elseif etat == "Repeat On" then
  544.                                 glass.clear()
  545.                                 setbackground()
  546.                                 if playlist == true then
  547.                                         headerplaylist = glass.addText(50,40,"("..playlistactuel.."/"..playlistmax..")", setcolor)
  548.                                         centerText("("..playlistactuel.."/"..playlistmax..")", headerplaylist, 1)
  549.                                 end
  550.                                 header1 = glass.addText(50,25,"En Cour", setcolor)
  551.                                 centerText("En Cour", header1, 2)
  552.                                 header2 = glass.addText(30,48,titledefile(titre), setcolor)
  553.                                 header3 = glass.addText(30,58,timer.."/"..timetotal, setcolor)
  554.                                 header4 = glass.addText(147,52,"ΡΊ", 0x00aa00)
  555.                                 header4.setScale(2)
  556.                                 centerText(titledefile(titre), header2, 1)
  557.                                 centerText(timer.."/"..timetotal, header3, 1)
  558.                                 glass.sync()
  559.                         end
  560.                 else
  561.                        
  562.                 end
  563.                 sleep(0.1)
  564.         end
  565. end
  566.  
  567. function history()
  568.         while true do
  569.         term.clear()
  570.         sleep(1)
  571.         term.setCursorPos(1,1)
  572.         getlog = fs.open("log-s8UqqBJy","r")
  573.         print(getlog.readAll())
  574.         getlog.close()
  575.         sleep(30)
  576.         end
  577. end
  578.  
  579. function erreur(types,Pseudo,msg)
  580.         etaterreur = true
  581.         msetcolor = setcolor
  582.         setcolor = 0xaa0000
  583.         sleep(1)
  584.         if types == "URL Invalide" then
  585.                 glass.clear()
  586.                 setbackground()
  587.                 local mainBoxE = glass.addBox(5, 35, 1, 12, 0xa0a0a0, 0.7)
  588.                 local outlineTE = glass.addBox(4,34,2,2,0xaa0000,0.7)
  589.                 local outlineBE = glass.addBox(4,52,2,2,0xaa0000,0.7)
  590.                 mainBoxE.setWidth(12)
  591.                 outlineTE.setWidth(14)
  592.                 outlineBE.setWidth(14)
  593.                 mainBoxE.setHeight(18)
  594.                 header4 = glass.addText(6, 37," ", 0xaa0000)
  595.                 header4.setScale(2)
  596.                 ii = 9
  597.                 for i = 0, 9 do
  598.                         header1 = glass.addText(50,23,"L'Url", 0xaa0000)
  599.                         header2 = glass.addText(30,40,"Youtube", 0xaa0000)
  600.                         header3 = glass.addText(30,50,"Est Invalide", 0xaa0000)
  601.                         header4.setText(tostring(ii))
  602.                         centerText("L'Url", header1, 2)
  603.                         centerText("Youtube", header2, 1)
  604.                         centerText("Est Invalide", header3, 2)
  605.                         glass.sync()
  606.                         -- print(tostring(ii))
  607.                         ii = ii-1
  608.                         sleep(1)
  609.                 end
  610.                 log(Pseudo..">"..msg.." | "..types)
  611.         elseif types == "Command Invalide" then
  612.                 glass.clear()
  613.                 setbackground()
  614.                 local mainBoxE = glass.addBox(5, 35, 1, 12, 0xa0a0a0, 0.7)
  615.                 local outlineTE = glass.addBox(4,34,2,2,0xaa0000,0.7)
  616.                 local outlineBE = glass.addBox(4,52,2,2,0xaa0000,0.7)
  617.                 mainBoxE.setWidth(12)
  618.                 outlineTE.setWidth(14)
  619.                 outlineBE.setWidth(14)
  620.                 mainBoxE.setHeight(18)
  621.                 header4 = glass.addText(6, 37," ", 0xaa0000)
  622.                 header4.setScale(2)
  623.                 ii = 9
  624.                 for i = 0, 9 do
  625.                         header1 = glass.addText(50,23,"La Command", 0xaa0000)
  626.                         header2 = glass.addText(30,40,msg, 0xaa0000)
  627.                         header3 = glass.addText(30,50,"Est Invalid", 0xaa0000)
  628.                         header4.setText(tostring(ii))
  629.                         centerText("Command", header1, 2)
  630.                         centerText(titledefile(msg), header2, 1)
  631.                         centerText("Est Invalid", header3, 2)
  632.                         glass.sync()
  633.                         -- print(tostring(ii))
  634.                         ii = ii-1
  635.                         sleep(1)
  636.                 end
  637.                 log(pseudo..">"..msg.." | "..types)
  638.         elseif types == "Erreur repeat" then
  639.                 glass.clear()
  640.                 setbackground()
  641.                 local mainBoxE = glass.addBox(5, 35, 1, 12, 0xa0a0a0, 0.7)
  642.                 local outlineTE = glass.addBox(4,34,2,2,0xaa0000,0.7)
  643.                 local outlineBE = glass.addBox(4,52,2,2,0xaa0000,0.7)
  644.                 mainBoxE.setWidth(12)
  645.                 outlineTE.setWidth(14)
  646.                 outlineBE.setWidth(14)
  647.                 mainBoxE.setHeight(18)
  648.                 header4 = glass.addText(6, 37," ", 0xaa0000)
  649.                 header4.setScale(2)
  650.                 ii = 9
  651.                 for i = 0, 9 do
  652.                         header1 = glass.addText(50,23,"Repeat doit", 0xaa0000)
  653.                         header2 = glass.addText(30,40,"etre executer lors de", 0xaa0000)
  654.                         header3 = glass.addText(30,50,"la lecture", 0xaa0000)
  655.                         header4.setText(tostring(ii))
  656.                         centerText("Repeat doit", header1, 2)
  657.                         centerText("etre executer lors de", header2, 1)
  658.                         centerText("la lecture", header3, 2)
  659.                         glass.sync()
  660.                         -- print(tostring(ii))
  661.                         ii = ii-1
  662.                         sleep(1)
  663.                 end
  664.                 log(pseudo..">"..msg.." | "..types)
  665.         end
  666.         setcolor = msetcolor
  667.         etaterreur = false
  668. end
  669. --     System Log     ------
  670.  
  671. function log(addLog)
  672.         if fs.exists("log-s8UqqBJy") == false then
  673.                 temporaire = fs.open("log-s8UqqBJy","w")
  674.                 temporaire.writeLine(addLog)
  675.                 temporaire.close()
  676.         else
  677.                 temporaire = fs.open("log-s8UqqBJy","a")
  678.                 temporaire.writeLine(addLog)
  679.                 temporaire.close()
  680.         end
  681. end
  682.  
  683. --    Chargement     ------
  684. parallel.waitForAll(updatetime,getordre,Affichage,history)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement