All pastes #745223 Raw Edit

Stuff

public text v1 · immutable
·published 2007-10-22 04:49 UTC
rendered paste body
/*
commandline mp3
ver. :  v1.8
by   :  nonane (zach@sharpnet.net/nonane x)
date :  5-16-05
*/
on *:load:c

; Command Reference
; /mp3 -r        = Random - Plays a random mp3 from your collection.
; /mp3 -c        = Cache  - Recaches mp3s from the selected mp3dir.
; /mp3 -p <song> = Play   - Plays random match of <song>
; /mp3 -q <song> = Play   - Quietly plays random match of <song>.
; /mp3 -s <song> = Search - Opens up a search window for matches of <song>.
; /mp3 -x        = Stop   - Stops the currently playing song if any.
; /mp3 -d        = Dir    - Changes the MP3 Directory.
;
; Note: In search windows [/mp3 -s <song>] you can enter more search terms in the editbox.
; [ex:  /mp3 -s linkin park , then enter "session" (without quotes), and hit enter]

alias -l cmp3.ec return $color(echo)
alias -l cmp3.listfile return $+(",$scriptdirlist.txt,")
alias -l cmp3.matchfile return $+(",$scriptdirmatches.txt,")
alias -l cmp3.info return $iif($mp3($1-).artist && $mp3($1-).title,1,0)
alias -l cmp3.tag return $iif($cmp3.info($1-)," $+ $lower($mp3($1-).title) $+ " by $lower($mp3($1-).artist),$lower($cmp3.rplc($1-)))
alias -l cmp3.rplc return $lower($remove($replace($nopath($1-),-,$+($chr(32),-,$chr(32)),-_-,$chr(32),_-_,$+($chr(32),-,$chr(32)),_,$chr(32)),.mp3,(1)))
alias -l cmp3.err echo $cmp3.ec * Error :: You have not $1-
alias -l cmp3.win window -lekd $1
alias -l cmp3.srchsel return $sline(@MP3Search,$sline(@MP3Search,0).ln)
alias -l cmp3.timefmt return $asctime($calc($sound($1-).length / 1000),n:ss)
alias -l c {
  if ($version < 6.14) { 
    echo $cmp3.ec * You need mIRC 6.14 to use this version of my mp3 player. 
    .unload -rs $script
  } 
  else { 
    .fclose * 
    .remove $cmp3.listfile 
    unset %mp3.d
    mp3 -d
  }
}
alias _cache {
  .remove $cmp3.listfile
  .fopen -n a $cmp3.listfile
  var %z = $findfile(%mp3.d,*.mp3,0,.fwrite -n a $+(",$1-,"))
  .fclose a
  echo $cmp3.ec * List generation complete. $+(,$lines($cmp3.listfile),) mp3s cached.
}

alias mp3 {
  if ($1 == -c) {
    if (!%mp3.d) { cmp3.err setup your mp3 directory. Please type /mp3 -d | halt }
    _cache
  }
  if ($1 == -d) {
    %mp3.d = $+(",$sdir(c:\,Where are your MP3s?),")
    linesep -
    echo -a * MP3 Directory Set: $+(,%mp3.d,)
    echo -a * Auto Caching .. Type /mp3 -c to manually recache your mp3 collection.
    _cache
  }
  if ($1 == -r) {
    if (!$len(%mp3.d)) { cmp3.err setup your mp3 directory. Please type /mp3 -d | halt }
    var %i $read($cmp3.listfile),%d $iif($cmp3.info(%i),$cmp3.tag(%i),$cmp3.rplc(%i))
    splay %i
    $iif($server,$iif($active ischan,describe $active randomly plays,echo -a *),echo -a *) $+(,%d,) $+($chr(40),$cmp3.timefmt(%i),$chr(41))
  }
  if ($1 == -s) {
    if (!$2-) { cmp3.err supply a search parameter. use /mp3 -s <song> | halt }
    if (!%mp3.d) { cmp3.err setup your mp3 directory. Please type /mp3 -d | halt }
    var %s $+(*,$replace($2-,$chr(32),*),*),%w @MP3Search
    cmp3.win %w
    .filter $cmp3.listfile %w %s
    .titlebar %w :: $line(%w,0) matches found for $+(",$2-,")
  }
  if ($1 == -p) {
    if (!%mp3.d) { cmp3.err setup your mp3 directory. Please type /mp3 -d | halt }
    var %s = $+(*,$replace($2-,$chr(32),*),*)
    .filter -ff $cmp3.listfile $cmp3.matchfile %s
    var %b = $lines($cmp3.matchfile)
    if (!%b) { echo -a No matches found | halt }
    var %i $read($cmp3.matchfile),%d $iif($cmp3.info(%i),$cmp3.tag(%i),$cmp3.rplc(%i)),%c $readn
    .remove $cmp3.matchfile
    splay %i
    $iif($server,$iif($active ischan,describe $active plays,echo -a *),echo -a *) $+(,%d,) $+($chr(40),$cmp3.timefmt(%i),$chr(41))
  }
  if ($1 == -q) {
    if (!%mp3.d) { cmp3.err setup your mp3 directory. Please type /mp3 -d | halt }
    var %s = $+(*,$replace($2-,$chr(32),*),*)
    .filter -ff $cmp3.listfile $cmp3.matchfile %s
    var %b = $lines($cmp3.matchfile)
    if (!%b) { echo -a No matches found | halt }
    var %i $read($cmp3.matchfile)
    .remove $cmp3.matchfile
    splay %i
  }
  if (($1 == -x) && ($insong.fname)) splay stop
}
menu @MP3Search {
  dclick:{
    var %a = $cmp3.srchsel  | .signal -n m %a
  }
  $style(0) $cmp3.rplc($cmp3.srchsel )
  -
  $iif($cmp3.srchsel ,Control)
  .Play:{ var %a = $cmp3.srchsel  | .signal -n m %a }
  .Silent Play:splay $cmp3.srchsel 
  $iif($cmp3.srchsel ,File)
  .Send to...:dcc send -l0 $$?="Send to who?" $cmp3.srchsel 
  .-
  .Open Directory:run $nofile($cmp3.srchsel )
  .-
  $iif($cmp3.srchsel  && $sound($cmp3.srchsel ).artist,ID3)
  .Artist.. $chr(9) $sound($cmp3.srchsel ).artist:echo
  .Title..  $chr(9) $sound($cmp3.srchsel ).title:echo
  .Album..  $chr(9) $sound($cmp3.srchsel ).album:echo
}
on *:signal:m:{
  var %a @MP3Search,%b $1-
  if (%b) {
    var %desc $iif($cmp3.info(%b),$cmp3.tag(%b),$cmp3.rplc(%b))
    splay %b
    $iif($server,ame selectively plays,echo -a *) $+(,%desc,) $+($chr(40),$cmp3.timefmt(%b),$chr(41))
  }
}
on *:INPUT:@MP3Search:{
  var %a $1-,%b @MP3Search
  .filter -cww %b %b $+(*,$replace($remove(%a,*,?),$chr(32),*),*)
}
menu channel,query,status {
  MP3 Player
  .Play
  ..Match Play:mp3 -p $$?="What do you want to play?"
  ..Random Play:mp3 -r
  .$iif($insong.fname,Stop):mp3 -x
  .-
  .Search:mp3 -s $$?="What file to search for?"
  .-
  .Help:mp3 -h
  .Set Directory:mp3 -d
}