1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
dialog playlist_generator {
title "Playlist generator"
size -1 -1 120 23
option dbu
button "Generate", 1, 2 1 37 12
button "Launch M3U", 2, 41 1 37 12
button "Launch HTML", 3, 80 1 37 12
text "", 6, 3 14 100 14
}
on *:dialog:pl:*:*: {
if ($devent == sclick) {
if ($did == 1) { pl_stat Please select a dir | pl_start }
if ($did == 2) { pl_stat Starting M3U.. | run playlist.m3u }
if ($did == 3) { pl_stat Starting HTML.. | run pl.html }
}
if ($devent == init) {
pl_stat Idle..
}
}
alias pl_stat { did -ra pl 6 $1- | write -a pl_log.txt $1- }
alias pl $iif(!$dialog(pl),dialog -dm pl playlist_generator,dialog -v pl playlist_generator)
alias -l pl_writeinfo {
write -a pl.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
write -a pl.html <html xmlns="http://www.w3.org/1999/xhtml">
write -a pl.html <head>
write -a pl.html <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
write -a pl.html <title>Playlist generator</title>
write -a pl.html <style type="text/css">
write -a pl.html body {background-color:#4F687D;font-family:Verdana;color:#FFFFFF}
write -a pl.html a {color:#99FFFF;text-decoration:none}
write -a pl.html a:hover {color:#FFFFFF;text-decoration:none}
write -a pl.html body,td,th {font-size: 9px;}
write -a pl.html a:link {color: #FFFFFF;text-decoration: underline;}
write -a pl.html a:visited {text-decoration: underline;color: #FFFFFF;}
write -a pl.html a:active {text-decoration: underline;color: #FFFFFF;}
write -a pl.html </style>
write -a pl.html </head>
write -a pl.html <body>
write -a pl.html <table width="100%" border="0" cellpadding="0" cellspacing="0">
write -a pl.html <tr>
write -a pl.html <td bgcolor="#006699"><strong>#</strong></td>
write -a pl.html <td bgcolor="#006699"><strong>Artist</strong></td>
write -a pl.html <td bgcolor="#006699"><strong>Title</strong></td>
write -a pl.html <td bgcolor="#006699"><strong>Length</strong></td>
write -a pl.html <td bgcolor="#006699"><strong>Album</strong></td>
write -a pl.html <td bgcolor="#006699"><strong>Bitrate</strong></td>
write -a pl.html </tr>
}
alias pl_start {
if (!$dialog(pl)) { echo -l -Playlist Generator- Please use /pl | halt }
if ($readini(mirc.ini,plgen,dir)) var %dir $sdir($v1,Please select a dir..)
else var %dir $sdir($mircdir,Please select a dir..)
writeini mirc.ini plgen dir %dir
unset %currentfile
pl_stat Changed dir to %dir $+ .. Starting to generate..
writeini mirc.ini plgen ticks $ticks
writeini mirc.ini plgen bitlow 99999
writeini mirc.ini plgen bithigh 0
writeini mirc.ini plgen totaltime 0
.btrunc playlist.m3u 0
.write playlist.m3u #EXTM3U
.write -ca pl.html
pl_writeinfo
pl_stat Removed playlist..
pl_stat Generating..
writeini mirc.ini plgen totalfilesfound $findfile(%dir,*.mp3,0,pl_write $1-)
}
alias iseven { return $iif($chr(46) isin $calc($1 / 2),$false,$true) }
alias pl_write {
var %length $gmt($calc($sound($1-).length / 1000),nn:ss)
var %artist $iif($sound($1-).artist,$sound($1-).artist,$remove($gettok($nopath($1-),1,45),.mp3))
var %title $iif($sound($1-).title,$sound($1-).title,$remove($gettok($nopath($1-),2,45),.mp3))
var %album $sound($1-).album
var %bitrate $sound($1-).bitrate
if (!%bitrate) { writeini mirc.ini plgen totalfilesfound $calc($readini(mirc.ini,plgen,totalfilesfound) - 1) | goto end }
inc %currentfile
writeini mirc.ini plgen totaltime $calc($readini(mirc.ini,plgen,totaltime) + $calc($sound($1-).length))
if (%bitrate < $readini(mirc.ini,plgen,bitlow)) {
writeini mirc.ini plgen bitlow %bitrate
}
if (%bitrate > $readini(mirc.ini,plgen,bithigh)) {
writeini mirc.ini plgen bithigh %bitrate
}
if (!$iseven(%currentfile)) {
write -a pl.html <tr> $crlf <td><strong> %currentfile </strong></td> $crlf <td><strong> %artist </strong> $crlf </td><td><strong> %Title </strong></td> $crlf <td><strong> %Length </strong></td> $crlf <td><strong> %Album </strong></td> $crlf <td><strong> %Bitrate </strong></td></tr>
}
else {
write -a pl.html <tr> $crlf <td bgcolor="#56748B"><strong> %currentfile </strong></td> $crlf <td bgcolor="#56748B"><strong> %artist </strong> $crlf </td><td bgcolor="#56748B"><strong> %Title </strong></td> $crlf <td bgcolor="#56748B"><strong> %Length </strong></td> $crlf <td bgcolor="#56748B"><strong> %Album </strong></td> $crlf <td bgcolor="#56748B"><strong> %Bitrate </strong></td></tr>
}
.write playlist.m3u #EXTINF: $+ $left($sound($1-).length,3) $+ , %artist - %title
.write playlist.m3u $1-
:end
if ($readini(mirc.ini,plgen,totalfilesfound) == %currentfile) {
pl_stat Finished.. took $round($calc(($ticks - $readini(mirc.ini,plgen,ticks)) / 1000),1) $+ seconds
.remini mirc.ini plgen currentfile
var %x $findfile($readini(mirc.ini,plgen,dir),*,0)
var %tt $duration($calc($readini(mirc.ini,plgen,totaltime) / 1000))
write -a pl.html </table><p><strong>Lowest Bitrate:</strong> $readini(mirc.ini,plgen,bitlow) $+ <br><strong>Highest Bitrate:</strong> $readini(mirc.ini,plgen,bithigh) $+ <br><strong>Time taken to generate:</strong> $round($calc(($ticks - $readini(mirc.ini,plgen,ticks)) / 1000),1) $+ seconds $+ <br><strong>Total time:</strong> %tt of music <br><strong>Total MP3s:</strong> %currentfile <br><strong>Total files scanned:</strong> %x <br><strong>Wasted files:</strong> $calc(%x - %currentfile) <br><strong>Directory:</strong> $readini(mirc.ini,plgen,dir) <br></p></body></html>
unset %currentfile
}
}
|