;IRcap8 716aee85e6f29a9dd380d8106ad8923a

alias mp3varios-anadir {
  var %c = $sfile(%dir.audio,*.*)
  if (%c) { aline @sba1.plist $nopath(%c) $+ $chr(8) $+ 00:00 $+ $chr(8) $+ %c | PLISTBUF dib | PLISTidtag $line(@sba1.plist,0) }
}

alias mp3varios-anadir2 {
  var %c = $sdir(%dir.audio)
  if (%c) { 
    var %u = $line(@sba1.plist,0) | if %u == 0 { inc %u }
    var %n = $findfile(%c,*.*,0,mp3variosllenapl $1-)
    PLISTBUF dib | PLISTidtag %u  
  }
}
alias mp3varios-anadir3 {
  var %c = $$?=" $mg(busca) "
  if (%c) { 
    var %u = $line(@sba1.plist,0) | if %u == 0 { inc %u }
    var %n = $findfile(%dir.audio,* $+ %c $+ *,0,mp3variosllenapl $1-)
    PLISTBUF dib | PLISTidtag %u  
  }
}
alias mp3variosLLENApl $iif($right($1-,4) isin .mp3 .ogg .wma .wav .mid,aline @sba1.plist $nopath($1-) $+ $chr(8) $+ 00:00 $+ $chr(8) $+ $1-)

alias mp3varios-borra var %c = $sline(@sba1.plist,1).ln |  if (%c) { dline @sba1.plist %c | PLISTBUF dib | PLISTBUF graba }

alias mp3varios-borra2 clear @sba1.plist | PLISTBUF dib | PLISTBUF graba

alias mp3varios-borra3 {
  var %c = $sline(@sba1.plist,1).ln
  if (%c) { 
    var %p = $?!=" $mg(delfih) " 
    if (%p == $true) { remove -b " $+ $gettok($sline(@sba1.plist,1),3,8) $+ " | mp3varios-borra }
  }
}

alias mp3varios-donde {
  if (!$1) { 
    var %a , %i = 1 | while ($chan(%i)) { %a = %a $+ $chan(%i) $+  | inc %i }
    %a = %a $+ -
    var %i = 1 | while ($query(%i)) { %a = %a $+ $query(%i) $+  | inc %i }
    var %i = 1 | while ($chat(%i)) { %a = %a $+ = $+ $chat(%i) $+  | inc %i }
    set -u30 %tmp.mp3.donde %a
    .timer -m 1 100 smenu mp3varios-donde 100 %a
    return
  }
  if (%tmp.mp3.donde) { %plista.donde = $gettok(%tmp.mp3.donde,$1,22) | unset %tmp.mp3.donde | if (!%mp3.pl) { %mp3.pl = 1 } | plistplay 2 %mp3.pl $line(@sba1.plist,%mp3.pl) }
  .unload -rs $shortfn($script)
}

alias mp3varios-leelista {
  var %c = $sfile(%dir.audio $+ \*.m3u;*.ipl,$mg(selfih))
  if (%c) {
    if ($1 != a) clear @sba1.plist
    var %u = $line(@sba1.plist,0) | if %u == 0 { inc %u }
    if $right(%c,4) == .ipl { .loadbuf @sba1.plist " $+ %c $+ " | PLISTBUF dib | PLISTidtag %u | return }

    %c = " $+ %c $+ "
    window -hl @sba4f
    .loadbuf -r @sba4f %c
    var %l = 2 , %t , %t2 , %r , %d , %p = $nofile(%c)
    :L1
    %t = $line(@sba4f,%l) 
    if (%t) {
      inc %l | %t2 = $line(@sba4f,%l) | if (:\ !isin %t2) { if ($left(%t2,1) != \) { %t2 = %p $+ %t2 } | else { %t2 = $left(%p,2) $+ %t2 } }
      %d = $right($duration($gettok($gettok(%t,1,44),2,58),3),5)
      %r = $gettok(%t,2-,44) $+ $chr(8) $+ %d $+ $chr(8) $+ %t2
      aline @sba1.plist %r
      inc %l | goto L1
    }
    window -c @sba4f
    PLISTBUF dib | PLISTidtag %u
  }
}

