05年写的,性能不是一般的低
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 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 | <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Option Explicit Response.Buffer = False server.ScriptTimeout = 3600000 Class Mp3WmaInfo Private Info Private Stream Private Standard_Wma_Header Private Standard_Wma_Tag_Header Private Standard_Wma_ExTag_Header Private Standard_Mp3_ID3V2Tag_Header Private TagCoding,Mp3_Genres(147) Public Function GetTag(Path,Input_TagCoding) Set Info = Server.CreateObject("Scripting.Dictionary") Set Stream = Server.CreateObject("Adodb.Stream") Dim Temp_Index Dim Hex_String Stream.Type = 1 Stream.Mode = 3 Stream.Open Stream.Position = 0 Stream.LoadFromFile Path TagCoding = Input_TagCoding If TagCoding = "" Then TagCoding = "Unicode" End If For Temp_Index = 1 To 16 Hex_String = Hex_String & Hex(AscB(Stream.Read(1))) Next If Hex_String = Standard_Wma_Header Then Call GetWmaInfo() Else Call GetMp3Info() End If Stream.Close Set Stream = NoThing Set GetTag = Info End Function Private Sub GetMp3Info() Dim Temp_Index Dim Hex_String Stream.Position = 0 For Temp_Index = 1 To 3 Hex_String = Hex_String & Hex(AscB(Stream.Read(1))) Next If Hex_String = Standard_Mp3_ID3V2Tag_Header Then Set Info.Item("ID3V2") = Server.CreateObject("Scripting.Dictionary") Dim ID3V2_Temp_Size(3) Dim ID3V2_Size Dim ID3V2_Flag Dim ID3V2_Temp_FrameSize(3) Dim ID3V2_FrameID Dim ID3V2_FrameSize Dim ID3V2_FrameSizeFlags Dim ID3V2_FrameContent Info.Item("ID3V2").Item("Ver") = AscB(Stream.Read(1)) Info.Item("ID3V2").Item("Revision") = AscB(Stream.Read(1)) ID3V2_Flag = AlgorismToBinary(AscB(Stream.Read(1)),8) ID3V2_Temp_Size(0) = AscB(Stream.Read(1)) * 2097152 ID3V2_Temp_Size(1) = AscB(Stream.Read(1)) * 16384 ID3V2_Temp_Size(2) = AscB(Stream.Read(1)) * 128 ID3V2_Temp_Size(3) = AscB(Stream.Read(1)) ID3V2_Size = ID3V2_Temp_Size(0) + ID3V2_Temp_Size(1) + ID3V2_Temp_Size(2) + ID3V2_Temp_Size(3) While Stream.Position <= ID3V2_Size ID3V2_FrameID = Trim(ByteToText(Stream.Read(4),TagCoding)) ID3V2_Temp_FrameSize(0) = AscB(Stream.Read(1)) * 16777216 ID3V2_Temp_FrameSize(1) = AscB(Stream.Read(1)) * 65536 ID3V2_Temp_FrameSize(2) = AscB(Stream.Read(1)) * 256 ID3V2_Temp_FrameSize(3) = AscB(Stream.Read(1)) ID3V2_FrameSize = ID3V2_Temp_FrameSize(0) + ID3V2_Temp_FrameSize(1) + ID3V2_Temp_FrameSize(2) + ID3V2_Temp_FrameSize(3) ID3V2_FrameSizeFlags = AlgorismToBinary(AscB(Stream.Read(1)),8) ID3V2_FrameSizeFlags = ID3V2_FrameSizeFlags & AlgorismToBinary(AscB(Stream.Read(1)),8) If ID3V2_FrameSize <> 0 Then ID3V2_FrameContent = Trim(ByteToText(Stream.Read(ID3V2_FrameSize),TagCoding)) End If If ID3V2_FrameID <> "" AND (ID3V2_FrameSizeFlags = "0000000000000000" OR ID3V2_FrameSizeFlags = "0010000000000000") Then Info.Item("ID3V2").Item(ID3V2_FrameID) = ID3V2_FrameContent End If Wend End If Stream.Position = Stream.Size - 128 If ByteToText(Stream.Read(3),TagCoding) = "TAG" Then Dim Mp3_ID3v1_Cenre,Mp3_ID3v1_Cenre_Index Set Info.Item("ID3v1") = Server.CreateObject("Scripting.Dictionary") Info.Item("ID3v1").Item("Title") = ByteToText(Stream.Read(30),TagCoding) Info.Item("ID3v1").Item("Artist") = ByteToText(Stream.Read(30),TagCoding) Info.Item("ID3v1").Item("Album") = ByteToText(Stream.Read(30),TagCoding) Info.Item("ID3v1").Item("Year") = ByteToText(Stream.Read(4),TagCoding) Info.Item("ID3v1").Item("Comment") = ByteToText(Stream.Read(28),TagCoding) Info.Item("ID3v1").Item("Reserve") = AscB(Stream.Read(1)) Info.Item("ID3v1").Item("Track") = AscB(Stream.Read(1)) Mp3_ID3v1_Cenre_Index = AscB(Stream.Read(1)) If Mp3_ID3v1_Cenre_Index <= 147 Then Mp3_ID3v1_Cenre = Mp3_Genres(Mp3_ID3v1_Cenre_Index) End If Info.Item("ID3v1").Item("Cenre") = Mp3_ID3v1_Cenre End If End Sub Private Sub GetWmaInfo() Set Info.Item("Tag") = Server.CreateObject("Scripting.Dictionary") Set Info.Item("ExTag") = Server.CreateObject("Scripting.Dictionary") Dim Wma_Tag_Header,Temp_Index Dim Temp_Byte Dim Wma_Music_Title_Byte_Length Dim Wma_Music_Artist_Byte_Length Dim Wma_Music_Album_Byte_Length Dim Wma_Music_Comment_Byte_Length Dim Wma_Music_Other_Byte_Length Dim Wma_Music_ExTag_Count Dim Temp_Wma_Music_ExTag_Count_Index Dim Wma_Music_ExTag_ID Dim Wma_Music_ExTag_Flag Dim Wma_Music_ExTag_Content_Index Dim Wma_Music_ExTag_Content Stream.Position = 30 For Temp_Index = 1 To 16 Wma_Tag_Header = Wma_Tag_Header & Hex(AscB(Stream.Read(1))) Next While Wma_Tag_Header = Standard_Wma_Tag_Header OR Wma_Tag_Header = Standard_Wma_ExTag_Header If Wma_Tag_Header = Standard_Wma_Tag_Header Then Stream.Position = Stream.Position + 8 Temp_Byte = "" Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_Title_Byte_Length = Clng(Temp_Byte) Temp_Byte = "" Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_Artist_Byte_Length = Clng(Temp_Byte) Temp_Byte = "" Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_Album_Byte_Length = Clng(Temp_Byte) Temp_Byte = "" Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_Comment_Byte_Length = Clng(Temp_Byte) Temp_Byte = "" Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_Other_Byte_Length = Clng(Temp_Byte) If Wma_Music_Title_Byte_Length <> 0 Then Info.Item("Tag").Item("Title") = ByteToText(Stream.Read(Wma_Music_Title_Byte_Length),"Unicode") End If If Wma_Music_Artist_Byte_Length <> 0 Then Info.Item("Tag").Item("Artist") = ByteToText(Stream.Read(Wma_Music_Artist_Byte_Length),"Unicode") End If If Wma_Music_Album_Byte_Length <> 0 Then Info.Item("Tag").Item("Album") = ByteToText(Stream.Read(Wma_Music_Album_Byte_Length),"Unicode") End If If Wma_Music_Comment_Byte_Length <> 0 Then Info.Item("Tag").Item("Comment") = ByteToText(Stream.Read(Wma_Music_Comment_Byte_Length),"Unicode") End If If Wma_Music_Other_Byte_Length <> 0 Then Info.Item("Tag").Item("Other") = ByteToText(Stream.Read(Wma_Music_Other_Byte_Length),"Unicode") End If End If If Wma_Tag_Header = Standard_Wma_ExTag_Header Then Stream.Position = Stream.Position + 8 Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_ExTag_Count = Clng(Temp_Byte) For Temp_Wma_Music_ExTag_Count_Index = 1 To Wma_Music_ExTag_Count Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_ExTag_ID = ByteToText(Stream.Read(Clng(Temp_Byte)),"Unicode") Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_ExTag_Flag = Clng(Temp_Byte) Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Temp_Byte = Clng(Temp_Byte) If Wma_Music_ExTag_Flag = 3 Then For Wma_Music_ExTag_Content_Index = 1 To Temp_Byte Step + 4 Temp_Byte = Hex(AscB(Stream.Read(1))) Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = Hex(AscB(Stream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte Wma_Music_ExTag_Content = Clng(Temp_Byte) Next Else Wma_Music_ExTag_Content = ByteToText(Stream.Read(Temp_Byte),"Unicode") End If Info.Item("ExTag").Item(Wma_Music_ExTag_ID) = Wma_Music_ExTag_Content Next End If For Temp_Index = 1 To 16 Wma_Tag_Header = Wma_Tag_Header & Hex(AscB(Stream.Read(1))) Next Wend End Sub Private Function ByteToText(ByteData,Coding) Dim MyStream,Temp_Byte Set MyStream = Server.CreateObject("Adodb.Stream") MyStream.Type = 1 MyStream.Mode = 3 MyStream.Open MyStream.Write ByteData MyStream.Position = 0 Select Case Coding Case "Unicode" If MyStream.Size Mod 2 = 0 Then While Not MyStream.EoS Temp_Byte = Hex(AscB(MyStream.Read(1))) Temp_Byte = Hex(AscB(MyStream.Read(1))) & Temp_Byte Temp_Byte = "&H" & Temp_Byte ByteToText = ByteToText & ChrW(Temp_Byte) Wend End If Case Else MyStream.Type = 2 MyStream.Charset = Coding ByteToText = MyStream.ReadText End Select MyStream.Close Set MyStream = Nothing End Function Private Function AlgorismToBinary(Algorism,Length) While Algorism <> 0 AlgorismToBinary = Algorism Mod 2 & AlgorismToBinary Algorism = Int(Algorism / 2) Wend While Len(AlgorismToBinary) < Length AlgorismToBinary = "0" & AlgorismToBinary Wend End Function Private Sub Class_Initialize() Standard_Wma_Header = "3026B2758E66CF11A6D90AA062CE6C" 'Wma鏂囦欢澶? Standard_Wma_Tag_Header = "3326B2758E66CF11A6D90AA062CE6C" 'Wma鏍囧噯Tag甯у悕 Standard_Wma_ExTag_Header = "40A4D0D27E3D21197F00A0C95EA850" 'Wma鎵╁睍Tag甯у悕 Standard_Mp3_ID3V2Tag_Header = "494433" 'Mp3ID3V2Tag鏍囩鍚? Mp3_Genres(0) = "Blues" Mp3_Genres(1) = "ClassicRock" Mp3_Genres(2) = "Country" Mp3_Genres(3) = "Dance" Mp3_Genres(4) = "Disco" Mp3_Genres(5) = "Funk" Mp3_Genres(6) = "Grunge" Mp3_Genres(7) = "Hip-Hop" Mp3_Genres(8) = "Jazz" Mp3_Genres(9) = "Metal" Mp3_Genres(10) = "NewAge" Mp3_Genres(11) = "Oldies" Mp3_Genres(12) = "Other" Mp3_Genres(13) = "Pop" Mp3_Genres(14) = "R&B" Mp3_Genres(15) = "Rap" Mp3_Genres(16) = "Reggae" Mp3_Genres(17) = "Rock" Mp3_Genres(18) = "Techno" Mp3_Genres(19) = "Industrial" Mp3_Genres(20) = "Alternative" Mp3_Genres(21) = "Ska" Mp3_Genres(22) = "DeathMetal" Mp3_Genres(23) = "Pranks" Mp3_Genres(24) = "Soundtrack" Mp3_Genres(25) = "Euro-Techno" Mp3_Genres(26) = "Ambient" Mp3_Genres(27) = "Trip-Hop" Mp3_Genres(28) = "Vocal" Mp3_Genres(29) = "Jazz+Funk" Mp3_Genres(30) = "Fusion" Mp3_Genres(31) = "Trance" Mp3_Genres(32) = "Classical" Mp3_Genres(33) = "Instrumental" Mp3_Genres(34) = "Acid" Mp3_Genres(35) = "House" Mp3_Genres(36) = "Game" Mp3_Genres(37) = "SoundClip" Mp3_Genres(38) = "Gospel" Mp3_Genres(39) = "Noise" Mp3_Genres(40) = "AlternRock" Mp3_Genres(41) = "Bass" Mp3_Genres(42) = "Soul" Mp3_Genres(43) = "Punk" Mp3_Genres(44) = "Space" Mp3_Genres(45) = "Meditative" Mp3_Genres(46) = "InstrumentalPop" Mp3_Genres(47) = "InstrumentalRock" Mp3_Genres(48) = "Ethnic" Mp3_Genres(49) = "Gothic" Mp3_Genres(50) = "Darkwave" Mp3_Genres(51) = "Techno-Industrial" Mp3_Genres(52) = "Electronic" Mp3_Genres(53) = "Pop-Folk" Mp3_Genres(54) = "Eurodance" Mp3_Genres(55) = "Dream" Mp3_Genres(56) = "SouthernRock" Mp3_Genres(57) = "Comedy" Mp3_Genres(58) = "Cult" Mp3_Genres(59) = "Gangsta" Mp3_Genres(60) = "Top40" Mp3_Genres(61) = "ChristianRap" Mp3_Genres(62) = "Pop/Funk" Mp3_Genres(63) = "Jungle" Mp3_Genres(64) = "NativeAmerican" Mp3_Genres(65) = "Cabaret" Mp3_Genres(66) = "NewWave" Mp3_Genres(67) = "Psychadelic" Mp3_Genres(68) = "Rave" Mp3_Genres(69) = "Showtunes" Mp3_Genres(70) = "Trailer" Mp3_Genres(71) = "Lo-Fi" Mp3_Genres(72) = "Tribal" Mp3_Genres(73) = "AcidPunk" Mp3_Genres(74) = "AcidJazz" Mp3_Genres(75) = "Polka" Mp3_Genres(76) = "Retro" Mp3_Genres(77) = "Musical" Mp3_Genres(78) = "Rock&Roll" Mp3_Genres(79) = "HardRock" Mp3_Genres(80) = "Folk" Mp3_Genres(81) = "Folk-Rock" Mp3_Genres(82) = "NationalFolk" Mp3_Genres(83) = "Swing" Mp3_Genres(84) = "FastFusion" Mp3_Genres(85) = "Bebob" Mp3_Genres(86) = "Latin" Mp3_Genres(87) = "Revival" Mp3_Genres(88) = "Celtic" Mp3_Genres(89) = "Bluegrass" Mp3_Genres(90) = "Avantgarde" Mp3_Genres(91) = "GothicRock" Mp3_Genres(92) = "ProgessiveRock" Mp3_Genres(93) = "PsychedelicRock" Mp3_Genres(94) = "SymphonicRock" Mp3_Genres(95) = "SlowRock" Mp3_Genres(96) = "BigBand" Mp3_Genres(97) = "Chorus" Mp3_Genres(98) = "EasyListening" Mp3_Genres(99) = "Acoustic" Mp3_Genres(100) = "Humour" Mp3_Genres(101) = "Speech" Mp3_Genres(102) = "Chanson" Mp3_Genres(103) = "Opera" Mp3_Genres(104) = "ChamberMusic" Mp3_Genres(105) = "Sonata" Mp3_Genres(106) = "Symphony" Mp3_Genres(107) = "BootyBass" Mp3_Genres(108) = "Primus" Mp3_Genres(109) = "PornGroove" Mp3_Genres(110) = "Satire" Mp3_Genres(111) = "SlowJam" Mp3_Genres(112) = "Club" Mp3_Genres(113) = "Tango" Mp3_Genres(114) = "Samba" Mp3_Genres(115) = "Folklore" Mp3_Genres(116) = "Ballad" Mp3_Genres(117) = "PowerBallad" Mp3_Genres(118) = "RhythmicSoul" Mp3_Genres(119) = "Freestyle" Mp3_Genres(120) = "Duet" Mp3_Genres(121) = "PunkRock" Mp3_Genres(122) = "DrumSolo" Mp3_Genres(123) = "Acapella" Mp3_Genres(124) = "Euro-House" Mp3_Genres(125) = "DanceHall" Mp3_Genres(126) = "Goa" Mp3_Genres(127) = "Drum&Bass" Mp3_Genres(128) = "Club-House" Mp3_Genres(129) = "Hardcore" Mp3_Genres(130) = "Terror" Mp3_Genres(131) = "Indie" Mp3_Genres(132) = "BritPop" Mp3_Genres(133) = "Negerpunk" Mp3_Genres(134) = "PolskPunk" Mp3_Genres(135) = "Beat" Mp3_Genres(136) = "ChristianGangstaRap" Mp3_Genres(137) = "HeavyMetal" Mp3_Genres(138) = "BlackMetal" Mp3_Genres(139) = "Crossover" Mp3_Genres(140) = "ContemporaryChristian" Mp3_Genres(141) = "ChristianRock" Mp3_Genres(142) = "Merengue" Mp3_Genres(143) = "Salsa" Mp3_Genres(144) = "TrashMetal" Mp3_Genres(145) = "Anime" Mp3_Genres(146) = "JPop" Mp3_Genres(147) = "Synthpop" End Sub End Class Sub FileList(Lookup_Path) Dim MyFileSystemObject,MyGetFolder,MySubFolders,Folder Dim MyFiles,File Dim Info,Info1,Mp3WmaInfo_,Infodd Set MyFileSystemObject = Server.CreateObject("Scripting.FileSystemObject") Set MyGetFolder = MyFileSystemObject.GetFolder(Lookup_Path) Set MySubFolders = MyGetFolder.SubFolders Set MyFiles = MyGetFolder.Files Set Mp3WmaInfo_ = New Mp3WmaInfo For Each Folder IN MySubFolders Call FileList(Folder.Path) Next For Each File IN MyFiles Response.Write "<table width=""100%"" border=""1"" cellpadding=""0"" cellspacing=""0"" bordercolor=""#EFEFEF""><tr onmouseout = ""javascript:this.style.backgroundColor = 'transparent'"" onmouseover = ""javascript:this.style.backgroundColor='#EEEEEE'"" onclick=""javascript:this.parentNode.rows[1].style.display == 'none' ? this.parentNode.rows[1].style.display = 'block':this.parentNode.rows[1].style.display = 'none'"">" Set Infodd = Mp3WmaInfo_.GetTag(File.Path,"gb2312") Response.Write "<td width=""30%"">" & File.Name & "</td>" Response.Write "<td width=""50%""><a href=""http://search.camxam.com/music/player.asp?title=" & File.Name & "&ext=mp3&url=http://search.camxam.com/0000002/" & Replace(Replace(File.Path,"G:\",""),"\","/") & """ target=""_blank"">" & File.Path & "</a></td>" Response.Write "<td width=""15%"">" & FormatNumber(File.Size / 1048576,2,-1,0,0) & "M</td>" Response.Write "</tr><tr style=""display:none""><td width=""100%"" colSpan = ""3"" style=""background-color:#EEEEEE"">" Response.Write "<table width=""100%"" border=""1"" cellpadding=""0"" cellspacing=""0"" bordercolor=""#BCBCBC"">" For Each Info IN Infodd Response.Write "<tr><td >" & Info & "</td>" Response.Write "<td >" If Infodd.Item(Info).Count > 0 Then Response.Write "<table width=""100%"" border=""1"" cellpadding=""0"" cellspacing=""0"" bordercolor=""#EEEEEE"">" For Each Info1 In Infodd.Item(Info) Response.Write "<tr><td width=""50%"">" & Info1 & "</td>" Response.Write "<td width=""50%"">" & Infodd.Item(Info)(Info1) & "</td></tr>" Next Response.Write "</table>" End If Response.Write "</td></tr>" Next Response.Write "</table></td>" Response.Write "</tr></table>" If Response.IsClientConnected = False Then Response.End() End If Next End Sub %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" > <title>鏃犳爣棰樻枃妗</title> </head> <body> <% Call FileList(Server.MapPath("music")) %> </body> </html> |
Leave a Reply