Advertisement
NEGI_RUS

Gmod E2 - Music Searcher v17

Dec 7th, 2013
2,603
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 20.80 KB | None | 0 0
  1. @name Music Searcher v17
  2. @inputs S:wirelink K:wirelink
  3. @outputs Private
  4. @persist W H ID StationID Reg SoundID LastPlayed LastPlayedText LastSelected LastSelectedText CurrentPlaying CurrentTime TotalPages CurrentPage PlayingPage CurrentSeconds
  5. @persist Mode Key BackspaceTime DelayTime PrivateKeyboard FooterPanel FooterOutline1 FooterOutline2 FooterOutline3 NPButton PageText PPButton PrivateUse PauseButton PauseButton2
  6. @persist SearchBarText SearchBar ResultPanel FoundText LanguageText TimeText CBtn CText Streaming Scrolling StartTime RH Version Paused Running
  7. @persist [SearchStr UrlPrefix CStr Station]:string
  8. @persist [SongArray UrlsArray TimeArray RuLayout RuLayout2 Results ResultsText ResultsTextTime]:array  [RadioStations RadioStationNames]:table
  9. @persist M:vector2 Ply:entity
  10. @model models/bull/various/speaker.mdl
  11.  
  12. if(!Running | first()) {
  13.     # YOU CAN CHANGE THAT FOR YOURSELF
  14.     PrivateKeyboard = 0
  15.     PrivateUse = 0
  16.     # UPDATE: http://pastebin.com/vq76aneJ
  17.     # Changes:
  18.     #   Added radiostations with different genres (for example: progressive)
  19.     #   Fast chars removing (backspace)
  20.     #   Fixed pause/play
  21.     #   Autorun when wired
  22.     # ================================
  23.    
  24.     if(->S) {
  25.         Running = 1  
  26.     } else {
  27.         reset()
  28.     }
  29.    
  30.     runOnHTTP(1)
  31.     runOnTick(1)
  32.  
  33.     #ifdef soundURLload(number, string, number, number, entity)
  34.         Mode = 1
  35.     #else
  36.         Mode = 0
  37.     #endif
  38.    
  39.     if(Mode != 1) {
  40.         #ifdef soundPlayURL(number, number, string)
  41.             Mode = 2
  42.         #else
  43.             Mode = 0
  44.         #endif
  45.     }
  46.        
  47.     if(Mode == 0) {
  48.         printColor(vec(0, 150, 255), "Install ", vec(255, 50, 0), "E2P", vec(0, 150, 255), ", for properly work.")
  49.         selfDestruct()  
  50.     }
  51.      
  52.     # Here you can add your music streams
  53.     function addStation(Names:array, URL:string) {
  54.         StationID++
  55.         for(I = 1, Names:count()) {
  56.             #RadioStationNames[Names[I, string], number] = StationID
  57.             RadioStations[Names[I, string], number] = StationID
  58.         }
  59.         RadioStations[StationID, string] = URL
  60.     }
  61.    
  62.     function addStation(Name:string, URL:string) {
  63.         StationID++
  64.         #RadioStationNames[Name, number] = StationID
  65.         RadioStations[Name, number] = StationID
  66.         RadioStations[StationID, string] = URL
  67.     }
  68.    
  69.     Prefix = "http://pub6.di.fm:80/di_"
  70.     addStation(array("electro house", "electro"), Prefix + "electrohouse")
  71.     addStation(array("progressive", "progressive house"), Prefix + "progressive")
  72.     addStation(array("dubstep", "brostep"), Prefix + "dubstep")
  73.     addStation("ambient", Prefix + "ambient")
  74.     addStation("chillstep", Prefix + "chillstep")
  75.     addStation(array("chiptune", "chiptunes"), Prefix + "chiptunes")
  76.     addStation("club", Prefix + "club")
  77.     addStation(array("mixes", "dj mixes"), Prefix + "djmixes")
  78.     addStation(array("deep house", "deep"), Prefix + "deephouse")
  79.     addStation(array("drum and bass", "drum 'n bass", "dnb"), Prefix + "drumandbass")
  80.     addStation(array("hardstyle", "hard style"), Prefix + "hardstyle")
  81.     addStation(array("hardcore", "hard core"), Prefix + "hardcore")
  82.     addStation("house", Prefix + "house")
  83.     addStation("minimal", Prefix + "minimal")
  84.     addStation("techno", Prefix + "techno")
  85.     addStation("trance", Prefix + "trance")
  86.     addStation("trap", Prefix + "trap")
  87.     addStation(array("uk garage", "ukgarage"), Prefix + "ukgarage")
  88.    
  89.     W = 512
  90.     H = W
  91.     Reg = 1
  92.     SoundID = owner():id()
  93.    
  94.     RuLayout = array(0x445, 92, 0x44A, 0x0, 0x0, 0x44D, 0x444, 0x438, 0x441, 0x432, 0x443, 0x430, 0x43F, 0x440, 0x448, 0x43E, 0x43B, 0x434, 0x44C, 0x442, 0x449, 0x437, 0x439, 0x43A, 0x44B, 0x435, 0x433, 0x43C, 0x446, 0x447, 0x43D, 0x44F)
  95.    
  96.     # Fuck that cyrillic unicode...
  97.     RuLayout2[39, number] = 0x44D
  98.     RuLayout2[44, number] = 0x431
  99.     RuLayout2[46, number] = 0x44E
  100.     RuLayout2[59, number] = 0x436
  101.    
  102.     function number addBox([Pos Size]:vector2) {
  103.         ID++
  104.         S:egpBox(ID, Pos, Size)
  105.         return ID
  106.     }
  107.    
  108.     function number addTriangle([P1 P2 P3]:vector2) {
  109.         ID++
  110.         S:egpTriangle(ID, P1, P2, P3)
  111.         return ID
  112.     }
  113.    
  114.     function number addBoxOutline([Pos Size]:vector2) {
  115.         ID++
  116.         S:egpBoxOutline(ID, Pos, Size)
  117.         return ID
  118.     }
  119.    
  120.     function number addRoundedBox([Pos Size]:vector2) {
  121.         ID++
  122.         S:egpRoundedBox(ID, Pos, Size)
  123.         return ID
  124.     }
  125.    
  126.     function number addText(Str:string, Pos:vector2, Size) {
  127.         ID++
  128.         S:egpText(ID, Str, Pos)
  129.         #S:egpSize(ID, Size)
  130.         S:egpFont(ID, "fixedsys", Size)
  131.         return ID
  132.     }
  133.    
  134.     function number addMultiLine(Args:array) {
  135.         ID++
  136.         #S:egpLine(ID, Pos1, Pos2)
  137.         S:egpPoly(ID, Args)
  138.         S:egpSize(ID, 1)
  139.         return ID
  140.     }
  141.    
  142.     function number addTextLayout(Str:string, Pos:vector2, Size) {
  143.         ID++
  144.         S:egpTextLayout(ID, Str, Pos, vec2(Size))
  145.         return ID
  146.     }
  147.    
  148.     function string timeToText(Time) {
  149.         Mins = floor(Time / 60)
  150.         Seconds = Time - Mins * 60
  151.         SSeconds = Seconds + ""
  152.         if(Seconds < 10) { SSeconds = "0" + Seconds }
  153.         return Mins + ":" + SSeconds
  154.     }
  155.    
  156.     function pausePlayClick() {
  157.         if(Paused) {
  158.             S:egpTriangle(PauseButton, vec2(129, H - 35), vec2(155, H - 20), vec2(129, H - 5))
  159.             S:egpColor(PauseButton, vec(0, 75, 150))
  160.             S:egpAlpha(PauseButton2, 0)
  161.         } else {
  162.             S:egpBox(PauseButton, vec2(129, H - 35), vec2(8, 30))
  163.             S:egpColor(PauseButton, vec(0, 75, 150))
  164.             S:egpAlpha(PauseButton2, 255)
  165.             #PauseButton2 = addBox(vec2(143, H - 35), vec2(8, 30))
  166.             #S:egpColor(PauseButton2, vec(0, 75, 150))  
  167.         }
  168.     }
  169.    
  170.     function play(URL:string) {
  171.         if(Mode == 1) {
  172.             #ifdef soundURLload(number, string, number, number, entity)
  173.                 soundURLload(SoundID, URL, 1, 0, entity())
  174.             #endif
  175.         } else {
  176.             #ifdef soundPlayURL(number, number, string)
  177.                 soundPlayURL(SoundID, 100000, URL)
  178.             #endif
  179.         }
  180.         Paused = 0
  181.         pausePlayClick()
  182.     }
  183.    
  184.     function drawResults(From) {
  185.         J = 1
  186.         for(I = From, From + 9) {
  187.             Count = 0
  188.             Str = SongArray[I, string]
  189.            
  190.             ResultTextId = ResultsText[J, number]
  191.             ResultTexTimetId = ResultsTextTime[J, number]
  192.             # TODO: mb removed
  193.             if(Str == "") {
  194.                 S:egpSetText(ResultTextId, "")
  195.                 S:egpSetText(ResultTexTimetId, "")
  196.                 J++
  197.                 continue
  198.             }
  199.            
  200.             Count = Str:length() - Str:replace(toChar(208), ""):replace(toChar(209), ""):length()
  201.             FinalStr = Str:replace("~", " - "):left((Streaming ? 55 : 45) + Count)
  202.             S:egpSetText(ResultTextId, FinalStr)
  203.             #print(ResultTextId)
  204.             S:egpColor(ResultTextId, Streaming ? vec(130, 0, 255) : vec(0, 150, 255))
  205.             S:egpSetText(ResultTexTimetId, Streaming ? "" : timeToText(TimeArray[I, number]))
  206.             J++
  207.         }
  208.     }
  209.    
  210.     function switchLanguage() {
  211.         Reg = !Reg
  212.        
  213.         if(Reg) {
  214.             S:egpSetText(LanguageText, "EN")
  215.         } else {
  216.             S:egpSetText(LanguageText, "RU")
  217.         }  
  218.     }
  219.  
  220.     function buttonClick() {
  221.         if(inrange(M, vec2(120, H - 40), vec2(120, H - 40) + vec2(40, 40))) {
  222.             #ifdef soundURLpause(number)
  223.             Paused = !Paused
  224.             if(Paused) {
  225.                 soundURLpause(SoundID)
  226.                 stoptimer("timeChange")
  227.             } else {
  228.                 soundURLplay(SoundID)
  229.                 if(!Streaming) {
  230.                     timer("timeChange", 1000)
  231.                 }
  232.             }
  233.             pausePlayClick()
  234.             return
  235.             #endif
  236.         } elseif(inrange(M, vec2(354, H - 35), vec2(354, H - 35) + vec2(30, 30))) {
  237.             CurrentPage++
  238.         } elseif(inrange(M, vec2(264, H - 35),  vec2(264, H - 35) + vec2(30, 30))) {
  239.             CurrentPage--
  240.         }
  241.        
  242.         if(CurrentPage > TotalPages) {
  243.             CurrentPage = TotalPages
  244.         } elseif(CurrentPage < 1) {
  245.             CurrentPage = 1
  246.         } else {
  247.             S:egpSetText(PageText, CurrentPage + "/" + TotalPages)
  248.             drawResults((CurrentPage - 1) * 10 + 1)
  249.             if(CurrentPage == PlayingPage) {
  250.                 S:egpColor(Results[CurrentPlaying, number], vec(100, 90, 100))
  251.             } else {
  252.                 S:egpColor(Results[CurrentPlaying, number], vec(50))
  253.             }
  254.         }      
  255.     }
  256.    
  257.     function removeLastChar() {
  258.         C = 1
  259.         if(toByte(SearchStr[SearchStr:length()]) > 126) {
  260.            C = 2
  261.         }
  262.         SearchStr = SearchStr:left(SearchStr:length() - C)
  263.         S:egpSetText(SearchBarText, SearchStr)  
  264.     }
  265.    
  266.     if(Mode == 1) {
  267.         #ifdef soundURLpause(number)  
  268.         #soundURLpause(SoundID)  
  269.         #endif
  270.     }
  271.  
  272.     S:egpClear()
  273.     S:egpDrawTopLeft(1)
  274.    
  275.     SearchBar = addBox(vec2(5, 5), vec2(512 - 10, 26))
  276.     S:egpColor(SearchBar, vec(50))
  277.    
  278.     SearchBar = addBoxOutline(vec2(5, 5), vec2(512 - 10, 26))
  279.     S:egpColor(SearchBar, vec(160))
  280.    
  281.     SearchBarText = addText("Enter song name...", vec2(10, 5), 20)
  282.     S:egpColor(SearchBarText, vec(200))
  283.    
  284.     FooterPanel = addBox(vec2(0, H - 40), vec2(W, 40))
  285.     S:egpColor(FooterPanel, vec(25))
  286.    
  287.     NPButton = addBox(vec2(354, H - 35), vec2(30, 30))
  288.     S:egpColor(NPButton, vec(0, 75, 150))
  289.     NPText = addText(">", vec2(364, H - 30), 18)
  290.    
  291.     PageText = addText("0/0", vec2(324, H - 30), 20)
  292.     S:egpColor(PageText, vec(200))
  293.     S:egpAlign(PageText, 1)
  294.    
  295.     PPButton = addBox(vec2(264, H - 35), vec2(30, 30))
  296.     S:egpColor(PPButton, vec(0, 75, 150))
  297.     NPText = addText("<", vec2(274, H - 30), 18)
  298.    
  299.     TimeText = addText("0:00/0:00", vec2(209, H - 30), 20)
  300.     S:egpColor(TimeText, vec(200))
  301.     S:egpAlign(TimeText, 1)  
  302.    
  303.     PauseButton = addTriangle(vec2(129, H - 35), vec2(155, H - 20), vec2(129, H - 5))
  304.     S:egpColor(PauseButton, vec(0, 75, 150))
  305.    
  306.     PauseButton2 = addBox(vec2(143, H - 35), vec2(8, 30))
  307.     S:egpColor(PauseButton2, vec(0, 75, 150))
  308.     S:egpAlpha(PauseButton2, 0)
  309.    
  310.     FooterOutline1 = addBoxOutline(vec2(159, H - 40), vec2(100, 40))
  311.     S:egpColor(FooterOutline1, vec(100))
  312.    
  313.     FooterOutline2 = addBoxOutline(vec2(258, H - 40), vec2(132, 40))
  314.     S:egpColor(FooterOutline2, vec(100))
  315.    
  316.     FooterOutline3 = addBoxOutline(vec2(120, H - 40), vec2(40, 40))
  317.     S:egpColor(FooterOutline3, vec(100))
  318.    
  319.     Arr = array(0x42, 0x79, 0x20, 0x2D, 0x4E, 0x45, 0x47, 0x49, 0x2D, 0x20, 0x28, 0x63, 0x29, 0x20, 0x32, 0x30, 0x31, 0x33) for(I = 1, Arr:count() - (PrivateUse ? 9 : 0)) { CStr += toChar(Arr[I, number]) }
  320.      
  321.     RH = 41
  322.     for(I = 1, 10) {
  323.         Results[I, number] = addRoundedBox(vec2(7, I * (RH + 1) + 2), vec2(512 - 14, RH))
  324.         S:egpColor(Results[I, number], vec(50, 50, 50))
  325.        
  326.         ResultsText[I, number] = addText("", vec2(10, I * (RH + 1) + 10), 20)
  327.         S:egpColor(ResultsText[I, number], vec(0, 150, 255))
  328.        
  329.         ResultsTextTime[I, number] = addText("", vec2(W - 15, I * (RH + 1) + 12), 18)
  330.         S:egpAlign(ResultsTextTime[I, number], 2)
  331.         S:egpColor(ResultsTextTime[I, number], vec(200))
  332.     }
  333.    
  334.    
  335.     LanguagePanel = addBox(vec2(W - 30, 7), vec2(25, 22))
  336.     S:egpColor(LanguagePanel, vec(50))
  337.    
  338.     LanguageText = addText("EN", vec2(W - 29, 8), 18)
  339.     S:egpColor(LanguageText, vec(250))
  340.    
  341.     CBtn = addBox(vec2(W - 20, H - 20), vec2(20, 20))
  342.     S:egpColor(CBtn, vec(60))
  343.    
  344.     CText = addText("?", vec2(W - 5, H - 19), 18)
  345.     S:egpColor(CText, vec(250))
  346.     S:egpAlign(CText, 2)
  347.    
  348.     Cursor = addMultiLine(array(vec2(0, 0), vec2(0, 20), vec2(4, 11), vec2(16, 16)))
  349.     S:egpColor(Cursor, vec4(0, 148, 255, 150))
  350.     S:egpParentToCursor(Cursor)
  351.    
  352.     LastSelected = Results[1, number]
  353.     LastSelectedText = ResultsText[1, number]
  354.     LastPlayed = 1
  355.     Paused = 1
  356.    
  357.     Ply = owner()
  358.     findIncludeClass("player")
  359.    
  360.     Version = 17
  361. }
  362.  
  363. if(findCanQuery()) {
  364.     if(PrivateUse == 0) {
  365.         findInSphere(entity():pos(), 500)
  366.         findSortByDistance(entity():pos())
  367.         Ply = find()
  368.     }
  369. }
  370.  
  371. M = S:egpCursor(Ply)
  372. S:egpColor(LastSelectedText, Streaming ? vec(130, 0, 255) : vec(0, 150, 255))
  373. #if(PlayingPage == CurrentPage) {
  374.     if(PlayingPage == CurrentPage & LastSelected == Results[CurrentPlaying, number]) {
  375.         S:egpColor(LastSelected, vec(100, 90, 100))
  376.     } else {
  377.         S:egpColor(LastSelected, vec(50, 50, 50))
  378.     }
  379. #}
  380.  
  381. S:egpBox(CBtn, vec2(W - 20, H - 20), vec2(20, 20))
  382. S:egpSetText(CText, "?")
  383. S:egpColor(CText, vec(200))
  384. OKey = Ply:keyUse() | Ply:keyAttack2()
  385.  
  386. if(M:y() < 462) {
  387.     Num = round((M:y() - 23) / (RH + 1))
  388.     if(Num >= 1 & Num <= 10) {
  389.         Pick = Num + ((CurrentPage - 1) * 10)
  390.        
  391.         if(CurrentPage == PlayingPage & Num == CurrentPlaying) {
  392.             S:egpColor(Results[Num, number], vec(120, 110, 120))
  393.         } else {
  394.             S:egpColor(Results[Num, number], vec(150))
  395.         }
  396.         S:egpColor(ResultsText[Num, number], vec(255))
  397.         LastSelected = Results[Num, number]
  398.         LastSelectedText = ResultsText[Num, number]
  399.        
  400.         if(changed(OKey) & OKey) {
  401.             if(Streaming) {
  402.                 httpRequest("http://negi.sytes.net/gmod/search.php?stream=" + Station)
  403.             } else {
  404.                 play("http://vk-music.ru" + UrlsArray[Pick, string])
  405.             }
  406.             CurrentPlaying = Num
  407.             S:egpColor(Results[LastPlayed, number], vec(50))
  408.             LastPlayed = Num
  409.             PlayingPage = CurrentPage
  410.             if(!Streaming) {
  411.                 StartTime = curtime()
  412.                 CurrentSeconds = 0
  413.                 timer("timeChange", 1000)
  414.             }
  415.         }
  416.     }
  417. } elseif(changed(OKey) & OKey) {
  418.     buttonClick()
  419. }
  420. if(PrivateUse | inrange(M, vec2(W - 20, H - 20), vec2(W - 20, H - 20) + vec2(20, 20))) {
  421.     X = PrivateUse ? 85 : 153
  422.     S:egpBox(CBtn, vec2(W - X + 1, H - 20), vec2(X, 20))
  423.     S:egpSetText(CText, CStr)
  424.     S:egpColor(CText, vec(0, 110, 255))
  425. }
  426. #print(Num + " " + Results[Num, number] + " " + LastSelected + " " + randint(10000))
  427.  
  428. #[
  429. if(Streaming) {
  430.     Scrolling += 0.1
  431.     if(Scrolling % 10 == 0) {
  432.         Str = SongArray[1, string]
  433.         Count = Str:length() - Str:replace(toChar(208), ""):replace(toChar(209), ""):length()
  434.         #FinalStr = Str:left(55 + Count - floor(Scrolling))
  435.         #Push = Str[1]
  436.         #Str:pushString(Push + "")
  437.         #Str:removeArray(1)
  438.         Str = Str:left(-(Count - 1))
  439.         #SongArray[1, string] = Str
  440.         #S:egpSetText(ResultsText[1, number], FinalStr)
  441.     }
  442. }
  443. ]#
  444.  
  445. if(changed(OKey) & OKey) {
  446.     if(inrange(M, vec2(W - 30, 7), vec2(W - 30, 7) + vec2(25, 22))) {
  447.         switchLanguage()
  448.     }
  449. }
  450.  
  451. if(clk("timeChange")) {
  452.     #CurrentTime = floor(curtime() - StartTime)
  453.     SongTime = TimeArray[CurrentPlaying + ((PlayingPage - 1) * 10), number]
  454.     #print(CurrentPlaying + ((PlayingPage - 1) * 10))
  455.     S:egpSetText(TimeText, timeToText(CurrentSeconds) + "/" + timeToText(SongTime))
  456.     CurrentSeconds++
  457.    
  458.     if(CurrentSeconds == SongTime) {
  459.         CurrentPlaying++
  460.         if(CurrentPlaying > 10) {
  461.             CurrentPlaying = 1
  462.             if(PlayingPage < TotalPages) {
  463.                 PlayingPage++
  464.             }
  465.         }
  466.         N = CurrentPlaying + ((CurrentPage - 1) * 10)
  467.         play("http://vk-music.ru" + UrlsArray[N, string])
  468.         S:egpColor(Results[N, number], vec(120, 110, 120))
  469.         S:egpColor(Results[LastPlayed, number], vec(50))
  470.         LastPlayed = CurrentPlaying
  471.         CurrentSeconds = 0
  472.     }
  473.     timer("timeChange", 1000)
  474. }
  475.  
  476. Key = K["Memory", number]
  477. Private = 0
  478.  
  479. if(K["InUse", number]) {
  480.     if(PrivateKeyboard & K["User", entity]:name() != owner():name()) {
  481.         Private = 1
  482.     }
  483.     if(changed(Key) & Key == 127) {
  484.         BackspaceTime = 0
  485.         removeLastChar()
  486.     } elseif(Key == 127) {
  487.         if(BackspaceTime == 20) {
  488.             BackspaceTime = 20
  489.             DelayTime++
  490.             if(DelayTime == 3) {
  491.                 DelayTime = 0
  492.                 removeLastChar()
  493.             }
  494.         } else {
  495.             BackspaceTime++
  496.         }
  497.     } elseif(changed(Key) & Key) {
  498.         BackspaceTime = 0
  499.         if(Key == 13) {
  500.             if(httpCanRequest()) {
  501.                 SearchFor = SearchStr:trim()
  502.                 Station = RadioStations[RadioStations[SearchFor:lower(), number], string]
  503.                 if(SearchFor == "radio") {
  504.                     foreach(K, V:number = RadioStations) {
  505.                         print(K + " " + V)
  506.                     }
  507.                     #print(RadioStations[RadioStations["electro", number], string])
  508.                     #play(RadioStations[1, string])
  509.                     #Streaming = 1
  510.                     #UrlsArray[1, string] = Station
  511.                     #stoptimer("timeChange")
  512.                 } elseif(Station != "") {
  513.                     httpRequest("http://negi.sytes.net/gmod/search.php?stream=" + Station)
  514.                     print(Station)
  515.                     play(Station)
  516.                     Streaming = 1
  517.                     UrlsArray = array()
  518.                     UrlsArray[1, string] = Station
  519.                     TimeArray = array()
  520.                     stoptimer("timeChange")
  521.                 } else {
  522.                     Req = httpUrlEncode(SearchFor)
  523.                     #print(Req)
  524.                     httpRequest("http://negi.sytes.net/gmod/search.php?args=" + Req + "&ver=" + Version)
  525.                 }
  526.             } else {
  527.                 print("Try again")
  528.             }
  529.         } elseif(Key == 9) {
  530.             switchLanguage()
  531.         } elseif(Key != 154) {
  532.             if(!Reg) {
  533.                 if(Key >= 65 & Key <= 90) {
  534.                     Key += 32
  535.                 }
  536.                 if(Key >= 91 & Key <= 122) {
  537.                     UC = RuLayout[Key - 90, number]
  538.                 } elseif(Key == 32 | Key >= 48 & Key <= 57) {
  539.                     UC = Key
  540.                 } else {
  541.                     UC = RuLayout2[Key, number]
  542.                 }
  543.             } else {
  544.                 UC = Key
  545.             }
  546.             SearchStr += toUnicodeChar(UC)
  547.         }
  548.         S:egpSetText(SearchBarText, SearchStr)  
  549.     }
  550. }
  551.  
  552. if(httpClk()) {
  553.     Data = httpData():explode("\n")
  554.     Count = Data:count()
  555.    
  556.     if(Data[1, string] == "ok") {
  557.         SongsCount = Data[2, string]:toNumber()
  558.         print("Found " + SongsCount)
  559.        
  560.         SongArray = array()
  561.        
  562.         for(I = 1, SongsCount) {
  563.             SongArray[I, string] = Data[I + 2, string]
  564.             #print(Data[I + 2, string])
  565.         }
  566.        
  567.         if(SongsCount < 10) {
  568.             for(I = Count - 3, SongArray:count() - Count) {
  569.                 SongArray[I, string] = ""
  570.             }
  571.         }
  572.        
  573.         UrlsArray = Data[Count - 1, string]:explode(",")
  574.         TimeArray = Data[Count, string]:explode(",")
  575.         play("http://vk-music.ru" + UrlsArray[1, string])
  576.         Streaming = 0
  577.        
  578.         S:egpColor(ResultsText[1, number], vec(0, 150, 255))
  579.         S:egpColor(Results[LastPlayed, number], vec(50))
  580.         S:egpColor(Results[1, number], vec(100, 90, 100))
  581.        
  582.         for(I = 1, SongsCount) {
  583.             TimeArray[I, number] = TimeArray[I, string]:toNumber()
  584.         }
  585.         timer("timeChange", 1000)
  586.        
  587.         drawResults(1)
  588.         CurrentPlaying = 1
  589.         LastPlayed = 1
  590.         CurrentPage = 1
  591.         PlayingPage = 1
  592.         TotalPages = ceil(SongsCount / 10)
  593.         StartTime = curtime()
  594.         CurrentSeconds = 0
  595.         S:egpSetText(PageText, "1/" + TotalPages)
  596.     } elseif(Data[1, string] == "iok") {
  597.         print("unfo")
  598.         Str = Data[2, string]
  599.         print(1 + " " + Str)
  600.         S:egpSetText(PageText, "1/1")
  601.         S:egpSetText(TimeText, "0:00/0:00")
  602.         S:egpColor(ResultsText[1, number], vec(130, 0, 255))
  603.         S:egpColor(Results[LastPlayed, number], vec(50))
  604.         S:egpColor(Results[1, number], vec(100, 90, 100))
  605.         SongArray = array()
  606.         SongArray[1, string] = Str
  607.         CurrentPlaying = 1
  608.         LastPlayed = 1
  609.         CurrentPage = 1
  610.         PlayingPage = 1
  611.         TotalPages = 1
  612.         CurrentSeconds = 0
  613.         drawResults(1)
  614.     } else {
  615.         print("Not found")
  616.         S:egpSetText(ResultsText[1, number], " Nothing found")
  617.         S:egpColor(ResultsText[1, number], vec(255, 50, 0))
  618.         for(I = 2, 10) {
  619.             S:egpSetText(ResultsText[I, number], "")
  620.         }
  621.     }
  622. }
  623.  
  624. # -NEGI- (C) 2013
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement