Author Topic: Spotify np script  (Read 4800 times)


  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 256
Spotify np script
« on: August 14, 2010, 09:08:28 AM »
Ok, so I finally got the time to make a np script for spotify. It's really simple, it only displays the artist and song name.

Code: [Select]
Dim hwndSpotify

Function FindSpotify()
hwndSpotify = API_FindWindow("SpotifyMainWindow", "NULL")

If hwndSpotify = 0 then
SendCommand "/echo -a ---Spotify is not running---"
FindSpotify = False
FindSpotify = True
End If

End Function

Sub SpotifyNp(ServerNumber,Message)

If FindSpotify = True then

np = API_GetWindowtext(hwndSpotify,"", 200)
np = StripNp(np)
Channel = GetIdentifier("$channel")
If Channel <> "$null" then
If Message = "$1-" then
SendCommand "/msg " & Channel & " np: " & np,ServerNumber
SendCommand "/msg " & Channel & " np: " & np & " | " & Message,ServerNumber
End If
End If
End If

End Sub

Function StripNp(Message)
newNp = Mid(Message,InStr(Message,"-") + 2)
StripNp = newNp
End Function

The script basically works exactly like the one for winamp. It gets the song info from the header of the spotify window. It then strips out only the artist and song name.

For the script you will also need this alias:
Code: [Select]
/np:/! SpotifyNp $currentservernumber | $1-
To use the script, simply type "/np" (without the quotes) and the song info will be sent to your current channel.

If you type something like "/np \,,/" (again, without the quotes) the script will send the message in this form: "np: artist - Song name | \,,/"

This allows you to add your own comment to the song you're listening to.
« Last Edit: August 14, 2010, 09:13:15 AM by Morio »
"I don't know what World War 3 will be fought with, but I know World War 4 with be fought with sticks and stones." - Albert Einstein