I ran across tinysong.com's api page last night so I decided to use it in a script.
This script uses tinysong's api to search Grooveshark.com for a artist/songname.
The script will return from 0 to 3 results in the form of songname - artistname - album - link
This is a script to load in to your bot. There are no dialogs at this time.
Type +tinymusic to turn the script on in a channel (Requires ops)
Triggers - @music search terms - @ is a public trigger that responds with a channel message and requires ops by default.
Triggers - !music search tearms - ! is a private trigger that responds with notice. The restriction on this trigger is one use per 10 seconds.
Note will also respond to !song, !tinysong, !tinymusic
There is a on/off switch for the triggers on the Channel,Status menus.
;Tinysong search by Ford_Lawnmower irc.geekshed.net #Script-Help
menu Channel,Status {
.$iif($group(#tinysong) == On,$style(1)) tinysong Trigger
..$iif($group(#tinysong) == On,$style(2)) On: .enable #tinysong
..$iif($group(#tinysong) == Off,$style(2)) Off: .disable #tinysong
}
#tinysong on
On $*:Text:/^(\+|-|!|@)(tiny)?(song|music).*/Si:#: {
var %action $regml(1)
if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
if (%action == +) {
if ($istok(%tinysongChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the tinysong script }
else {
.enable #tinysong
Set %tinysongChanList $addtok(%tinysongChanList,$+($network,$chan),32)
.msg $chan $nick has activated the tinysong script for $chan .
}
}
else {
if (!$istok(%tinysongChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the tinysong script }
else {
Set %tinysongChanList $remtok(%tinysongChanList,$+($network,$chan),1,32)
.msg $chan $nick has deactivated the tinysong script for $chan .
}
}
}
elseif (!$timer($+(tinysong,$network,$nick))) && ($istok(%tinysongChanList,$+($network,$chan),32)) {
.timer $+ $+(tinysong,$network,$nick) 1 6 noop
var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%|\+)/),.msg $chan,.notice $nick))
Gettinysong %method $replace($strip($2-),$chr(32),+)
}
}
#tinysong end
alias tinysong { Gettinysong echo -a $replace($1-,$chr(32),+) }
alias -l Gettinysong {
$1-2 Searching........
var %sockname $+(tinysong,$network,$2,$ticks)
sockopen %sockname tinysong.com 80
sockmark %sockname $1-2 $+(/s/,$3,?limit=7&key=,$decode(NTM4MmJkM2Y3NjRhOWNmNzkzYmFiN2ExNGIxODkyZGQ=,m))
}
On *:sockopen:tinysong*: {
if (!$sockerr) {
sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
sockwrite -n $sockname Host: tinysong.com
sockwrite -n $sockname $crlf
}
else { sockclose $sockname | return }
}
On *:sockread:tinysong*: {
if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
else {
var %tinysong | sockread %tinysong
if (%tinysong == Content-Length: 4) $gettok($sock($sockname).mark,1-2,32) Nothing found! Please refine your search and try again!
elseif ( http:// isin %tinysong) {
tokenize 59 %tinysong
put $gettok($sock($sockname).mark,1-2,32) Song = $3 by $5 from the album $7 $+(,,$1)
}
}
}
alias -l Put {
if (!$regex($1,/(\.|^)(msg|notice|echo)$/Si)) || (!$3) { echo -st **Put error** Syntax /Put msg #channel text - or - /Put notice nickname text | return }
tokenize 32 $regsubex($1-,/([$\|%\[\]\}\{][^\s]*)/g,$+($chr(2),$chr(2),\t))
var %tokens $0, %Tstart 3, %Dtimer 1500
if ($timer($+(Put,$2,$network)).secs) { %Dtimer = $calc($v1 * 1000) }
while ($len($($+($,%Tstart,-,%tokens),2)) > 430) {
dec %tokens
if ($len($($+($,%Tstart,-,%tokens),2)) <= 430) {
.timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
inc %Dtimer 1500
%Tstart = $calc(%tokens + 1)
%tokens = $0
}
}
.timer -m 1 %Dtimer $1-2 $($+($,%Tstart,-,%tokens),2))
.timer $+ $+(Put,$2,$network) -m 1 $calc(%Dtimer + 1500) noop
}
nice script. might be worth looking at amazon.com or play.com or something for the purchase of song/album links for a possible update but as it is.. very very good
!playing Current Song playing on Titan Sounds Radio: Marcia Ball Angela Strehli & Lou Ann Barton - A Fool in Love http://s8.viastreaming.net/7380/ @music marcia ball Song = Watermelon Time by Marcia Ball from the album Peace http://tinysong.com/4ycX Song = You Make Me Happy by Marcia Ball from the album Presumed Innocent http://tinysong.com/4ycY Song = Scene Of The Crime by Marcia Ball from the album Presumed Innocent http://tinysong.com/4ycZ
gets a thumping 9 and a like