mp3 playlist/html generator
Posted by w.e
Monday, May 02, 2005
Description: cool?


on *:load: {
  mkdir junk
}
dialog playlist {
  title "Play list Generator"
  size -1 -1 308 211
  option dbu
  tab "Generate", 1, 3 4 301 191
  edit "", 4, 6 33 245 10, tab 1
  text "Play List DIR:", 5, 7 25 34 8, tab 1
  button "Browse", 6, 253 33 37 10, tab 1
  edit "", 10, 9 100 289 87, tab 1 multi hsbar vsbar
  box "Console", 11, 6 91 295 100, tab 1
  button "Generate", 13, 7 43 37 12, tab 1
  tab "Play List", 2
  edit "", 14, 5 18 298 176, tab 2 multi hsbar vsbar
  tab "HTML", 3
  link "Your site", 15, 144 104 22 8, tab 3
  tab "M3U / winamp", 33
  link "Launch winamp", 22, 144 104 22 8, tab 33
  button "Done/OK", 7, 137 198 37 12, ok cancel
}

on *:dialog:playlist:sclick:6: {
  set %sdir $sdir(select dir)
  set %songs = $findfile(" $+ %sdir $+ ",*.mp3,0)
  if (%songs == 0) {
    var %errormsg = $input(Invalid DIR!,o) | halt
  }
  if (%songs == 1) {
    set %songss Song
  }
  else {
    set %songss Songs
  }
  did -ra playlist 4 %sdir
  set %sdir $did(playlist,4)
}
on *:dialog:playlist:sclick:13: {
  set %sdir $did(playlist,4)
  generateplaylist
}
menu channel,status,menubar {
  mp3 Playlist creator:
  .Platlist Generator: dialog -m playlist playlist
  .M3U Player: dialog -m mp3player mp3player  
}
alias generateplaylist {
  unset %lastdr
  var %x = 1
  while (%x <= $fopen(0)) {
    if ($fopen(%x) == playlist) {
      .fclose playlist
    }
    inc %x
  }
  did -a playlist 10 This could be up to 10 minutes. $crlf
  .fopen -o playlist " $+ $scriptdirplaylist.html $+ "
  var %i 1
  set %ticks $ticks
  unset %totaltime
  .btrunc playlist.m3u 0
  .write playlist.m3u #EXTM3U
  .fwrite playlist <style type="text/css">
  .fwrite playlist <!--
  .fwrite playlist body $chr(123)
  .fwrite playlist     background-color: #BFBFBF;
  .fwrite playlist $chr(125)
  .fwrite playlist .style3 $chr(123)
  .fwrite playlist     color: #000000;
  .fwrite playlist     font-weight: bold;
  .fwrite playlist $chr(125)
  .fwrite playlist body,td,th $chr(123)
  .fwrite playlist     font-family: Verdana, Arial, Helvetica, sans-serif;
  .fwrite playlist     font-size: 9px;
  .fwrite playlist     color: #000000;
  .fwrite playlist $chr(125)
  .fwrite playlist a:link $chr(123)
  .fwrite playlist     color: #999999;
  .fwrite playlist     text-decoration: none;
  .fwrite playlist $chr(125)
  .fwrite playlist a:visited $chr(123)
  .fwrite playlist     color: #333333;
  .fwrite playlist     text-decoration: none;
  .fwrite playlist $chr(125)
  .fwrite playlist a:hover $chr(123)
  .fwrite playlist     color: #999999;
  .fwrite playlist     text-decoration: none;
  .fwrite playlist $chr(125)
  .fwrite playlist a:active $chr(123)
  .fwrite playlist     color: #999999;
  .fwrite playlist     text-decoration: none;
  .fwrite playlist $chr(125)
  .fwrite playlist -->
  .fwrite playlist </style><title>Playlist Generator v. 1.1 - Created by wnr|reg @ #wetnoseradio</title> Total Files in "<b> $+ %sdir $+ </b>" <br><br>
  set %percent 1
  .set %songg 0
  set %#files $findfile(%sdir,*.mp3,0)
  .fwrite playlist <br>Total files: <b> $+ $findfile(%sdir,*.mp3,0,writepl $1-) </b>
  totaltime
  secondsgen
  .fwrite playlist <br>Download: <b><a href="http://scriptsurge.org/744">www.scriptsurge.org/744</a>
  .fclose playlist
  run $scriptdirplaylist.html
  did -a playlist 10 Playlist Generation Complete. $crlf
}
alias writepl {
  inc %songg
  var %songprogress = $calc(%songg / %#files * 100)
  var %i 1
  while (%i <= 100) {
    if (%songprogress > %percent) {
      did -a playlist 10 %percent $+ % completed. $crlf
      inc %percent
    }
    inc %i
  }
  .fwrite playlist <b> $+ %songg $+ </b> $+ . $nopath($1- ( $+ $gmt($calc($sound($1-).length / 1000),nn:ss) $+ )<br>)
  .write playlist.m3u #EXTINF: $+ $sound($1-).length $+ , $nopath($1-)
  .write playlist.m3u $1-
  writedialog $1-
  inc %totaltime $calc($sound($1-).length / 1000)
}
alias writedialog {
  did -a playlist 14 %songg $+ . $nopath($1- ( $+ $gmt($calc($sound($1-).length / 1000),mm:dd:nn:ss) $+ ) $+ $crlf $+ )
}
alias totaltime {
  .fwrite playlist <br>Total time:<b> $gmt(%totaltime,dd:nn:ss) $+ </b>
  .fwrite playlist <br>Stats:<b> $gettok($calc(%totaltime / 31449600),1,46) Years about $gettok($calc( %totaltime / 108000 ),1,46) Months $gettok($calc(%totaltime / 86400),1,46) Days $gettok($calc( ( %totaltime / 3600 ) - (24 * $gettok($calc(%totaltime / 86400),1,46) ) ),1,46) Hours $gmt(%totaltime,nn) minutes and $gmt(%totaltime,ss) Seconds of Music's and %#files MP3s in " $+ %sdir $+ *."</b>
  ame Damn, I have $gettok($calc(%totaltime / 31449600),1,46) Years about $gettok($calc( %totaltime / 108000 ),1,46) Months $gettok($calc(%totaltime / 86400),1,46) Days $gettok($calc( ( %totaltime / 3600 ) - (24 * $gettok($calc(%totaltime / 86400),1,46) ) ),1,46) Hours $gmt(%totaltime,nn) minutes and $gmt(%totaltime,ss) Seconds of Music's and %#files MP3s in " $+ %sdir $+ *."
}
alias secondsgen {
  .fwrite playlist <br>Time taken to generate: <b> $+ $duration($calc(($ticks - %ticks) / 1000)) </b>
}
on *:dialog:playlist:sclick:15: {   run $scriptdirplaylist.html }
on *:dialog:playlist:sclick:22: {   run playlist.m3u }
dialog mp3player {
  title "MP3 Player - wnr|reg"
  size -1 -1 186 168
  option dbu
  edit "", 1, 85 13 93 10
  box "Playlist", 3, 4 33 178 105
  box "Now Playing", 2, 81 3 101 27
  box "Options", 4, 4 3 73 27
  button ">", 6, 22 12 11 12, default
  button "||", 7, 35 12 11 12
  button "", 10, 48 12 11 12
  button "Load Playlist / M3U's only.", 5, 40 123 100 12
  list 11, 9 42 168 78, size hsbar vsbar
  button "Done", 12, 2 154 37 12, ok cancel
  button "Uninstall", 13, 147 154 37 12
  text "Made by wnr|reg to go along with HTML / M3U mp3 generator.", 14, 43 151 102 14
  button ">|", 8, 61 12 11 12
  button "|<", 9, 9 12 11 12, default
}
on *:dialog:mp3player:sclick:5: {
  btrunc m3uplayer.ini 0
  did -r mp3player 11
  set %m3ufile $sfile(*.m3u,M3U only.,Select)
  var %x 1
  while (%x <= $lines(%m3ufile)) {
    if ($left($read(%m3ufile,%x),1) == $chr(35)) { inc %x }
    else {    
      write "junk/ $+ $nopath($read(%m3ufile,%x))) $+ " $read(%m3ufile,%x)
      did -a mp3player 11 $nopath($read(%m3ufile,%x))
      inc %x
    }
  }
}
on *:dialog:mp3player:sclick:8: {
  splay seek $calc($insong.pos + 2000)
}
on *:dialog:mp3player:sclick:10: {
  splay stop
}
on *:dialog:mp3player:sclick:9: {
  splay seek $calc($insong.pos - 2000)
}
on *:dialog:mp3player:sclick:7: {
  splay pause
  set %pause 1
}
on *:dialog:mp3player:sclick:6: {
  if (%pause == 1) { splay resume | unset %pause }
  else {
    splay $read(junk/ $+ $did(mp3player,11).seltext,1)
    sc_start mp3player 1 60 r 60 $did(mp3player,11).seltext ( $+ $gmt($calc($sound($read(junk/ $+ $did(mp3player,11).seltext,1)).length / 1000),nn:ss) $+ ) $chr(32) *** mIRC m3u Loader - wnr|reg ***
  }
}
on *:dialog:mp3player:dclick:11: {
  splay $read(junk/ $+ $did(mp3player,11).seltext,1)
  sc_start mp3player 1 60 r 60 $did(mp3player,11).seltext ( $+ $gmt($calc($sound($read(junk/ $+ $did(mp3player,11).seltext,1)).length / 1000),nn:ss) $+ ) $chr(32) *** mIRC m3u Loader - wnr|reg ***
}
on *:dialog:mp3player:init:0: {
  sc_start mp3player 1 60 r 60 Nothing Playing.
}
alias sc_start {
  var %r return,%e echo $color(info) -ea * /sc_start:,%c did -r $1-2
  if $isid { %e incorrect usage | %r }
  if !$5 { %e insufficient parameters | %r }
  if !$dialog($1) { %e no such dialog | %r }
  if $4 != l && $4 != r { %e invalid direction | %r }
  var %x $timer(0)
  while %x {
    if $+(sc_,$1,_,$2,_*) iswm $timer(%x) { .timer $+ $ifmatch off | %c | break }
    dec %x
  }
  var %a did -a $1-2,%n $+($iif($4 = l,$6-),$chr(160),$iif($3 > $len($6-),$str($chr(160),$calc($3 - $len($6-)))),$iif($4 = r,$6-)),%x 1
  %a %n
  while %x <= $len(%n) {
    $+(.timersc_,$1,_,$2,_,%x) -m 1 $calc($5*%x) %c $chr(124) %a $right(%n,$iif($4 = l,-) $+ %x) $+ $left(%n,$iif($4 = r,-) $+ %x) $iif(!$calc($len(%n)-%x),$chr(124) sc_start $1-)
    inc %x
  }
}
on *:dialog:mp3player:close:*:$+(.timersc_,$dname,*) off | splay stop
on *:dialog:mp3player:sclick:13: {
  set %yesnoun $input(Are you sure?)
  if (%yesnoun == $FALSE) { halt }
  elseif (%yesnoun == $TRUE) { unload -rs " $+ $script(1) $+ " }
  echo Uninstalled.
}
Submit a comment
Oops! You need to login or register before you can post a comment!

ebaum's world