-- <> Services </>
local Players = game:GetService("Players")
local HttpService = game:GetService("HttpService")
-- </> Variables </>
local client = "a078520cc3bd4ede8007a6a4349a443c"
local secret = "89741fa735254e818e0305e22296fcb4"
local playlistId = "5qeMbwkcSnUv3V5FpubrKk"
local playlistAPI = "https://api.spotify.com/v1/playlists/"
local tokenAPI_sp = "https://accounts.spotify.com/api/token/"
local lyricsAPI = "https://spclient.wg.spotify.com/color-lyrics/v2/track/"
local code = "AQApHaPuVmVs7NZc4L2fMXhREZ1MmUtB7tRf4aSOfqv6YGY31PCH3l2CSx3vxmJlWheRSZbBwFibSFtdyFuMpNMnsRH1MQbrQBcWJmCZYHD__7sspYxC2ccgG4sqyjknGat2OoYuY89VJZVjHYTGNnR7oWFL-MR8hWjGNINqmhaFECHreQOZOZLRLQjemPxO3t_ejlmqb9v5MqLr4y0Xg-sV_l8xGRBdArRQahMlKw"
local refreshToken = "AQA-LvFfY5gXSdwWNVoLsXPslzWDfu5o3u1IkKVXdFF-7qDKX4bRrjDin4Myl_dp7gTSkuGsK1f_w5N8FGubkhLE2y4D0ZUk794fZBvFx2kU_e5L9mlZ-MkE_28pZ9o3k8Y"
local accessToken= nil;
local playerName = "tabanog1234"
local player = owner or Players:WaitForChild(playerName)
local playerChar = player.Character or player.CharacterAdded:Wait()
local billboardGui = Instance.new("BillboardGui")
billboardGui.Size = UDim2.fromScale(5, 1)
billboardGui.StudsOffset = Vector3.new(0, 2.5, 0)
billboardGui.Parent = playerChar.Head
local frame = Instance.new("Frame")
frame.Size = UDim2.fromScale(1, 1)
frame.BackgroundTransparency = 1
frame.Parent = billboardGui
local label = Instance.new("TextLabel")
label.Size = UDim2.fromScale(1, 1)
label.TextWrapped = false
label.TextColor3 = Color3.fromRGB(255, 255, 255)
label.TextScaled = true
label.BackgroundTransparency = 1
label.Font = Enum.Font.RobotoMono
label.Parent = frame
-- <> Misc Funcs </>
local function getSpAccessToken(client_id, client_secret)
local data = `client_id={client_id}&client_secret={client_secret}&grant_type=client_credentials`
local headers = {
["Content-Type"] = "application/x-www-form-urlencoded"
}
local response = HttpService:RequestAsync({
Url = tokenAPI_sp,
Method = "POST",
Headers = headers,
Body = data
})
local body = HttpService:JSONDecode(response.Body)
local token = body["access_token"]
return token
end
local function getSpRefreshToken(client_id, secret_id, code)
local redirect = "https://google.com/callback"
local data = `client_id={client_id}&client_secret={secret_id}&grant_type=authorization_code&code={code}&redirect_uri={redirect}`
local response = HttpService:RequestAsync({
Url = tokenAPI_sp,
Method = "POST",
Body = data
})
local body = HttpService:JSONDecode(response.Body)
return body["refresh_token"]
end
local function getSpAccessTokenFromRefreshToken(client_id, secret_id, refresh_token)
local data = `client_id={client_id}&client_secret={secret_id}&refresh_token={refresh_token}&grant_type=refresh_token`
local response = HttpService:RequestAsync({
Url = tokenAPI_sp,
Method = "POST",
Body = data
})
local body = HttpService:JSONDecode(response.Body)
return body["access_token"]
end
local function getArtists(track)
local artists = ""
for i, artistData in next, track.artists do
if i == 1 then
artists = artistData.name
continue
end
artists = `{artists}, {artistData.name}`
end
return artists
end
local function getTracksFromPlaylist(playlistId, accessToken)
local headers = {
["Authorization"] = `Bearer {accessToken}`
}
local response = HttpService:RequestAsync({
Url = `{playlistAPI}{playlistId}/tracks`,
Method = "GET",
Headers = headers
})
local data = HttpService:JSONDecode(response.Body)
local tracks = {}
for _, item in next, data.items do
local track = item.track
local artists = getArtists(track)
local trackData = {
name = track.name,
artists = artists,
track = track
}
table.insert(tracks, trackData)
end
return tracks
end
local function getCurrentSongPlaying(accessToken)
local url = "https://api.spotify.com/v1/me/player/currently-playing"
local headers = {
["Authorization"] = `Bearer {accessToken}`
}
local response = HttpService:RequestAsync({
Url = url,
Method = "GET",
Headers = headers
})
local data = HttpService:JSONDecode(response.Body)
local item = data.item
local name = item.name
return item.artists[1].name, name
end
-- <> Mian script </>
if refreshToken == nil then
accessToken = getSpAccessToken(client, secret)
else
accessToken = getSpAccessTokenFromRefreshToken(client, secret, refreshToken)
end
while true do
local artist, songName = getCurrentSongPlaying(accessToken)
label.Text = `{artist} - {songName}`
task.wait(5)
end