Music Search Script

By FordLawnmower on Jun 01, 2009

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 
}

Comments

Sign in to comment.
Somsubhra1   -  Jan 23, 2016

I think this script needs some update... No results shown.

[19:35:30] !music hello
[19:35:32] -RadishBot- Searching........

 Respond  
ovelayer   -  Nov 26, 2014

can i request an update please it stopped working.
ty

 Respond  
FordLawnmower   -  Mar 19, 2011

Updated Working again.

 Respond  
jasonh   -  Mar 19, 2011

i used to love this script, but it no longer works for me.
running mirc v7.19

is this no longer working because they require an api key or am i doing something wrong?

 Respond  
Jethro   -  Dec 26, 2010

Ford, will you be around for the next 50 years to maintain your socket scripts? :p

 Respond  
FordLawnmower   -  Dec 26, 2010

Old code updated and working fine again :)

 Respond  
FordLawnmower   -  Nov 17, 2009

Thanks JDavis :)

 Respond  
JDavis   -  Nov 17, 2009

Sweet Script Ford.. Very Nice.. Works like a charm..

 Respond  
_Daniel_   -  Jun 03, 2009

}{exer I know that..

 Respond  
FordLawnmower   -  Jun 03, 2009

Thank you Cheiron :)

 Respond  
Cheiron   -  Jun 03, 2009

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

 Respond  
FordLawnmower   -  Jun 01, 2009

@Daniel Judging from YOUR posts here, I'm guessing that the mindforge part was all you could comprehend :P

Thanks }{exer :)

 Respond  
}{exer   -  Jun 01, 2009

Hello Ford :))

Nice Script what you make it works perfect :))

Daniel , this Script runs on all other Networks too.
Mindforge is a Network who you can find Ford for possible Questions !

 Respond  
_Daniel_   -  Jun 01, 2009

I dont like that code FordLawnmower only cuz mindforge sucks :D

 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.