PlaylistGenerator — File Browser

PlaylistGeneratorv1.0 / PlaylistGeneratorv1.0 / playlistgenerator.mrc

playlistgenerator.mrc — 14.77 KB — Download this file

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;  PlaylistGenerator
;;  by bunkahumpa
;;  bh@scriptsurge.org
;;  irc.GameSurge.org #script
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

menu channel,status,query,menubar {
  PlaylistGenerator
  .mp3 Playlist:mp3playlist
  .m3u Playlist:m3uplaylist
  .pls Playlist:plsplaylist
}

alias -l maketok {
  ; by CrashB
  var %string $$1
  var %space $$2
  var %chr $$3
  var %i $len(%string)
  var %scount 0
  while %i >= 1 {
    if %scount == %space {
      var %new $chr(%chr) $+ %new
      var %scount 0
    }
    var %new $mid([ %string ],[ %i ],1) $+ %new
    inc %scount
    dec %i
  }
  return %new
}

alias mp3playlist {
  var %songdir = $sdir($gettok($mircdir,1,92) $+ \,Locate the directory where you mp3s are)
  if (!%songdir) {
    var %errormsg = $input(Please specify a directory!,o)
    return
  }
  var %songs = $findfile(" $+ %songdir $+ ",*.mp3,0)
  if (%songs == 0) {
    var %errormsg = $input(There are no songs in the directory specified or any of its subdirectories.,o)
  }
  else {
    var %songlengths = $input(Do you want to display the song lengths?,y)
    if (%songs == 1) {
      var %songsword = Song
    }
    else {
      var %songsword = Songs
    }
    var %x = 1
    while (%x <= $fopen(0)) {
      if ($fopen(%x) == playlist) {
        .fclose playlist
      }
      inc %x
    }
    echo -a Please Wait, Generating Playlist...
    var %ticks = $ticks
    .fopen -o playlist " $+ $scriptdirmp3playlist.html $+ "
    .fwrite -n playlist <head>  
    .fwrite -n playlist <title>My mp3 Playlist - generated by mIRC (by bunkahumpa)</title>
    .fwrite -n playlist </head>
    .fwrite -n playlist <body>
    .fwrite -n playlist <font face="verdana" size="3">
    .fwrite -n playlist My mp3 Playlist - generated by mIRC
    .fwrite -n playlist <br>
    .fwrite -n playlist <b> $+ %songs $+ </b> %songsword
    .fwrite -n playlist </font>
    .fwrite -n playlist <br>
    .fwrite -n playlist <font face="verdana" size="2">
    .fwrite -n playlist <ul>
    var %x = 1
    while (%x <= %songs) {
      var %songprogress = $calc(%x / %songs * 100)
      if ((%songprogress > 5) && (%songprogress <= $int(10))) {
        if (!%progress10) {
          var %progress10 = 1
          echo $color(text) -a Generating Playlist...about 10% complete.
        }
      }
      if ((%songprogress > 15) && (%songprogress <= $int(20))) {
        if (!%progress20) {
          var %progress20 = 1
          echo $color(text) -a Generating Playlist...about 20% complete.
        }
      }
      if ((%songprogress > 25) && (%songprogress <= $int(30))) {
        if (!%progress30) {
          var %progress30 = 1
          echo $color(text) -a Generating Playlist...about 30% complete.
        }
      }
      if ((%songprogress > 35) && (%songprogress <= $int(40))) {
        if (!%progress40) {
          var %progress40 = 1
          echo $color(text) -a Generating Playlist...about 40% complete.
        }
      }
      if ((%songprogress > 45) && (%songprogress <= $int(50))) {
        if (!%progress50) {
          var %progress50 = 1
          echo $color(text) -a Generating Playlist...about 50% complete.
        }
      }
      if ((%songprogress > 55) && (%songprogress <= $int(60))) {
        if (!%progress60) {
          var %progress60 = 1
          echo $color(text) -a Generating Playlist...about 60% complete.
        }
      }
      if ((%songprogress > 65) && (%songprogress <= $int(70))) {
        if (!%progress70) {
          var %progress70 = 1
          echo $color(text) -a Generating Playlist...about 70% complete.
        }
      }
      if ((%songprogress > 75) && (%songprogress <= $int(80))) {
        if (!%progress80) {
          var %progress80 = 1
          echo $color(text) -a Generating Playlist...about 80% complete.
        }
      }
      if ((%songprogress > 85) && (%songprogress <= $int(90))) {
        if (!%progress90) {
          var %progress90 = 1
          echo $color(text) -a Generating Playlist...about 90% complete.
        }
      }
      if (!%currentsongdir) {
        var %currentsongdir = $gettok($findfile(%songdir,*.mp3,%x),-2,92)
        .fwrite -n playlist <b> $+ $gettok($findfile(%songdir,*.mp3,%x),1- $+ $calc($numtok($findfile(%songdir,*.mp3,%x),92) -1),92) $+ </b><br><br>
      }
      else {
        if (%currentsongdir != $gettok($findfile(%songdir,*.mp3,%x),-2,92)) {
          var %currentsongdir = $gettok($findfile(%songdir,*.mp3,%x),-2,92)
          .fwrite -n playlist <br><b> $+ $gettok($findfile(%songdir,*.mp3,%x),1- $+ $calc($numtok($findfile(%songdir,*.mp3,%x),92) -1),92) $+ </b><br><br>
        }
      }
      .fwrite -n playlist <li> %x $+ . $left($gettok($findfile(" $+ %songdir $+ ",*.mp3,%x),-1,92),-4) $iif(%songlengths == $true,( $+ $gmt($calc($sound($findfile(" $+ %songdir $+ ",*.mp3,%x)).length / 1000),nn:ss) $+ )) $+ <br>
      inc %x
    }
    .fwrite -n playlist </ul></font>
    .fwrite -n playlist <font face="verdana" size="1">
    .fwrite -n playlist <br>Assuming I don't own any of these songs, I owe the RIAA about $chr(36) $+ $maketok($calc(%songs * 250000),3,44) $+ .
    .fwrite -n playlist <br>Generated in: ~ $+ $duration($calc(($ticks - %ticks) / 1000)) $+ . <br>
    .fwrite -n playlist Created by <a href="mailto:bh@scriptsurge.org">bunkahumpa</a>
    .fwrite -n playlist </font>
    .fwrite -n playlist </body>
    .fwrite -n playlist </html>
    .fclose playlist
    echo $color(text) -a Playlist Generation Complete.
    echo $color(text) -a Playlist Saved to: $scriptdirmp3playlist.html
    run $scriptdirmp3playlist.html
  }
}

