Last.fm Now Playing

I know there are tons of now playing scripts, but because last.fm now shows the currently playing song I figured I'd make this one for last.fm. Also I really wanted to make one for Pandora but couldn't figure out how to (if anyone can/does please let me know) and this works while I listen to Pandora because of a Firefox add-on I have.

Anyway, please give me suggestions/feedback :)

By the way: Last.fm will randomly not update the currently playing song every once in a while. If the script gets the song wrong it's because of last.fm, not the script. It grabs whatever is on your last.fm profile at the moment you use the /np alias.

To use:
-Set your username when you load the script or use the alias /lastfm nickname to set it
-Use the alias /np to describe your current song according to last.fm

I would need to read up on it. and I read the TCP socket indtroduction on the forums... and It explained a few things to me. I understood what they do. but it didn't give me the information to understand how to script it effectively. It gave examples on how to join a server. well I thought that is what the /server was for. Granted doing it as an alias you could do /name and have it automatically join that server. or you could do a menu to do that also. Personally I don't think it explained what is needed to know with sockets as effective as it could of.

KillerX, why don't you set out to write one on your own? It's not hard to make a socket script using GET. Give it a try yourself and if you have an issue with it, you can post your work at the forum, I'm sure napa, dean or whoever and I would be glad to help you out.

tv3636, I'm not sure why you put this line of code:> sockread %last.fm | sockread %last.fm | sockread %last.fmwhen it's not necessary and can be omitted?

Well not saying you personally have to. I tried changing around some Alias. using a bnp. and using a write /buy /1 /2 Which I want it to write to the $scriptdirc a new folder /buy the file name would be the artist name (or /1) and then it would list the songs inside that file. But It didn't work. so I deleated it. even if this could be rewritten to do that.

Well, regardless, I have a macbook at college with me and I actually don't even have my own PC at home anymore, so I probably won't be doing any mIRC scripting for a very long time...if ever. I would be open to doing bug fixes but I don't think I'll be adding that, sorry.

(personally has 157 pages) I doubt I want to go though those looking for how long ago I played them. And sometimes I am to lazy to write it out myself. So I miss a song then. Would be nice to be able to just /bfm and have it write down the song title and artist. So I can get it from Itunes or last.fm or where-ever I decide to grab it from.

I could add that, but Last.fm already does that. If you're using this script, you already have that information. Go to your last.fm profile, click on the list of artists, and you can then click on an artist to see a chart of which songs you've listened to and how many times you've listened to each one.

Yeah, I noticed that too after seeing %last.fm in my variables all the time.
Code updated in a few ways, I shortened it a lot with regex, which I now know how to use. (kind of) If you have a better regex match for me let me know.
Also added an error message if no currently playing song is detected, meaning last.fm doesn't have one on the page.

minor update to deal with ampersands (&) ..I'm not sure what other weird characters would show up as code but if anyone has any instances (like & showed up as &) let me know and I can add a $replace to deal with them

Cheiron, you don't need to set a variable for the sockread as you did here:

var %t
sockread %t

; it can just be

sockread %t

.

tv3636: /tokenize is basically using bits of things (such as $sock($sockname).mark or variables), which you can turn into identifiers, such as $1, $2, $3, depending on the number of contents you have in a set. Like the name, you get the $1, $2, $3 through the token number.
So if I have

/sockmark obama $active $nick($chan,$r(1,$nick($chan,0)))

, since those two are separated by $chr(32), I can use /tokenize 32 $sock($sockname).mark to make $1 the $active, and $2 the $nick($chan,$r(1,$nick($chan,0))).

Oops, %sockreader was what it was originally called and then I switched it to %last.fm.

I guess I could switch it to sockmark..does it really increase efficiency or anything or just cuts down on variable usage?

And I don't really understand/want to get into tokens yet but thank you very much for the suggestions.

Edit: Also, if anybody has an idea for an automatic version of this please let me know. I don't have a use for it personally so I don't care that much, but I could try to add that in if possible. Because there isn't readily available song length data I don't think it would be very easy to do if it could be done at all, but if somebody wanted to find out I'd be interested to hear.

What's very useful about sockmark is that you can limit your usage on variables. /tokenize works very well with it too, if you have multiple items you want to sockmark. With sockmarking, you can jam bits of information for useful purposes.
The

halt

in the $sockerr is unecessary because you have an else { after it, and the

var %sockreader

is unecessary as well because I do not see other place in which it is used.
Good to see some regex too.