AspGerman Wiki

Von http://www.iamsmo.com/site/aspmp3lister/aspmp3lister.htm

<%@ Language=VBScript %>
<% Option Explicit %>

<%
'***********
'*          ASP MP3 Lister By Smo           *
'*        (c) 2001 By Tim Smulders          *
'*               Version 1                  *
'*          http://www.iamsmo.com           *
'***********

'Ignore this line below.
Dim strPhysicalAddressOfMP3Folder, strMP3IsALink, strVirtualAddressOfMP3Folder, strTableBackGroundColor, _
	strTableBorderColor, strCreateAspPage, strPhysicalAddressOfFolderWithWritePermission, _
	strAspPageName, arrGenre, objFSO, objMP3Directory, objMP3, strAspPage, MP3, strComment, _
	strTag, intGenre, objAspPage

'Between the quotes in the line below enter the
'physical address of your mp3 folder.

strPhysicalAddressOfMP3Folder = "C:\Physical\Address\Of\MP3Folder"

'If you want the MP3 filename to be a link so users
'can download the file leave Yes between the quotes
'in the line below. If you do not want the filename
'to be a download link enter No between the quotes.

strMP3IsALink = "Yes"

'If strMP3IsALink above is set to Yes you must enter
'the virtual address of your mp3 folder between the
'quotes in the line below.

strVirtualAddressOfMP3Folder = "http://www.mywebsite.com/Virtual/Address/Of/MP3Folder"

'Enter the hexadecimal color for the table background.
strTableBackGroundColor = "#CCCCCC"

'Enter the hexadecimal color for the table border.
strTableBorderColor = "#000000"

'If you want to create an asp file from the list
'leave Yes between the quotes in the line below.
'You can use the created asp file as an include file.
'If you do not want to create an asp file from the
'list enter No between the quotes.

strCreateAspPage = "Yes"

'If strCreateAspPage above is set to Yes you must enter
'the physical address of the folder where you want the asp
'file to be created between the quotes in the line below.
'This folder must have write permission.

strPhysicalAddressOfFolderWithWritePermission = "C:\Physical\Address\Of\FolderWithWritePermission"

'If strCreateAspPage above is set to Yes you must enter
'a name for the asp file between the quotes in the line
'below. Its best to move the created asp file to a
'different directory before linking to it so your users
'do not know the location of your writable directory.

strAspPageName = "mymp3list.asp"

'You can ignore everything else below this line.

arrGenre = Split("Blues,Classic Rock,Country,Dance,Disco,Funk,Grunge,Hip-Hop,Jazz,Metal," & _
	"New Age,Oldies,Other,Pop,R&B,Rap,Reggae,Rock,Techno,Industrial,Alternative,Ska," & _
	"Death Metal,Pranks,Soundtrack,Euro-Techno,Ambient,Trip-Hop,Vocal,Jazz+Funk," & _
	"Fusion,Trance,Classical,Instrumental,Acid,House,Game,Sound Clip,Gospel,Noise," & _
	"Altern Rock,Bass,Soul,Punk,Space,Meditative,Instrumental Pop,Instrumental Rock," & _
	"Ethnic,Gothic,Darkwave,Techno-Industrial,Electronic,Pop-Folk,Eurodance,Dream," & _
	"Southern Rock,Comedy,Cult,Gangsta,Top 40,Christian Rap,Pop/Funk,Jungle," & _
	"Native American,Cabaret,New Wave,Psychadelic,Rave,Showtunes,Trailer,Lo-Fi,Tribal," & _
	"Acid Punk,Acid Jazz,Polka,Retro,Musical,Rock & Roll,Hard Rock,Folk,Folk/Rock," & _
	"National Folk,Swing,Bebob,Latin,Revival,Celtic,Bluegrass,Avantgarde,Gothic Rock," & _
	"Progressive Rock,Psychedelic Rock,Symphonic Rock,Slow Rock,Big Band,Chorus," & _
	"Easy Listening,Acoustic,Humour,Speech,Chanson,Opera,Chamber Music,Sonata,Symphony," & _
	"Booty Bass,Primus,Porn Groove,Satire,Slow Jam,Club,Tango,Samba,Folklore", ",")

Response.Write "<html><head><title>ASP MP3 Lister</title>" & _
	"<meta http-equiv=""Content-Type"" content=""text/html;charset=iso-8859-1"">" & _
	"</head><body bgcolor=""#FFFFFF"">"

Response.Write "<table width=""100%"" border=""0""><tr valign=""top"" align=""left"">" & _
	"<td>ASP MP3 Lister Version beta 1 &copy; <a href=""http://www.iamsmo.com"">" & _
	"I Am Smo</a></td></tr></table><br><form name=""CreateMP3List"" method=""post"" " & _
	"action=""aspmp3lister_v1.asp?aspmp3listerstep=createmp3list""><table width=""100%"" " & _
	"border=""0""><tr valign=""top"" align=""left""><td><input type=""submit"" " & _
	"name=""Submit"" value=""Create MP3 List""></td></tr></table><br>"

