playlist generator thing
Posted by w.e
Saturday, November 12, 2005
Description: creates a playlist for html and winamp (.m3u) with a little m3u player.. nothing special
example [tims-design.net]
--updated 'playlist' tab
rough coding but it gets the job done cleanly
example [tims-design.net]
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 disable
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 read
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:
.Playlist Generator: dialog -m playlist playlist
.M3U Player: dialog -m mp3player mp3player
}
alias mostsaid {
set %max 0
var %a 0
while (%a <= $gettok($1-,0,164)) {
if ($gettok(%max,1,32) < $count($1-,$gettok($1-,%a,164))) && ($gettok($1-,%a,164) !isin %max) {
set %max $count($1-,$gettok($1-,%a,164)) $gettok($1-,%a,164)
}
if ($gettok(%max,1,32) == $count($1-,$gettok($1-,%a,164))) && ($gettok($1-,%a,164) !isin %max) {
set %max %max $chr(124) $gettok($1-,%a,164)
}
inc %a
}
return $iif($chr(124) isin %max,$replace($gettok(%max,2-,32),$chr(124),$chr(38)),$gettok(%max,2-,32))
}
alias iseven { return $iif($chr(46) isin $calc($1 / 2),$false,$true) }
alias generateplaylist {
did -ra playlist 14 ---started $date $time $+ $crlf
unset %songz
unset %totaltime
unset %songg
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 <html>
.fwrite -n playlist <title>Playlist Generator v. 2.1 - Created by TiM</title>
.fwrite -n playlist <style type="text/css">
.fwrite -n playlist body $chr(123) background: #4F687D; font-family : Verdana, Arial, Helvetica; color: #FFFFFF $chr(125)
.fwrite -n playlist a $chr(123) color: #99FFFF; TEXT-DECORATION: none $chr(125)
.fwrite -n playlist a:hover $chr(123) color: #FFFFFF; TEXT-DECORATION: none $chr(125)
.fwrite -n playlist body,td,th $chr(123)
.fwrite -n playlist font-size: 9px;
.fwrite -n playlist $chr(125)
.fwrite -n playlist a:link $chr(123)
.fwrite -n playlist color: #FFFFFF;
.fwrite -n playlist text-decoration: underline;
.fwrite -n playlist $chr(125)
.fwrite -n playlist a:visited $chr(123)
.fwrite -n playlist text-decoration: underline;
.fwrite -n playlist color: #FFFFFF;
.fwrite -n playlist $chr(125)
.fwrite -n playlist a:active $chr(123)
.fwrite -n playlist text-decoration: underline;
.fwrite -n playlist color: #FFFFFF;
.fwrite -n playlist $chr(125)
.fwrite -n playlist </style>
set %#files $findfile(%sdir,*.mp3,0)
.fwrite -n playlist <center>Total of<b> %#files </b>legal mp3's in<b> %sdir </b></center><br>
.fwrite -n playlist <table width="100%" border="0" cellpadding="0" cellspacing="0">
.fwrite -n playlist <tr>
.fwrite -n playlist <td width="2%" bgcolor="#006699"><strong>#</strong></td>
.fwrite -n playlist <td width="22%" bgcolor="#006699"><strong>Artist</strong></td>
.fwrite -n playlist <td width="25%" bgcolor="#006699"><strong>Title</strong></td>
.fwrite -n playlist <td width="10%" bgcolor="#006699"><strong>Length</strong></td>
.fwrite -n playlist <td width="32%" bgcolor="#006699"><strong>Album</strong></td>
.fwrite -n playlist <td width="9%" bgcolor="#006699"><strong>Bitrate</strong></td>
.fwrite -n playlist </tr>
set %scannedfi $findfile(%sdir,*,0)
var %num $findfile(%sdir,*.mp3,0,writepl $1-)
.fwrite -n playlist </table>
.fwrite -n playlist <p><b>Total length</b>: $gmt($calc(%totaltime / 1000),hh:nn:ss) <br>
.fwrite -n playlist <b>Total number of songs</b>: %songg $+ <br>
.fwrite -n playlist <b>Favorite artist</b>: $mostsaid(%songz)
.fwrite -n playlist <br>
.fwrite -n playlist <b>Total time taken to generate</b>: $duration($calc(($ticks - %ticks) / 1000)) <br>
.fwrite -n playlist <b>Total files scanned</b>: %scannedfi $+ <br>
.fwrite -n playlist <b>Directory scanned</b>: %sdir $+ *<br>
.fwrite -n playlist <br>
.fwrite -n playlist Created by TiM on #script<br>
.fwrite -n playlist </p>
.fwrite -n playlist </html>
.fclose playlist
run $scriptdirplaylist.html
did -a playlist 10 Playlist Generation Complete. $crlf
}
alias writepl {
echo $1-
if (!$sound($1-).length) halt
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
}
inc %totaltime $sound($1-).length
var %title $iif($sound($1-).title,$sound($1-).title,$remove($gettok($nopath($1-),2,45),.mp3))
if ($len(%title) > 30) { var %title $left(%title,30) $+ ... }
var %artist $iif($sound($1-).artist,$sound($1-).artist,$remove($gettok($nopath($1-),1,45),.mp3))
if ($len(%artist) > 30) { var %artist $left(%artist,30) $+ ... }
set %songz %songz $+ ¤ $+ %artist $+ ¤
if ($iseven(%songg)) {
.fwrite -n playlist <tr>
.fwrite -n playlist <td> $+ %songg $+ </td>
.fwrite -n playlist <td> $+ %artist $+ </td>
.fwrite -n playlist <td> $+ %title $+ </td>
find.mp3 %artist - %title
.fwrite -n playlist <td> $+ $gmt($calc($sound($1-).length / 1000),nn:ss) $+ </td>
.fwrite -n playlist <td> $+ $sound($1-).album $+ </td>
.fwrite -n playlist <td> $+ $sound($1-).bitrate $+ </td>
.fwrite -n playlist </tr>
}
else {
.fwrite -n playlist <tr>
.fwrite -n playlist <td bgcolor="#56748B"> $+ %songg $+ </td>
.fwrite -n playlist <td bgcolor="#56748B"> $+ %artist $+ </td>
.fwrite -n playlist <td bgcolor="#56748B"> $+ %title $+ </td>
.fwrite -n playlist <td bgcolor="#56748B"> $+ $gmt($calc($sound($1-).length / 1000),nn:ss) $+ </td>
.fwrite -n playlist <td bgcolor="#56748B"> $+ $sound($1-).album $+ </td>
.fwrite -n playlist <td bgcolor="#56748B"> $+ $sound($1-).bitrate $+ </td>
.fwrite -n playlist </tr>
}
.write playlist.m3u #EXTINF: $+ $left($sound($1-).length,3) $+ , %artist - %title
.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),nn:ss) $+ ) $+ $crlf
}
on *:dialog:playlist:sclick:15: { run $scriptdirplaylist.html }
on *:dialog:playlist:sclick:22: { run playlist.m3u }
dialog mp3player {
title "MP3 Player - TiM"
size -1 -1 186 168
option dbu
edit "", 1, 85 13 93 10, disable
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 TiM", 14, 75 156 102 8
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 - TiM ***
}
}
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 - TiM ***
}
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.
}
alias find.mp3 {
.remove artist.txt
write artist.txt $gettok($1-,1,45)
write artist.txt $gettok($1-,2,45)
sockclose findmp3
sockopen findmp3 mp3.com 80
}
on *:SOCKOPEN:findmp3*:{
if (!$gettok($sockname,2,45)) {
var %artist $read(artist.txt,1)
var %song $read(artist.txt,2)
echo %artist
echo %title
sockwrite -n $sockname GET /search.php?action=Search&stype=song&query= $+ %song $+ &x=0&y=0 HTTP/1.1
sockwrite -n $sockname Host: www.mp3.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
sockwrite -n $sockname Authorization: Basic <uu-encoded>
sockwrite -n $sockname $crlf
}
else {
sockwrite -n $sockname GET / $+ $gettok($gettok($remove($sockname,http://,www.),2,45),2-,47) HTTP/1.1
sockwrite -n $sockname Host: www.mp3.com
sockwrite -n $sockname Connection: close
sockwrite -n $sockname User-Agent: Mozilla/3.0 (compatible)
sockwrite -n $sockname Authorization: Basic <uu-encoded>
sockwrite -n $sockname $crlf
}
}
on *:sockread:findmp3-*: {
var %artist $read(artist.txt,1)
var %song $read(artist.txt,2)
sockread %temp
if (song-clip-on.gif isin %temp) set %link $gettok(%temp,2,34)
if (%song isin %temp) {
.fwrite -n music. $+ $replace(%artist,$chr(32),^space^) <td bgcolor="#56748B"> $+ <a href=" $+ %link $+ " target="_blank"> $+ %artist $+ </a> $+ </td>
}
}
on *:sockread:findmp3: {
var %artist $read(artist.txt,1)
var %song $read(artist.txt,2)
sockread %temp
if ($lines(artist.txt) == 4) {
sockclose findmp3- $+ $gettok(%temp,2,34)
sockopen findmp3- $+ $gettok(%temp,2,34) $gettok($remove($gettok(%temp,2,34),http://),1,47) 80
write -dl3 artist.txt
write -dl3 artist.txt
}
if ($lines(artist.txt) == 3) {
write artist.txt a
}
if (%artist isin %temp) {
write artist.txt a
}
}
--updated 'playlist' tab
rough coding but it gets the job done cleanly