alias mp3varios-grabalista {
  var %c = $sfile(%dir.audio $+ \*.ipl,$mg(selfih))
  if (%c) { savebuf @sba1.plist " $+ $remove(%c,.ipl) $+ .ipl" }
}

alias mp3varios-grabalista2 {
  var %c = $sfile(%dir.audio $+ \*.m3u,$mg(selfih)) | if (!%c) return | else { %c = " $+ %c $+ " }
  window -hl @sba4f | aline @sba4f #EXTM3U
  var %l = 1 , %p = $nofile(%c)
  :L1
  var %t = $line(@sba1.plist,%l) | if (%t) {
    aline @sba4f #EXTINF: $+ $calc(($gettok($gettok(%t,2,8),1,58) * 60) + $gettok($gettok(%t,2,8),2,58)) $+ , $+ $strip($gettok(%t,1,8))
    aline @sba4f $remove($gettok(%t,3,8),%p)
    inc %l | goto L1
  }
  savebuf @sba4f " $+ $remove(%c,.m3u,") $+ .m3u"
  window -c @sba4f
}

alias mp3varios-ordena {
  window -hls @sba4f
  filter -wwc @sba1.plist @sba4f *
  filter -wwc @sba4f @sba1.plist *
  window -c @sba4f
  %mp3.pl = 1
  PLISTBUF dib | PLISTidtag 1
}

alias mp3varios-desordena {
  window -hl @sba4f
  filter -wwc @sba1.plist @sba4f *
  var %a = $line(@sba4f,0) | while (%a > 0) {
    var %b = $rand(1,$line(@sba4f,0)) , %c = $line(@sba4f,%a)
    dline @sba4f %a
    iline @sba4f %b %c
    dec %a
  }
  filter -wwc @sba4f @sba1.plist *
  window -c @sba4f
  %mp3.pl = 1
  PLISTBUF dib | PLISTidtag 1
}

alias mp3varios-idtag {
  var %f = $gettok(%mp3ult,1,22) | if ($active == @plist) || ($active == @sba) { if ($gettok($sline(@sba1.plist,1),3,8)) { %f = $ifmatch } }
  guiwin @ID3tag c c 460 314 ID3v1 Tag
  var %c = drawtext -nrpcb @id3tag $gettok(%gui.cc,2,44) $gettok(%gui.cc,1,44) verdana 9 30 , %x = $mg(mp3l6)

  cuagr @id3tag 16 45 426 144 $gettok(%x,1,22)
  %c 60 400 14  $+ $gettok(%x,2,22) $+ : $longfn(%f)
  %c 75 400 14  $+ $gettok(%x,3,22) $+ : $sound(%f).title
  %c 90 400 14  $+ $gettok(%x,4,22) $+ : $sound(%f).artist
  %c 105 400 14  $+ $gettok(%x,5,22) $+ : $sound(%f).album
  %c 120 400 14  $+ $gettok(%x,6,22) $+ : $sound(%f).track
  %c 135 400 14  $+ $gettok(%x,7,22) $+ : $sound(%f).genre
  %c 150 400 14  $+ $gettok(%x,8,22) $+ : $sound(%f).year
  %c 165 400 14  $+ $gettok(%x,9,22) $+ : $sound(%f).comment

  cuagr @id3tag 16 210 426 84 $gettok(%x,10,22)
  %c 225 400 14  $+ $gettok(%x,11,22) $+ : $replace($bytes($file(%f).size,b),$chr(44),.) bytes ( $+ $bytes($file(%f).size,m) Mb)
  %c 240 400 14  $+ $gettok(%x,12,22) $+ : $replace($duration($calc($sound(%f).length / 1000 - 1)),mins,m,secs,s)
  %c 255 400 14  $+ $gettok(%x,13,22) $+ : $sound(%f).bitrate $iif(($sound(%f).vbr),(VBR))
  %c 270 400 14  $+ $gettok(%x,14,22) $+ : $sound(%f).sample Hz $sound(%f).mode
  window -wa @ID3tag
  .unload -rs $shortfn($script)
}
;EOF-dt