If Request.QueryString("aspmp3listerstep") = "createmp3list" Then

	Set objFSO = CreateObject("Scripting.FileSystemObject")
	Set objMP3Directory = objFSO.GetFolder(strPhysicalAddressOfMP3Folder)
	Set objMP3 = Server.CreateObject("ADODB.Stream") 
	objMP3.Type = 1

	strAspPage = "<table border=""1"" bgcolor=""" & _
		strTableBackGroundColor & """ bordercolor=""" & strTableBorderColor & _
		""" cellspacing=""0"" cellpadding=""0""><tr align=""center"" " & _
		"valign=""middle""><td>&nbsp;&nbsp;File Size&nbsp;&nbsp;</td><td>" & _
		"&nbsp;&nbsp;File Name&nbsp;&nbsp;</td><td>&nbsp;&nbsp;" & _
		"Title&nbsp;&nbsp;</td><td>&nbsp;&nbsp;Artist&nbsp;&nbsp;" & _
		"</td><td>&nbsp;&nbsp;Album&nbsp;&nbsp;</td><td>&nbsp;&nbsp;" & _
		"Year&nbsp;&nbsp;</td><td>&nbsp;&nbsp;Comment&nbsp;&nbsp;</td><td>" & _
		"&nbsp;&nbsp;Track&nbsp;&nbsp;</td><td>&nbsp;&nbsp;Genre&nbsp;&nbsp;</td>" & _
		"<td>&nbsp;&nbsp;Tag&nbsp;&nbsp;</td></tr>"

	For Each MP3 in objMP3Directory.Files
		strAspPage = strAspPage & "<tr align=""center"" valign=""middle""><td>&nbsp;&nbsp;" & _
			Round((MP3.Size * .000001), 2) & "&nbsp;meg&nbsp;&nbsp;</td>"
		If strMP3IsALink = "Yes" Then
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;<a href=""" & _
				strVirtualAddressOfMP3Folder & "/" & MP3.Name & """>" & _
				MP3.Name & "</a>&nbsp;&nbsp;</td>"
		Else
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & MP3.Name & _
				"&nbsp;&nbsp;</td>"
		End If

		objMP3.Open
		objMP3.LoadFromFile MP3.Path
		objMP3.Position = objMP3.Size - 128

		If UCase(ConvertTheBinary(objMP3.Read(3))) = "TAG" Then
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
				ConvertTheBinary(objMP3.Read(30)) & "&nbsp;&nbsp;</td>"
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
				ConvertTheBinary(objMP3.Read(30)) & "&nbsp;&nbsp;</td>"
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
				ConvertTheBinary(objMP3.Read(30)) & "&nbsp;&nbsp;</td>"
			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
				ConvertTheBinary(objMP3.Read(4)) & "&nbsp;&nbsp;</td>"

			strComment = objMP3.Read(30)

			If AscB(MidB(strComment, 29, 1)) = 0 AND AscB(MidB(strComment, 30, 1)) > 0 _
				AND AscB(MidB(strComment, 30, 1)) < 256 Then

				strTag = "ID3v1.1"

				strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
					ConvertTheBinary(LeftB(strComment, 28)) & "&nbsp;&nbsp;</td>"

				strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
					AscB(MidB(strComment, 30,1)) & "&nbsp;&nbsp;</td>"

			Else

				strTag = "ID3v1"

				strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
					ConvertTheBinary(strComment) & "&nbsp;&nbsp;</td>"

				strAspPage = strAspPage & "<td>&nbsp;</td>"

			End If

			intGenre = AscB(objMP3.Read(1))

			If intGenre <= 114 AND intGenre >= 0 Then
				strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & _
					arrGenre(intGenre) & "&nbsp;&nbsp;</td>"

			Else

				strAspPage = strAspPage & "<td>&nbsp;</td>"

			End If

			strAspPage = strAspPage & "<td>&nbsp;&nbsp;" & strTag & _
				"&nbsp;&nbsp;</td></tr>"
		Else
			strAspPage = strAspPage & "<td colspan=""8"">&nbsp;&nbsp;" & _
				"NO ID3v1 or ID3v1.1 TAG found for this file&nbsp;&nbsp;</td></tr>"
		End If

		objMP3.Close
	Next

	strAspPage = strAspPage & "</table>"

	Set objMP3 = Nothing
	Set objMP3Directory = Nothing
	Set objFSO = Nothing

End If

Response.Write strAspPage & "</body></html>"

If strCreateAspPage = "Yes" Then

	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
	Set objAspPage = objFSO.CreateTextFile(strPhysicalAddressOfFolderWithWritePermission & _
		"\" & strAspPageName)

	objAspPage.WriteLine(strAspPage)

	objAspPage.Close
	Set objAspPage = Nothing
	Set objFSO = Nothing

End If

Function ConvertTheBinary(thebytes)

	Dim x

	For x = 1 to LenB(thebytes)
		If AscB(MidB(thebytes,x, 1))<> 0 Then
			ConvertTheBinary = ConvertTheBinary & Chr(AscB(MidB(thebytes, x, 1)))
		End If
	Next

End function

%>

ScrewTurn Wiki version 2.0.33. Some of the icons created by FamFamFam.