alias m3uplaylist {
  var %playlist = $sfile($gettok($mircdir,1,92) $+ \*.m3u,Select the m3u playlist file)
  if (!%playlist) {
    var %errormsg = $input(You did not select an m3u playlist!,o)
    return
  }
  if ($read(%playlist,1) != #EXTM3U) {
    var %errormsg = $input(That is not a valid m3u playlist!,o)
    return
  }
  var %songs = $round($calc($lines(%playlist) / 2 - 1),0)
  if (%songs == 0) {
    var %errormsg = $input(There are no songs entries in the playlist!,o)
  }
  else {
    var %songlengths = $input(Do you want to display the song lengths?,y)
    if (%songs == 1) var %songsword = Song
    else var %songsword = Songs
    var %x = 1
    while (%x <= $fopen(0)) {
      if ($fopen(%x) == playlist) {
        .fclose playlist
      }
      inc %x
    }
    echo -a Please Wait, Generating Playlist...
    var %ticks = $ticks
    .fopen -o playlist " $+ $scriptdirmp3playlist.html $+ "
    .fwrite -n playlist <head>  
    .fwrite -n playlist <title>My m3u Playlist - generated by mIRC (by bunkahumpa)</title>
    .fwrite -n playlist </head>
    .fwrite -n playlist <body>
    .fwrite -n playlist <font face="verdana" size="3">
    .fwrite -n playlist My mp3 Playlist - generated by mIRC
    .fwrite -n playlist <br>
    .fwrite -n playlist <b> $+ %songs $+ </b> %songsword
    .fwrite -n playlist </font>
    .fwrite -n playlist <br>
    .fwrite -n playlist <font face="verdana" size="2">
    .fwrite -n playlist <ul>
    var %x = 1
    while (%x <= $calc(%songs * 2)) {
      var %songprogress = $calc(%x / %songs * 100)
      if ((%songprogress > 5) && (%songprogress <= $int(10))) {
        if (!%progress10) {
          var %progress10 = 1
          echo $color(text) -a Generating Playlist...about 10% complete.
        }
      }
      if ((%songprogress > 15) && (%songprogress <= $int(20))) {
        if (!%progress20) {
          var %progress20 = 1
          echo $color(text) -a Generating Playlist...about 20% complete.
        }
      }
      if ((%songprogress > 25) && (%songprogress <= $int(30))) {
        if (!%progress30) {
          var %progress30 = 1
          echo $color(text) -a Generating Playlist...about 30% complete.
        }
      }
      if ((%songprogress > 35) && (%songprogress <= $int(40))) {
        if (!%progress40) {
          var %progress40 = 1
          echo $color(text) -a Generating Playlist...about 40% complete.
        }
      }
      if ((%songprogress > 45) && (%songprogress <= $int(50))) {
        if (!%progress50) {
          var %progress50 = 1
          echo $color(text) -a Generating Playlist...about 50% complete.
        }
      }
      if ((%songprogress > 55) && (%songprogress <= $int(60))) {
        if (!%progress60) {
          var %progress60 = 1
          echo $color(text) -a Generating Playlist...about 60% complete.
        }
      }
      if ((%songprogress > 65) && (%songprogress <= $int(70))) {
        if (!%progress70) {
          var %progress70 = 1
          echo $color(text) -a Generating Playlist...about 70% complete.
        }
      }
      if ((%songprogress > 75) && (%songprogress <= $int(80))) {
        if (!%progress80) {
          var %progress80 = 1
          echo $color(text) -a Generating Playlist...about 80% complete.
        }
      }
      if ((%songprogress > 85) && (%songprogress <= $int(90))) {
        if (!%progress90) {
          var %progress90 = 1
          echo $color(text) -a Generating Playlist...about 90% complete.
        }
      }
      var %string = $read(%playlist,%x)
      var %regex = /#EXTINF:(\d+),(.+)/
      if ($regex(%string,%regex)) {
        if (!%songlist) var %songlist = 1
        else inc %songlist
        .fwrite -n playlist <li> %songlist $+ . $regml(2) $iif(%songlengths == $true,( $+ $gmt($regml(1),nn:ss) $+ )) $+ <br>
      }
      inc %x
    }
  }
  .fwrite -n playlist </ul></font>
  .fwrite -n playlist <font face="verdana" size="1">
  .fwrite -n playlist <br>Assuming I don't own any of these songs, I owe the RIAA about $chr(36) $+ $maketok($calc(%songs * 250000),3,44) $+ .
  .fwrite -n playlist <br>Generated in: ~ $+ $duration($calc(($ticks - %ticks) / 1000)) $+ . <br>
  .fwrite -n playlist Created by <a href="mailto:bh@scriptsurge.org">bunkahumpa</a>
  .fwrite -n playlist </font>
  .fwrite -n playlist </body>
  .fwrite -n playlist </html>
  .fclose playlist
  echo $color(text) -a Playlist Generation Complete.
  echo $color(text) -a Playlist Saved to: $scriptdirmp3playlist.html
  run $scriptdirmp3playlist.html
}

