I have a lot of mp3's - and I want to display them on my web page so I need to either use ASP (I've done that) or create an XML database of my MP3 listing...
To display XML in a friendly format I am using XSL markup language - and I've included that as well.
But the main point here is that this executable will create an XML database of all of your mp3's (Or other files)
This is in it's infancy right now and I will be posting updates.
USEAGE: XMLDrive <path to your mp3's> <output dir where the XML will go> <file extension - usually mp3>
KNOWN ISSUES:
Filename *must* be in artist - songname.mp3 format
XML does not allow certain special characters - I will be adding filters in when I get a filter list from work (We do XML and XSL)...
Now to make it fancy you will want the XSL otherwise it will display in ugly XML format, XSL takes XML input and outputs it as HTML
Modify as you see fit
To display XML in a friendly format I am using XSL markup language - and I've included that as well.
But the main point here is that this executable will create an XML database of all of your mp3's (Or other files)
This is in it's infancy right now and I will be posting updates.
USEAGE: XMLDrive <path to your mp3's> <output dir where the XML will go> <file extension - usually mp3>
KNOWN ISSUES:
Filename *must* be in artist - songname.mp3 format
XML does not allow certain special characters - I will be adding filters in when I get a filter list from work (We do XML and XSL)...
Code:
#Option Version5 #Register None #Include "WIN32API.INC" Declare Function WriteDTDFile(OutputDir As String,filename As String) As Long '============================================<WINMAIN>================================================================== Function WinMain (ByVal hInstance As Long, _ ByVal hPrevInstance As Long, _ ByVal lpCmdLine As Asciiz Ptr, _ ByVal iCmdShow As Long) As Long Local hFile As Long Local lResult As Long Local lCount As Long Local lLoop As Long Local inputdir As String Local outputdir As String Local FileName As String 'baseline of filename as directed by user Local sTmp As String Local buff As String Local fd As WIN32_FIND_DATA Local sSearchSpec As String Local ncPaths As Long Local hFind As Long Local qcbFileSize As Quad Dim asPathList(1 To 1) As String If IsFalse Len(Command$) Then StdOut Color 11,0 StdOut "xmlDrive "; Color 14,0 StdOut "<inputdir> <outputdir> <fileextension>" Color 7,0 StdOut "<inputdir> is the directory scanned" StdOut "<outputdir> is the folder the dtd and xml file are written to" StdOut "<filename> is the name assigned to .xml and .dtd (ie mp3.dtd, mp3.xml)" End If inputdir = Parse$(Command$," ",1) outputdir = Parse$(Command$," ",2) filename = Parse$(Command$," ",-1) If filename = outputdir Then 'filename left off StdOut "Filename not specified" Exit Function End If If Right$(InputDir,1) <> "\" Then InputDir = InputDir & "\" If Right$(outputDir,1) <> "\" Then outputDir = outputDir & "\" lResult = WriteDTDFile(outputdir,filename) hFile = FreeFile Open outputdir & filename & ".xml" For Output As #hFile Print #hFile, "<?xml version=""1.0""?>" Print #hFile, "<!DOCTYPE mp3list SYSTEM """ & filename & ".dtd"">" Print #hFile, "<?xml-stylesheet type=""text/xsl"" href=""" & filename & ".xsl""?> Print #hFile, "<mp3list>" 'Begin scanning drive sSearchSpec = "*." & Filename ' Treat any periods as literals rather than as regex codes. Replace "." With "\." In sSearchSpec ncPaths = 1 asPathList(ncPaths) = inputdir ' Scan for matching files, one directory at a time. Do hFind = FindFirstFile(asPathList(1) + "*", fd) If hFind <> Bits&(%INVALID_HANDLE_VALUE) Then Do If fd.cFilename <> "." And fd.cFilename <> ".." Then ' If it's a directory, add it to the search list. If (fd.dwFileAttributes And %FILE_ATTRIBUTE_DIRECTORY) Then Incr ncPaths ReDim Preserve asPathList(1 To ncPaths) As String asPathList(ncPaths) = asPathList(1) + fd.cFilename + "\" End If ' If it's a matching file, display it. Incr lCount ' StdOut asPathList(1) + fd.cFilename 'XML Engine - parse and write the elements here '</mp3> Print #hFile, "<" & filename & " id=""" & Format$(lCount) & """>" 'Open tag for element mp3 '<artist> Print #hFile, String$(5,32) & "<artist>"; Print #hFile, Trim$(Parse$(fd.cFilename,"-",1)); Print #hFile, "</artist>" '<title> Print #hFile, String$(5,32) & "<title>"; sTmp = Trim$(Parse$(fd.cFilename,"-",-1)) If Right$(sTmp,4) = "." & filename Then sTmp = Left$(sTmp,Len(sTmp)-4) Print #hFile, sTmp; Print #hFile, "</title>" '<path> Print #hFile, String$(5,32) & "<path>"; sTmp = asPathList(1) If Right$(sTmp,1) = "\" Then sTmp = Left$(sTmp,Len(sTmp)-1) Print #hFile, sTmp; Print #hFile, "</path>" '</mp3> Print #hFile, "</" & filename & ">" 'Open tag for element mp3 End If Loop While FindNextFile(hFind, fd) FindClose hFind End If Array Delete asPathList() Decr ncPaths Loop While ncPaths StdOut StdOut Format$(lCount) & " files.." Print #hFile, "</mp3list>" Close #hFile End Function '======================================================================================================================= '------------------------------------------------------------------------------------------ Function WriteDTDFile(OutputDir As String,filename As String) As Long Local hFile As Long hFile = FreeFile Open OutPutDIr & filename & ".dtd" For Output As #hFile Print #hFile,"<?xml version=""1.0""?>" Print #hFile, "<!ELEMENT mp3list (mp3,author,title,path)>" Print #hFile, "<!ELEMENT mp3 (#PCDATA)>" Print #hFile, "<!ELEMENT artist (#PCDATA)>" Print #hFile, "<!ELEMENT title (#PCDATA)>" Print #hFile, "<!ELEMENT path (#PCDATA)>" Close #hFile Function = %TRUE End Function '------------------------------------------------------------------------------------------ '------------------------------------------------------------------------------------------ '------------------------------------------------------------------------------------------ '------------------------------------------------------------------------------------------
Now to make it fancy you will want the XSL otherwise it will display in ugly XML format, XSL takes XML input and outputs it as HTML
Modify as you see fit
Code:
'Filename must match the extension name, ie mp3.xsl <?xml version='1.0' encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"> <xsl:template match="/"> <html> <head> <title>MP3 Collection</title> </head> <style type="text/css"> .warn {color: black;text-transform:none;font-style:normal;font-weight:bolder;background:yellow;} .del {color: black;text-decoration:Line-through;background:#F66;} .ins{color: black;text-decoration:None;background:yellow;} A:link{text-decoration: None; Color: #000080;} A:visited {text-decoration: None; Color: #000080;} A:active{text-decoration:None; Color: #000080;} A:hover{text-decoration: None; Color: #FF4040;background: #000080;} </style> <body bgcolor="#000000" text="#000000"> <div align="center"> <center> <table border="0" width="655" height="142"> <tr> <td width="150" height="142"> <img src="http://www.tngbbs.com/images/batty.gif" width="125" height="82"></img> </td> <td width="990" height="142"> <p algin="center" align="center"> <font size="7"><font color="#FF0000">T</font><font color="#0000FF">he</font> <font color="#FF0000">N</font><font color="#0000FF">ight </font><font color="#FF0000">G</font><font color="#0000FF">allery </font></font><font color="#FF0000" size="7">BBS </font><br/> <font size="4" color="#FFFFFF"><b>Since July 1994</b></font> </p> <p></p> </td> </tr> </table> </center> </div> <table border="2" bordercolor="black" BGCOLOR="#7191F7" align="center"> <tr BGCOLOR="#7191F7"> <td> <table border="0" width="100%"> <tr> <td> <a href="http://www.tngbbs.com/ccs"> <img border="0" src="http://www.tngbbs.com/ccs/images/mp3ccsweblogo.jpg"></img></a> </td> <td>TNGMP3! v3.0 <br /> <span class="warn">Copyright (c) 2002-2005</span><br /> <a href="http://www.tngbbs.com/ccs">Computer Creations Software</a> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#8080DD"><Font color="#FF0000">Path</Font></td> <td bgcolor="#8080DD"><Font color="#FF0000">Artist</Font></td> <td bgcolor="#8080DD"><Font color="#FF0000">Title</Font></td> </tr> <xsl:for-each select="mp3list/mp3"> <tr BGCOLOR="#7191F7"> <td ALIGN="left" bgcolor="#8080DD" color="#000080"><font face="Tahoma,Verdana" size="2" color="#000080"><xsl:value-of select="path"/></font></td> <td ALIGN="left" bgcolor="#8080DD" color="#000080"><font face="Tahoma,Verdana" size="2" color="#000080"><xsl:value-of select="artist"/></font></td> <td ALIGN="left" bgcolor="#8080DD" color="#000080"><font face="Tahoma,Verdana" size="2" color="#000080"><xsl:value-of select="title"/></font></td> </tr> </xsl:for-each> </table> </body> </html> </xsl:template> </xsl:stylesheet>