[mIRC] Spotify link checker [v1.4.0]

By Jonesy44 on Feb 14, 2010

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
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
  }
}

Comments

Sign in to comment.
Jonesy44   -  Jun 07, 2011

Updated. The XML had changed.

 Respond  
Jonesy44   -  Jun 07, 2011

Yep.. You'll need to send me a link and URI because I don't use Spotify anymore. :(

 Respond  
Henco   -  Jun 07, 2011

Spotify have changed their API recently, and I think that has stopped this working.. could you take a look please?

 Respond  
Jonesy44   -  Dec 14, 2010

Mint.

 Respond  
MixXeduP   -  Dec 14, 2010

Wow, Awesome jonesy44.

 Respond  
Jonesy44   -  Dec 14, 2010

Fixed, they changed their metadata.

MixXeduP: Done.

 Respond  
MixXeduP   -  Dec 14, 2010

Jonesy44: Can u maybe add the album of the tracks?

 Respond  
Jonesy44   -  Dec 14, 2010

No way around that problem (using mIRC, anyways) you'll just have to run the script.

I'll see what I can do about the updates.

 Respond  
MixXeduP   -  Dec 13, 2010

They do?
But i mean i wan't my IRCbot. 24/7 :P

 Respond  
cupcake   -  Dec 13, 2010

MixXedup ..go to forum, Mirc scripting tell them what you need...sure someone would be glad to help and show you how to make and set up a bot. Some great scriptors on this site. All you have to do is ask :D

 Respond  
MixXeduP   -  Dec 13, 2010

I like it,
Damn i wan't a 24/7 mIRC bot. :(

 Respond  
Dark|   -  Dec 12, 2010

Nice job
xd

 Respond  
Cyborgmatt   -  Dec 12, 2010

I noticed the script is only returning the track title now, is there any chance you could do a quick update for the new layout the Spotify website is using now.

 Respond  
Jonesy44   -  Nov 22, 2010

Yep, sorry I can't help there!

 Respond  
b0sse   -  Nov 22, 2010

That's too bad :(

 Respond  
Jonesy44   -  Oct 19, 2010

Yeah if you're good with COM objects. I am not :(

 Respond  
b0sse   -  Oct 19, 2010

Is it possible to make a script like the dozens of winamp scripts out there but for spotify?

so you can right click in channel and press "display song info".
So it will display to the channel what song you are currently playing in your spotify.

 Respond  
Jonesy44   -  May 09, 2010

All of the links you provided there worked for me;

[Spotify TRACK] Midlife Crisis - Faith No More
[Spotify TRACK] It Flies Again - Fireball Ministry
[Spotify TRACK] Holy Diver - Dio
[Spotify TRACK] Fireball - Deep Purple

try;

/unset %Spotify.Search.*
 Respond  
Exterus   -  May 07, 2010

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

 Respond  
Jonesy44   -  May 06, 2010

Cheers for picking that one up, edited it. Should be all good now.

 Respond  
Exterus   -  May 06, 2010

Awesome! Thanks a lot. :)

Though one small thing, when posting the Spotify URI it just echoed the band and title, it didn't msg it to the channel. But that was easily fixed, even for someone code-challenged such as myself. ;)

Thanks again, great work!

 Respond  
Jonesy44   -  May 06, 2010

All fixed. Paste the new script over the old one :) The spotify page had changed completely lol.

 Respond  
Exterus   -  May 06, 2010

A friend of mine tried to load the script as well, but even though the script seemed to load successfully, we didn't even get to use the "/spotify on" command there. "SPOTIFY Unknown command", etc.

I have checked that all the code is there and all that.

 Respond  
Exterus   -  May 05, 2010

Hi again!

After a couple of reinstalls, the track unknown command doesn't show up anymore. But the odd html tag still shows up.

Here's a screenshot (including some spotify urls and uris):

http://pics.reprobate.se/files/100506/4268spot.jpg

 Respond  
Jonesy44   -  May 05, 2010

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:

  • Remove any trace of this script you have from your mIRC remotes file (ALT+R)
  • Create a new script, File -> New
  • Paste the entire script, ensuring you have highlighted all of it in, then press OK

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.

 Respond  
Exterus   -  May 04, 2010

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.

 Respond  
Jonesy44   -  Feb 14, 2010

No worries. I wrote an iTunes script a while back .. maybe something more like that?

 Respond  
Pangaea   -  Feb 14, 2010

actually ya know your right, after reading the script description again i realise what im talking about is completely unrelated.. sorry, tired long weekend

 Respond  
Jonesy44   -  Feb 14, 2010

I'm not familiar with that.. But i think that what you describe would be a different script entirely. If you could provide a DLL or COM hook, i'd be happy to write the snippet from there on.

 Respond  
Pangaea   -  Feb 14, 2010

looks good,

are you familiar with media monkey? the player used within it is winamp based but it dosent seem to work with regular "now playing" scripts.. would it be possible to make one simple one for it?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.