-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpotify Player.lua
2745 lines (2357 loc) · 87.3 KB
/
Spotify Player.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
slot0 = require("gamesense/surface") or error("gamesense/surface library is required")
slot1 = require("gamesense/http") or error("gamesense/http library is required")
slot2 = require("gamesense/images") or error("gamesense/images library is required")
slot3 = require("gamesense/inspect")
slot4 = require("ffi")
slot6 = database.write
slot7 = package.searchpath
slot8 = ui.set_callback
slot9 = ui.set_visible
slot10 = ui.get
slot11 = ui.set
slot12 = ui.new_label
slot13 = ui.new_button
slot14 = ui.new_checkbox
slot15 = ui.new_combobox
slot16 = ui.new_slider
slot17 = ui.new_color_picker
slot18 = ui.new_hotkey
slot19 = ui.new_multiselect
slot20 = ui.menu_position
slot21 = entity.get_local_player
slot22 = entity.get_prop
slot23 = client.unix_time()
slot24 = client.unix_time()
slot25 = client.unix_time()
slot26 = globals.tickcount()
slot27 = globals.tickcount()
slot28 = globals.tickcount()
slot29 = client.unix_time()
slot30 = globals.tickcount()
slot31, slot32 = client.screen_size()
MenuScaleX = 4.8
MenuScaleY = 10.8
ScaleTitle = 41.54
ScaleArtist = 63.53
ScaleDuration = 57
slot33 = slot0.create_font("GothamBookItalic", slot32 / ScaleTitle, 900, 16)
slot34 = slot0.create_font("GothamBookItalic", slot32 / ScaleArtist, 600, 16)
slot35 = slot0.create_font("GothamBookItalic", 25, 900, 16)
slot36 = slot0.create_font("GothamBookItalic", 20, 600, 16)
slot37 = slot0.create_font("GothamBookItalic", slot32 / ScaleDuration, 600, 16)
slot38 = slot0.create_font("GothamBookItalic", 12, 900, 16)
slot39 = slot0.create_font("GothamBookItalic", 18, 600, 16)
slot40 = slot0.create_font("GothamBookItalic", 18, 500, 16)
slot41 = slot0.create_font("GothamBookItalic", 30, 500, 16)
slot42 = slot0.create_font("GothamBookItalic", 23, 500, 16)
slot43 = slot0.create_font("GothamBookItalic", 17, 500, 16)
slot44 = slot0.create_font("GothamBookItalic", 19, 800, 16)
slot45 = slot0.create_font("GothamBookItalic", 12, 500, 16)
slot46 = slot0.create_font("GothamBookItalic", 24, 500, 16)
slot47 = slot0.create_font("GothamBookItalic", slot32 / ScaleTitle, 900, 16)
slot48 = ui.new_checkbox("MISC", "Miscellaneous", "Spotify")
slot49 = ui.reference("MISC", "Settings", "Menu key")
slot52 = slot5("previous_size") or 30
slot53 = slot5("StoredKey") or nil
slot54 = slot5("StoredKey2") or nil
slot4.cdef([[
typedef bool (__thiscall *IsButtonDown_t)(void*, int);
typedef int (__thiscall *GetAnalogValue_t)(void*, int);
typedef int (__thiscall *GetAnalogDelta_t)(void*, int);
typedef void***(__thiscall* FindHudElement_t)(void*, const char*);
typedef void(__cdecl* ChatPrintf_t)(void*, int, int, const char*, ...);
]])
slot55 = vtable_bind("vgui2.dll", "VGUI_System010", 7, "int(__thiscall*)(void*)")
slot56 = vtable_bind("vgui2.dll", "VGUI_System010", 11, "int(__thiscall*)(void*, int, const char*, int)")
slot57 = slot4.typeof("char[?]")
slot61 = slot4.cast(slot4.typeof("void***"), client.create_interface("inputsystem.dll", "InputSystemVersion001"))[0]
slot65 = slot4.cast("IsButtonDown_t", slot61[15])
slot66 = slot4.cast("GetAnalogValue_t", slot61[18])
slot67 = slot4.cast("GetAnalogDelta_t", slot61[19])
slot75 = slot4.cast("ChatPrintf_t", ((slot4.cast("FindHudElement_t", client.find_signature("client_panorama.dll", "U\\x8b\\xecS\\x8b]VW\\x8b\\xf93\\xf69w(") or error("FindHudElement not found"))(slot4.cast("void**", slot4.cast("char*", client.find_signature("client_panorama.dll", "\\xb9\\xcc\\xcc\\xcc̈F\t") or error("sig1 not found")) + 1)[0] or error("hud is nil"), "CHudChat") or error("CHudChat not found"))[0] or error("CHudChat instance vtable is nil"))[27])
function slot76(slot0)
uv0(uv1, 0, 0, slot0)
end
slot77 = {
new = function ()
return setmetatable({
laststate = 0,
tape = 0,
initd = false,
events = {}
}, {
__index = uv0
})
end
}
retardedJpg = false
dragging = false
Authed = false
CornerReady = false
ControlCheck = false
AuthClicked = false
SongChanged = false
VolumeMax = false
VolumeMin = false
VolumeCheck = false
FirstPress = false
RunOnceCheck = false
StopSpamming = false
SetCheck = true
forkinCock = true
bool = true
gropeTits = true
animCheck = false
ShuffleState = false
UpdateWaitCheck = false
kanker = false
MenuBarExtended = false
SearchSelected = false
PlaylistSelected = false
PlaylistLimitReached = false
scrollmin = true
scrollmax = false
SongTooLong = false
SpotifyScaleX = slot31 / 4.8
SpotifyScaleY = slot32 / 10.8
SpotifyIndicX2 = 1
adaptivesize = 400
ArtScaleY = SpotifyScaleY
ArtScaleX = SpotifyScaleY
UpdateCount = 0
ClickSpree = 0
ClickSpreeTime = 1
TotalErrors = 0
ErrorSpree = 0
NewApiKeyRequest = 0
AlteredVolume = 0
NewVolume = 0
AnimSizePerc = 100
ProgressBarCache = 0
PlayListCount = 0
TrackCount = 0
scrollvalue = 0
last_analogvalue = 0
CurrentSong = "-"
AuthStatus = "> Not connected"
deviceid = ""
UserName = "-"
SongName = "-"
ArtistName = "-"
SongNameHUD = "-"
ArtistNameHUD = "-"
SongProgression = "-"
SongLength = "-"
ProgressDuration = "-"
TotalDuration = "-"
LeftDuration = "-"
SongNameBack = "-"
HoveringOver = "none"
RepeatState = "off"
loadanim = "."
AuthURL = "https://spotify.stbrouwers.cc/"
function slot83()
if uv0() > 0 then
slot1 = uv1(slot0)
uv2(0, slot1, slot0)
return uv3.string(slot1, slot0 - 1)
end
end
function slot84(slot0, slot1)
slot2 = {}
for slot6 = 1, #slot0, slot1 do
slot2[#slot2 + 1] = slot0:sub(slot6, slot6 + slot1 - 1)
end
return slot2
end
slot85 = slot77.new()
function slot77.init(slot0)
if not slot0.init then
slot0.tape = 0
slot0.laststate = uv0(uv1, 3)
slot0.initd = true
end
if uv0(uv1, 3) == 0 and slot0.tape ~= 0 then
slot0.tape = 0
return
end
if slot0.tape < uv2(uv1, 3) then
for slot5, slot6 in ipairs(slot0.events) do
slot6({
state = "Up",
pos = slot1
})
end
slot0.tape = slot1
elseif slot1 < slot0.tape then
for slot5, slot6 in ipairs(slot0.events) do
slot6({
state = "Down",
pos = slot1
})
end
slot0.tape = slot1
end
if uv2(uv1, 3) >= last_analogvalue + 1 and not scrollmin then
scrollvalue = scrollvalue + 1
elseif uv2(uv1, 3) <= last_analogvalue - 1 and not scrollmax then
scrollvalue = scrollvalue - 1
end
last_analogvalue = uv2(uv1, 3)
end
slot1.get("https://i.imgur.com/wREhluX.png", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
Loop = uv0.load_png(slot1.body)
end)
slot1.get("https://i.imgur.com/rEEvjzM.png", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
LoopA = uv0.load_png(slot1.body)
end)
slot1.get("https://i.imgur.com/8hjJTCO.png", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
Shuffle = uv0.load_png(slot1.body)
end)
slot1.get("https://i.imgur.com/HNVpf4j.png", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
ShuffleA = uv0.load_png(slot1.body)
end)
slot1.get("https://i.imgur.com/rj2IJfJ.png", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
VolumeSpeaker = uv0.load_png(slot1.body)
end)
currplaylist = {}
if slot5("previous_posX") == nil then
slot6("previous_posX", database.read("previous_posX") or 0)
slot6("previous_posY", slot5("previous_posY") or 1020)
elseif slot5("previous_posX") >= slot31 + 3 then
slot50 = 0
slot51 = 1020
end
Playlistcache = slot5("playlistcache")
if slot5("savedplaylists") == nil then
Playlists = {}
Playlistcache = ""
else
Playlists = slot5("savedplaylists")
for slot89, slot90 in ipairs(Playlists) do
PlayListCount = PlayListCount + 1
end
end
function switch(slot0)
return function (slot0)
if type(slot0[uv0]) == "function" then
return slot0[uv0]()
elseif type(slot0.default == "function") then
return slot0.default()
end
end
end
function slot86(slot0)
slot1 = math.floor(slot0 / 1000)
slot2 = math.floor(slot1 / 3600)
slot3 = slot1 - slot2 * 3600
slot5 = "00" .. slot3 - math.floor(slot3 / 60) * 60
if slot2 > 0 then
slot7 = "" .. slot4
return slot2 .. ":" .. ("00" .. slot7):sub(#slot7 + 1) .. ":" .. slot5:sub(#slot5 - 1)
else
return slot4 .. ":" .. slot6
end
end
function round(slot0)
return slot0 % 1 >= 0.5 and math.ceil(slot0) or math.floor(slot0)
end
function slot87()
if AuthClicked == false then
return
end
panorama.loadstring([[
return {
open_url: function(url){
SteamOverlayAPI.OpenURL(url)
}
}
]])().open_url(AuthURL)
end
function GetApiToken()
if NewApiKeyRequest <= 5 then
if PendingRequest then
return
end
PendingRequest = true
if AuthClicked == true then
AuthStatus = "TRYING"
end
uv0.get("https://spotify.stbrouwers.cc/refresh_token?refresh_token=" .. uv1, function (slot0, slot1)
if slot1.status ~= 200 then
AuthStatus = "WRONGKEY"
PendingRequest = false
uv0()
NewApiKeyRequest = NewApiKeyRequest + 1
return
else
PendingRequest = false
NewApiKeyRequest = 0
parsed = json.parse(slot1.body)
uv1 = parsed.access_token
Auth()
end
end)
else
return
end
end
function Auth()
if AuthClicked == true then
uv0 = uv1()
end
if uv0 == nil then
uv2()
return
end
if uv0 ~= nil and uv3 == nil then
GetApiToken()
return
end
if uv0 ~= nil and uv3 ~= nil then
uv4.get("https://api.spotify.com/v1/me?&access_token=" .. uv3, function (slot0, slot1)
ConnectionStatus = slot1.status
if not slot0 or slot1.status ~= 200 then
ConnectionStatus = slot1.status
Authed = false
AuthStatus = "FAILED"
GetApiToken()
ShowMenuElements()
UpdateElements()
return
end
UpdateCount = UpdateCount + 1
spotidata = json.parse(slot1.body)
UserName = spotidata.display_name
Authed = true
AuthStatus = "SUCCESS"
ShowMenuElements()
UpdateElements()
end)
end
end
Auth()
function DAuth()
if not ConnectionStatus then
return
end
if ConnectionStatus == 202 then
AuthStatus = "SUCCESS"
end
if ConnectionStatus == 403 then
AuthStatus = "FORBIDDEN"
ErrorSpree = ErrorSpree + 1
TotalErrors = TotalErrors + 1
end
if ConnectionStatus == 429 then
AuthStatus = "RATE"
ErrorSpree = ErrorSpree + 1
TotalErrors = TotalErrors + 1
end
if ConnectionStatus == 503 then
AuthStatus = "APIFAIL"
ErrorSpree = ErrorSpree + 1
TotalErrors = TotalErrors + 1
end
ShowMenuElements()
UpdateElements()
end
function UpdateInf()
SongNameBack = SongName
if UpdateWaitCheck == false then
DAuth()
uv0.get("https://api.spotify.com/v1/me/player?access_token=" .. uv1, function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
AuthStatus = "TOKEN"
ErrorSpree = ErrorSpree + 1
TotalErrors = TotalErrors + 1
UpdateWaitCheck = true
return
end
CurrentDataSpotify = json.parse(slot1.body)
if CurrentDataSpotify == nil then
return
end
deviceid = CurrentDataSpotify.device.id
if RunOnceCheck == false then
NewVolume = CurrentDataSpotify.device.volume_percent
RunOnceCheck = true
end
if CurrentDataSpotify.is_playing and CurrentDataSpotify.currently_playing_type == "episode" then
SongName = "Podcast"
ArtistName = ""
PlayState = "Playing"
elseif CurrentDataSpotify.is_playing then
SongName = CurrentDataSpotify.item.name
SongNameHUD = CurrentDataSpotify.item.name
ArtistName = CurrentDataSpotify.item.artists[1].name
ArtistNameHUD = CurrentDataSpotify.item.artists[1].name
Currenturi = CurrentDataSpotify.item.uri
PlayState = "Playing"
else
SongName = "Music paused"
PlayState = "Paused"
ArtistName = ""
end
SongLength = CurrentDataSpotify.item.duration_ms / 1000
SongProgression = CurrentDataSpotify.progress_ms / 1000
ShuffleState = CurrentDataSpotify.shuffle_state
RepeatState = CurrentDataSpotify.repeat_state
ProgressBarCache = CurrentDataSpotify.progress_ms
VolumeBarCache = CurrentDataSpotify.device.volume_percent
TotalDuration = uv0(CurrentDataSpotify.item.duration_ms)
ProgressDuration = uv0(CurrentDataSpotify.progress_ms)
LeftDuration = uv0(CurrentDataSpotify.item.duration_ms - CurrentDataSpotify.progress_ms)
if not CurrentDataSpotify.item.is_local then
ThumbnailUrl = CurrentDataSpotify.item.album.images[1].url
uv1.get(ThumbnailUrl, function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
Thumbnail = uv0.load_jpg(slot1.body)
end)
end
if SongNameBack ~= SongName and SongNameBack ~= nil then
SpotifyIndicX2 = uv3 + adaptivesize
SongChanged = true
end
end)
end
UpdateWaitCheck = false
end
function PlayPause()
if CurrentDataSpotify.is_playing then
PlayState = "Paused"
uv1.put("https://api.spotify.com/v1/me/player/pause?device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
else
PlayState = "Playing"
uv1.put("https://api.spotify.com/v1/me/player/play?device_id=" .. deviceid, slot0, function (slot0, slot1)
UpdateCount = UpdateCount + 1
UpdateWaitCheck = true
end)
end
end
function NextTrack()
uv1.post("https://api.spotify.com/v1/me/player/next?device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
end
function PreviousTrack()
uv1.post("https://api.spotify.com/v1/me/player/previous?device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
end
function ShuffleToggle()
if ShuffleState == true then
ShuffleState = false
else
ShuffleState = true
end
uv1.put("https://api.spotify.com/v1/me/player/shuffle?device_id=" .. deviceid .. "&state=" .. tostring(ShuffleState), {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
UpdateWaitCheck = true
end)
end
function LoopToggle()
if RepeatState == "off" then
RepeatState = "context"
elseif RepeatState == "context" then
RepeatState = "track"
elseif RepeatState == "track" then
RepeatState = "off"
end
uv1.put("https://api.spotify.com/v1/me/player/repeat?device_id=" .. deviceid .. "&state=" .. RepeatState, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
UpdateWaitCheck = true
end)
end
slot88 = {
Connected = slot12("MISC", "Miscellaneous", AuthStatus),
AuthButton = slot13("MISC", "Miscellaneous", "Authorize", function ()
AuthClicked = true
Auth()
end),
IndicType = slot15("MISC", "Miscellaneous", "Type", "Spotify", "Minimal"),
Additions = slot19("MISC", "Miscellaneous", "Additions", "Cover art", "Duration", "Vitals", "Fixed width"),
CustomLayoutType = slot15("MISC", "Miscellaneous", "Art location", "Left", "Right"),
MenuSize = slot16("MISC", "Miscellaneous", "Scale", 50, 150, 100, true, "%"),
WidthLock = slot12("MISC", "Miscellaneous", "⭥\t\t\t\t\t\t[LINKED]\t\t\t\t\t\t ⭥"),
MinimumWidth = slot16("MISC", "Miscellaneous", "Minimum box width", 199, 600, 400, true, "px", 1, {
[199.0] = "Auto"
}),
FixedWidth = slot16("MISC", "Miscellaneous", "Box width", 200, 600, 400, true, "px", 1),
DebugInfo = slot14("MISC", "Miscellaneous", "Debug info"),
NowPlaying = slot12("MISC", "Miscellaneous", "Now playing:" .. SongName),
Artist = slot12("MISC", "Miscellaneous", "By:" .. ArtistName),
SongDuration = slot12("MISC", "Miscellaneous", SongProgression .. SongLength),
VolumeLabel = slot12("MISC", "Miscellaneous", "NewVolume: " .. NewVolume),
UpdateRate = slot16("MISC", "Miscellaneous", "Update rate", 0.5, 5, 1, true, "s"),
RateLimitWarning = slot12("MISC", "Miscellaneous", "WARNING: using <1s updaterate might get you ratelimited"),
SessionUpdates = slot12("MISC", "Miscellaneous", "Total updates this session: " .. UpdateCount),
TotalErrors = slot12("MISC", "Miscellaneous", "Errors this session: " .. TotalErrors),
SpreeErrors = slot12("MISC", "Miscellaneous", "Errors this spree: " .. ErrorSpree),
RecentError = slot12("MISC", "Miscellaneous", "Most recent error: " .. "-"),
MaxErrors = slot16("MISC", "Miscellaneous", "Max errors", 1, 20, 5, true, "x"),
ErrorRate = slot16("MISC", "Miscellaneous", "within", 5, 300, 30, true, "s"),
FirstPressAmount = slot16("MISC", "Miscellaneous", "First press amount", 1, 20, 5, true, "%"),
VolumeTickSpeed = slot16("MISC", "Miscellaneous", "Volume tick speed", 1, 64, 2, true, "tc"),
VolumeTickAmount = slot16("MISC", "Miscellaneous", "Volume tick amount", 1, 10, 1, true, "%"),
SpotifyPosition = slot12("MISC", "Miscellaneous", "Position(x - x2(width), y): " .. slot50 .. " - " .. SpotifyIndicX2 .. "(" .. adaptivesize .. "), " .. slot51 .. "y"),
AddError = slot13("MISC", "Miscellaneous", "Add an error", function ()
AuthStatus = "TOKEN"
ErrorSpree = ErrorSpree + 1
TotalErrors = TotalErrors + 1
end),
ForceReflowButton = slot13("MISC", "Miscellaneous", "Force element reflow", function ()
ForceReflow()
end),
MenuBarEnable = slot14("MISC", "Miscellaneous", "Menu bar"),
HideOriginIndic = slot14("MISC", "Miscellaneous", "Hide indicator while in menu"),
CustomColors = slot14("MISC", "Miscellaneous", "Custom colors"),
ProgressGradientSwitch = slot14("MISC", "Miscellaneous", "Gradient progress bar"),
BackgroundGradientSwitch = slot14("MISC", "Miscellaneous", "Gradient background"),
LabelProgressGradient1 = slot12("MISC", "Miscellaneous", " - Progress gradient L"),
ProgressGradient1 = slot17("MISC", "Miscellaneous", "progressbar gradient 1", 0, 255, 0, 255),
LabelProgressGradient2 = slot12("MISC", "Miscellaneous", " - Progress gradient R"),
ProgressGradient2 = slot17("MISC", "Miscellaneous", "progressbar gradient 2", 0, 255, 0, 255),
LabelGradientColour = slot12("MISC", "Miscellaneous", " - Progress bar color"),
GradientColour = ui.new_color_picker("MISC", "Miscellaneous", "progress bar Colourpicker", 0, 255, 0, 255),
LabelBackgroundColor = slot12("MISC", "Miscellaneous", " - Background color"),
BackgroundColour = slot17("MISC", "Miscellaneous", "Background colourrpicker", 25, 25, 25, 255),
LabelBackgroundColorGradient1 = slot12("MISC", "Miscellaneous", " - Background gradient L"),
BackgroundColorGradient1 = slot17("MISC", "Miscellaneous", "Background Gradient colourpicker1", 25, 25, 25, 50),
LabelBackgroundColorGradient2 = slot12("MISC", "Miscellaneous", " - Background gradient R"),
BackgroundColorGradient2 = slot17("MISC", "Miscellaneous", "Background Gradient colourpicker2", 25, 25, 25, 255),
LabelTextColorPrimary = slot12("MISC", "Miscellaneous", " - Primary text color"),
TextColorPrimary = slot17("MISC", "Miscellaneous", "Primary text clr", 255, 255, 255, 255),
LabelTextColorSecondary = slot12("MISC", "Miscellaneous", " - Secondary text color"),
TextColorSecondary = slot17("MISC", "Miscellaneous", "Secondary text clr", 159, 159, 159, 255),
ControlSwitch = slot14("MISC", "Miscellaneous", "Controls"),
SmartControlSwitch = slot14("MISC", "Miscellaneous", "Smart controls"),
SmartVolumeSwitch = slot14("MISC", "Miscellaneous", "Smart volume"),
SmartControls = slot18("MISC", "Miscellaneous", " - Smart Controls", true),
PlayPause = slot18("MISC", "Miscellaneous", " - Play/Pause", false),
SkipSong = slot18("MISC", "Miscellaneous", " - Skip song", false),
PreviousSong = slot18("MISC", "Miscellaneous", " - Previous song", false),
IncreaseVolume = slot18("MISC", "Miscellaneous", " - Volume up", false),
DecreaseVolume = slot18("MISC", "Miscellaneous", " - Volume down", false),
AdaptiveVolume = slot16("MISC", "Miscellaneous", "Decrease volume by % on voicechat", 0, 100, "off", true, "%", 1, {
[0] = "off",
[100.0] = "mute"
}),
ExtrasBox = slot19("MISC", "Miscellaneous", "Extras", "Print song changes in chat", "Now playing clantag", "Higher update rate (experimental)"),
ResetAuth = slot13("MISC", "Miscellaneous", "Reset authorization", function ()
ResetAPI()
end),
KankerOp = slot13("MISC", "Miscellaneous", "Reset playlists", function ()
uv0("savedplaylists", nil)
Playlists = {}
PlayListCount = 0
PlaylistLimitReached = false
currplaylist = {}
currplaylisturi = ""
currplaylistname = ""
TrackCount = 0
Playlistcache = ""
uv0("playlistcache", Playlistcache)
PlaylistSelected = false
end)
}
function ChangeVolume(slot0)
if kanker then
kanker = false
uv1.put("https://api.spotify.com/v1/me/player/volume?volume_percent=" .. round(slot0) .. "&device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
VolumeBarCache = ScrolledVolume
else
if stopRequest then
return
end
uv1.put("https://api.spotify.com/v1/me/player/volume?volume_percent=" .. NewVolume .. "&device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
stopRequest = true
StopSpamming = false
SetCheck = true
UpdateInf()
end
end
function Seek(slot0)
uv1.put("https://api.spotify.com/v1/me/player/seek?position_ms=" .. round(slot0) .. "&device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
ProgressBarCache = CurrentDataSpotify.item.duration_ms / 404 * MouseHudPosXprgs
ProgressDuration = uv2(SeekedTime)
LeftDuration = uv2(CurrentDataSpotify.item.duration_ms - SeekedTime)
end
function PlaySong(slot0, slot1, slot2, slot3)
uv1.put("https://api.spotify.com/v1/me/player/play", {
headers = {
["Content-Type"] = "application/json",
Accept = "application/json",
Authorization = "Bearer " .. uv0
},
body = json.stringify({
position_ms = 0,
context_uri = "spotify:playlist:" .. currplaylisturi,
offset = {
position = slot0 - 1
}
})
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
if not success or response.status ~= 200 then
return
end
SongNameHUD = uv0
ArtistNameHUD = uv1
ThumbnailUrl = slot0
uv2.get(ThumbnailUrl, function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
Thumbnail = uv0.load_jpg(slot1.body)
end)
end)
end
function QueueSong(slot0)
uv1.post("https://api.spotify.com/v1/me/player/queue?uri=" .. slot0 .. "&device_id=" .. deviceid, {
headers = {
["Content-Type"] = "application/json",
["Content-length"] = 0,
Accept = "application/json",
Authorization = "Bearer " .. uv0
}
}, function (slot0, slot1)
UpdateCount = UpdateCount + 1
end)
end
function InitPlaylist(slot0)
if slot0 == nil then
client.color_log(255, 0, 0, "Failed to add playlist. Make sure that you have your Playlist link in your clipboard, and that the formatting is correct. (https://open.spotify.com/playlist/6piHLVTmzq8nTix2wIlM8x?si=10c8288bd6fc4f94)")
return
end
if string.find(Playlistcache, slot0) ~= nil then
client.color_log(255, 0, 0, "You have already added this playlist!")
return
end
UpdateWaitCheck = true
uv0.get("https://api.spotify.com/v1/playlists/" .. slot0 .. "?access_token=" .. uv1 .. "&fields=name", function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
client.color_log(255, 0, 0, "Failed to add playlist. Make sure that you have your Playlist link in your clipboard, and that the formatting is correct. (https://open.spotify.com/playlist/6piHLVTmzq8nTix2wIlM8x?si=10c8288bd6fc4f94)")
return
end
PlayListCount = PlayListCount + 1
table.insert(Playlists, {
id = PlayListCount,
PlaylistName = json.parse(slot1.body).name .. "," .. uv0
})
Playlistcache = Playlistcache .. uv0
UpdateCount = UpdateCount + 1
end)
end
function LoadPlaylist(slot0)
slot1, slot2 = string.match(slot0, "(.*),(.*)")
TrackCount = 0
UpdateWaitCheck = true
uv0.get("https://api.spotify.com/v1/playlists/" .. slot2 .. "/tracks?market=US&limit=100&offset=0" .. "&access_token=" .. uv1, function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
currplaylist = {}
currplaylistname = uv0
currplaylisturi = uv1
for slot6, slot7 in ipairs(json.parse(slot1.body).items) do
TrackCount = TrackCount + 1
table.insert(currplaylist, {
id = TrackCount,
SongDetails = slot2.items[slot6].track.name .. "^" .. slot2.items[slot6].track.artists[1].name .. "^" .. slot2.items[slot6].track.duration_ms .. "^" .. slot2.items[slot6].track.uri .. "^" .. slot2.items[slot6].track.album.images[3].url
})
PlaylistSelected = true
UpdateCount = UpdateCount + 1
end
end)
end
function AddPlaylist(slot0)
UpdateWaitCheck = true
uv0.get("https://api.spotify.com/v1/playlists/" .. slot0 .. "/tracks?market=US&limit=100&offset=" .. TrackCount .. "&access_token=" .. uv1, function (slot0, slot1)
if not slot0 or slot1.status ~= 200 then
return
end
for slot6, slot7 in ipairs(json.parse(slot1.body).items) do
TrackCount = TrackCount + 1
table.insert(currplaylist, {
id = TrackCount,
SongDetails = slot2.items[slot6].track.name .. "^" .. slot2.items[slot6].track.artists[1].name .. "^" .. slot2.items[slot6].track.duration_ms .. "^" .. slot2.items[slot6].track.uri .. "^" .. slot2.items[slot6].track.album.images[3].url
})
UpdateCount = UpdateCount + 1
end
end)
end
function setConnected(slot0)
uv0(uv1.Connected, slot0)
end
slot89 = {
DRegiony = 0,
DRegionx = 0
}
slot90 = {
DRegionx = SpotifyScaleX,
DRegiony = SpotifyScaleY
}
function slot91(slot0, slot1, slot2, slot3, slot4)
slot5 = {
ui.mouse_position()
}
rawmouseposX = slot5[1]
rawmouseposY = slot5[2]
if slot4 or false then
uv0.draw_filled_rect(slot0, slot1, slot2, slot3, 255, 0, 0, 50)
end
return slot0 <= rawmouseposX and rawmouseposX <= slot0 + slot2 and slot1 <= rawmouseposY and rawmouseposY <= slot1 + slot3
end
function slot92(slot0, slot1)
if slot0 == nil then
return false
end
for slot5 = 0, #uv0(slot0) do
if slot0[slot5] == slot1 then
return true
end
end
return false
end
function ShowMenuElements()
if uv0(uv1) and Authed then
uv2(uv3.Connected, true)
uv2(uv3.AuthButton, false)
uv2(uv3.NowPlaying, true)
uv2(uv3.Artist, true)
uv2(uv3.SongDuration, true)
uv2(uv3.IndicType, true)
uv2(uv3.GradientColour, true)
uv2(uv3.LabelGradientColour, true)
uv2(uv3.CustomColors, true)
uv2(uv3.ControlSwitch, true)
uv2(uv3.MenuSize, true)
uv2(uv3.ResetAuth, true)
uv2(uv3.MenuBarEnable, true)
uv2(uv3.ExtrasBox, true)
if uv0(uv3.IndicType) == "Spotify" then
uv2(uv3.WidthLock, ShiftClick)
uv2(uv3.MinimumWidth, not uv4(uv3.Additions, "Fixed width"))
uv2(uv3.CustomLayoutType, uv4(uv3.Additions, "Cover art"))
uv2(uv3.FixedWidth, uv4(uv3.Additions, "Fixed width"))
uv2(uv3.Additions, true)
if uv0(uv3.CustomColors) then
uv2(uv3.ProgressGradientSwitch, true)
uv2(uv3.BackgroundGradientSwitch, true)
uv2(uv3.LabelTextColorPrimary, true)
uv2(uv3.TextColorPrimary, true)
uv2(uv3.LabelTextColorSecondary, true)
uv2(uv3.TextColorSecondary, true)
uv2(uv3.BackgroundColour, true)
uv2(uv3.LabelBackgroundColor, true)
if uv0(uv3.ProgressGradientSwitch) then
uv2(uv3.LabelProgressGradient1, true)
uv2(uv3.ProgressGradient1, true)
uv2(uv3.LabelProgressGradient2, true)
uv2(uv3.ProgressGradient2, true)
uv2(uv3.GradientColour, false)
uv2(uv3.LabelGradientColour, false)
else
uv2(uv3.GradientColour, true)
uv2(uv3.LabelGradientColour, true)
uv2(uv3.LabelProgressGradient1, false)
uv2(uv3.ProgressGradient1, false)
uv2(uv3.LabelProgressGradient2, false)
uv2(uv3.ProgressGradient2, false)
end
if uv0(uv3.BackgroundGradientSwitch) then
uv2(uv3.BackgroundColorGradient1, true)
uv2(uv3.LabelBackgroundColorGradient1, true)
uv2(uv3.BackgroundColorGradient2, true)
uv2(uv3.LabelBackgroundColorGradient2, true)
else
uv2(uv3.BackgroundColorGradient1, false)
uv2(uv3.LabelBackgroundColorGradient1, false)
uv2(uv3.BackgroundColorGradient2, false)
uv2(uv3.LabelBackgroundColorGradient2, false)
end
else
uv2(uv3.ProgressGradientSwitch, false)
uv2(uv3.BackgroundGradientSwitch, false)
uv2(uv3.BackgroundColour, false)
uv2(uv3.LabelBackgroundColor, false)
uv2(uv3.LabelTextColorPrimary, false)
uv2(uv3.TextColorPrimary, false)