Because of Spotify's HTTP connectivity. It is possible to view the name of a song if someone posts it in a channel easily. Either using the built in auto-feed. Which can alternatively be disabled. Or using the alias /Spotify [name-of-track/album]
This version also now deals with album names too.
Screenshot.. View image
; Spotify Track Identifier
; Version 1.4.0
; Jonesy44
; ---
; Syntax
; /Spotify [link-to-track|album|artist] Return track name & artist
; eg: /Spotify http://open.spotify.com/track/4q8o513Sv5TMcJAFGcJswT
; or: /Spotify spotify:track:4q8o513Sv5TMcJAFGcJswT
; /Spotify [On/Off] Automatically respond to channel when link posted
;
; Both methods will check for Spotify URI links and HTTP links.
; ---
alias Spotify {
if $regex($1,/^on$/Si) {
set %Spotify.Channel.DontRespond 0
echo -a 2* Spotify: Will now respond to channel Spotify links
}
else if $regex($1,/^off$/Si) {
set %Spotify.Channel.DontRespond 1
echo -a 2* Spotify: Will no longer respond to channel links
}
else if $regex($1,/^(http\:\/\/)?open.spotify.com\/(track|album|artist)\/([a-zA-Z0-9]{22})$/Si) {
set %Spotify.Search.Type $iif($regml(1) == http://,$regml(2),$regml(1))
set %Spotify.Search.URI $iif($regml(1) == http://,$regml(3),$regml(2))
set %Spotify.Search.ReturnMethod echo -a
set %Spotify.Search.Check $+(spotify:,%Spotify.Search.Type,:,%Spotify.Search.URI)
Spotify.GetInfo
}
else if $regex($1,/^spotify\:(track|album|artist):([a-zA-Z0-9]{22})$/Si) {
set %Spotify.Search.Type $regml(1)
set %Spotify.Search.URI $regml(2)
set %Spotify.Search.ReturnMethod echo -a
set %Spotify.Search.Check $+(spotify:,%Spotify.Search.Type,:,%Spotify.Search.URI)
Spotify.GetInfo
}
else echo -a 2* Spotify: Your command was not recognised
}
on $*:text:/(http.\/\/)?open.spotify.com\/(track|album|artist)\/([a-zA-Z0-9]{22})/Si:#: {
if !%Spotify.Channel.DontRespond {
set %Spotify.Search.Type $iif($regml(1) == http://,$regml(2),$regml(1))
set %Spotify.Search.URI $iif($regml(1) == http://,$regml(3),$regml(2))
set %Spotify.Search.ReturnMethod msg #
set %Spotify.Search.Check $+(spotify:,%Spotify.Search.Type,:,%Spotify.Search.URI)
Spotify.GetInfo
}
}
on $*:text:/spotify.(track|album|artist).([a-zA-Z0-9]{22})/Si:#: {
if !%Spotify.Channel.DontRespond {
set %Spotify.Search.Type $regml(1)
set %Spotify.Search.URI $regml(2)
set %Spotify.Search.ReturnMethod msg #
set %Spotify.Search.Check $+(spotify:,%Spotify.Search.Type,:,%Spotify.Search.URI)
Spotify.GetInfo
}
}
alias Spotify.GetInfo sockopen $+(Spotify.,$ticks) open.spotify.com 80
on *:sockopen:Spotify.*:{
if $sockerr { %Spotify.Search.ReturnMethod Socket error: $sock($sockname).wsmsg }
else {
sockwrite -nt $sockname GET $+(/,%Spotify.Search.Type,/,%Spotify.Search.URI,) HTTP/1.1
sockwrite -nt $sockname Host: open.spotify.com
sockwrite -nt $sockname $crlf
}
}
on *:sockread:Spotify.*:{
var %SocketRead
sockread %SocketRead
if $regex(%SocketRead,/<meta property="og:description" content="(.*) a[n]? (album|song|artist) (.*)on Spotify\." \/>/Si) {
%Spotify.Search.ReturnMethod 14[Spotify $+(04,$upper(%Spotify.Search.Type),14]) $iif(%Spotify.Search.Check != $regml(1),$left($regml(1),-1) $iif($regml(3),14by1 $regml(3)),04 $+ $upper(%Spotify.Search.Type) does not exist)
Unset %Spotify.Search.*
Sockclose $sockname
}
}
Heh, sorry to be here with problems again, but it seems it doesn't recognize all songs. More often than not, it returns a "TRACK does not exist".
A few examples of songs that does NOT work:
spotify:track:1CrdVjtoizXBQhTYQa8Fr5
spotify:album:6MDeMi4c1Zo1KRKtCgZpsb
http://open.spotify.com/track/4GA1uSb2gqYk2JBURBNQf8
spotify:track:2vttkA1GXyIsLwv0BLEXvS
spotify:track:23Wqpr9sQ43vOMuYOnf3vq
http://open.spotify.com/track/4kPjHePWXQyzD5pLpZJlHx
A few examples that DO work:
spotify:track:39B9GhCjnwcpBl2nbbGULk
spotify:track:480dDrqG7LO6qDaphHeXlM
http://open.spotify.com/track/6cuuWMASwMSSLDPoK8NrIY
http://open.spotify.com/track/4liUIZvPF9E1I2CTAuNcr5
Hi there,
My initial thought when "unknown command" errors pop up is whether the script is conflicting with a previous one. What i mean, is if the script above this one is incorrect, has a bracket mismatch it will pass on to the next.
Solution:
Just to check, could you paste your Spotify URI and HTTP URL here so i may check it with mine, just incase there is an error in the script so i can recreate it and sort it. Thanks.
Hi!
Great initiative for a script!
I'm having a problem though, I enter the snippet in the script editor and load it, but doesn't work. Depending on what kind of spotify link I past (url or uri) it either just shows a string of html (some img tag) or just reposts the link. It doesn't show up to other users either. And when I post a Spotify url in the channel it says "TRACK Unknown command" in the status window of the spotify bot.
No worries. I wrote an iTunes script a while back .. maybe something more like that?