alias plsplaylist {
  var %playlist = $sfile($gettok($mircdir,1,92) $+ \*.pls,Select the pls playlist file)
  if (!%playlist) {
    var %errormsg = $input(You did not select an pls playlist!,o)
    return
  }
  if ($read(%playlist,1) != [playlist]) {
    var %errormsg = $input(That is not a valid pls playlist!,o)
    return
  }
  var %songs = $gettok($read(%playlist,$calc($lines(%playlist) - 1)),2,61)
  if (%songs == 0) {
    var %errormsg = $input(There are no songs entries in the playlist!,o)
  }
  else {
    var %songlengths = $input(Do you want to display the song lengths?,y)
    if (%songs == 1) var %songsword = Song
    else var %songsword = Songs
    var %x = 1
    while (%x <= $fopen(0)) {
      if ($fopen(%x) == playlist) {
        .fclose playlist
      }
      inc %x
    }
    echo -a Please Wait, Generating Playlist...
    var %ticks = $ticks
    .fopen -o playlist " $+ $scriptdirmp3playlist.html $+ "
    .fwrite -n playlist <head>  
    .fwrite -n playlist <title>My pls Playlist - generated by mIRC (by bunkahumpa)</title>
    .fwrite -n playlist </head>
    .fwrite -n playlist <body>
    .fwrite -n playlist <font face="verdana" size="3">
    .fwrite -n playlist My pls Playlist - generated by mIRC
    .fwrite -n playlist <br>
    .fwrite -n playlist <b> $+ %songs $+ </b> %songsword
    .fwrite -n playlist </font>
    .fwrite -n playlist <br>
    .fwrite -n playlist <font face="verdana" size="2">
    .fwrite -n playlist <ul>
    var %x = 1
    while (%x <= $lines(%playlist)) {
      var %songprogress = $calc(%x / %songs * 100)
      if ((%songprogress > 5) && (%songprogress <= $int(10))) {
        if (!%progress10) {
          var %progress10 = 1
          echo $color(text) -a Generating Playlist...about 10% complete.
        }
      }
      if ((%songprogress > 15) && (%songprogress <= $int(20))) {
        if (!%progress20) {
          var %progress20 = 1
          echo $color(text) -a Generating Playlist...about 20% complete.
        }
      }
      if ((%songprogress > 25) && (%songprogress <= $int(30))) {
        if (!%progress30) {
          var %progress30 = 1
          echo $color(text) -a Generating Playlist...about 30% complete.
        }
      }
      if ((%songprogress > 35) && (%songprogress <= $int(40))) {
        if (!%progress40) {
          var %progress40 = 1
          echo $color(text) -a Generating Playlist...about 40% complete.
        }
      }
      if ((%songprogress > 45) && (%songprogress <= $int(50))) {
        if (!%progress50) {
          var %progress50 = 1
          echo $color(text) -a Generating Playlist...about 50% complete.
        }
      }
      if ((%songprogress > 55) && (%songprogress <= $int(60))) {
        if (!%progress60) {
          var %progress60 = 1
          echo $color(text) -a Generating Playlist...about 60% complete.
        }
      }
      if ((%songprogress > 65) && (%songprogress <= $int(70))) {
        if (!%progress70) {
          var %progress70 = 1
          echo $color(text) -a Generating Playlist...about 70% complete.
        }
      }
      if ((%songprogress > 75) && (%songprogress <= $int(80))) {
        if (!%progress80) {
          var %progress80 = 1
          echo $color(text) -a Generating Playlist...about 80% complete.
        }
      }
      if ((%songprogress > 85) && (%songprogress <= $int(90))) {
        if (!%progress90) {
          var %progress90 = 1
          echo $color(text) -a Generating Playlist...about 90% complete.
        }
      }
      if ($left($gettok($read(%playlist,%x),1,61),4) == File) {
        if (!%songlist) var %songlist = 1
      }
      if ($gettok($read(%playlist,%x),1,61) == Title $+ %songlist) {
        var %songname = $gettok($read(%playlist,%x),2,61)
        var %songlength = $gettok($read(%playlist,$calc(%x + 1)),2,61)
        .fwrite -n playlist <li> %songlist $+ . %songname $iif(%songlengths == $true,( $+ $gmt(%songlength,nn:ss) $+ )) $+ <br>
        inc %songlist
      }
      inc %x
    }
  }
  .fwrite -n playlist </ul></font>
  .fwrite -n playlist <font face="verdana" size="1">
  .fwrite -n playlist <br>Assuming I don't own any of these songs, I owe the RIAA about $chr(36) $+ $maketok($calc(%songs * 250000),3,44) $+ .
  .fwrite -n playlist <br>Generated in: ~ $+ $duration($calc(($ticks - %ticks) / 1000)) $+ . <br>
  .fwrite -n playlist Created by <a href="mailto:bh@scriptsurge.org">bunkahumpa</a>
  .fwrite -n playlist </font>
  .fwrite -n playlist </body>
  .fwrite -n playlist </html>
  .fclose playlist
  echo $color(text) -a Playlist Generation Complete.
  echo $color(text) -a Playlist Saved to: $scriptdirmp3playlist.html
  run $scriptdirmp3playlist.html
}