Love Forum - Online Relationship Discussion
Quote of the month: "It is not the things we do in life that we regret on our death bed. It is the things we do not. Find your passion and follow it. " ~ Randy Pausch

 

Reply
 
LinkBack Thread Tools Rating: Thread Rating: 9 votes, 5.00 average. Display Modes
  #1 (permalink)  
Old 08-11-06, 09:53 AM
King Zarathu
 
Posts: n/a
MP3 Playlist to HTML
So I made this program last night while I was talking with TDurden. I should've been doing my homework...but...yeah....

http://www.thesarcasm.com/Music.html

Code:
import java.util.*; import java.io.*; import org.farng.mp3.*; import org.farng.mp3.id3.*; import org.farng.mp3.lyrics3.*; public class MP3HTML { public static BufferedWriter out; public static void main(String[] args) throws IOException, TagException { Scanner in = new Scanner(new File("All.m3u")); String newIn = "", artist = "", title = ""; int progress = 0, total = 0; out = new BufferedWriter( new PrintWriter( new FileWriter( new File("Music.html")))); MP3Class mp3; ID3v1 id3v1 = new ID3v1(); ID3v2_2 id3v2_2 = new ID3v2_2(); ID3v2_3 id3v2_3 = new ID3v2_3(); ID3v2_4 id3v2_4 = new ID3v2_4(); writeHeader(); while(in.hasNext()){in.nextLine(); total++;} in = new Scanner(new File("All.m3u")); while(in.hasNext()) { mp3 = new MP3Class(in.nextLine()); if(mp3.getType() == 1) { try {id3v1 = new ID3v1(new RandomAccessFile(mp3.getLocation(), "r"));} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} try {writeSong(id3v1.getLeadArtist(), id3v1.getSongTitle());} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} } else if(mp3.getType() == 22) { try {id3v2_2 = new ID3v2_2(new RandomAccessFile(mp3.getLocation(), "r"));} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} try {writeSong(id3v2_2.getLeadArtist(), id3v2_2.getSongTitle());} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} } else if(mp3.getType() == 23) { try {id3v2_3 = new ID3v2_3(new RandomAccessFile(mp3.getLocation(), "r"));} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} try {writeSong(id3v2_3.getLeadArtist(), id3v2_3.getSongTitle());} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} } else if(mp3.getType() == 24) { try {id3v2_4 = new ID3v2_4(new RandomAccessFile(mp3.getLocation(), "r"));} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} try {writeSong(id3v2_4.getLeadArtist(), id3v2_4.getSongTitle());} catch (Exception e) {writeSong("Broken Tag", "Broken Tag");} } System.out.println(progress + "/" + total); progress++; } writeFooter(); out.close(); } public static void writeHeader() throws IOException { out.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD Xhtml 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"); out.write("<html>"); out.newLine(); out.write("\t<head>"); out.newLine(); out.write("\t\t<title>TheSarcasm.com - I rule</title>"); out.newLine(); out.write("\t\t<link rel=\"stylesheet\" href=\"style.css\" type=\"text/css\" media=\"screen\" />"); out.newLine(); out.write("\t</head>"); out.newLine(); out.newLine(); out.write("<style type=\"text/css\">"); out.newLine(); out.write("*"); out.newLine(); out.write("{"); out.newLine(); out.write("\tpadding: 0;"); out.newLine(); out.write("\tmargin: 0;"); out.newLine(); out.write("}"); out.newLine(); out.write("body"); out.newLine(); out.write("{"); out.newLine(); out.write("\tbackground: #000000;"); out.newLine(); out.write("\ttext-align: center;"); out.newLine(); out.write("\tfont-size: 100%;"); out.newLine(); out.write("}"); out.newLine(); out.write("div"); out.newLine(); out.write("{"); out.newLine(); out.write("\ttext-align: left;"); out.newLine(); out.write("}"); out.newLine(); out.write("a"); out.newLine(); out.write("{"); out.newLine(); out.write("\ttext-decoration: none;"); out.newLine(); out.write("\tcolor: #00ffff;"); out.newLine(); out.write("\tfont: .6em Verdana,sans-serif;"); out.newLine(); out.write("}"); out.newLine(); out.write("a:hover"); out.newLine(); out.write("{"); out.newLine(); out.write("\ttext-decoration: underline;"); out.newLine(); out.write("}"); out.newLine(); out.write("#wrapper"); out.newLine(); out.write("{"); out.newLine(); out.write("\tmargin: 0 auto;"); out.newLine(); out.write("\twidth: 779px;"); out.newLine(); out.write("\tbackground-image: url(http://www.thesarcasm.com/images/body.jpg);"); out.newLine(); out.write("\tbackground-repeat: repeat-y;"); out.newLine(); out.write("}"); out.newLine(); out.write("#header"); out.newLine(); out.write("{"); out.newLine(); out.write("\tbackground: url(http://www.thesarcasm.com/images/head.jpg);"); out.newLine(); out.write("\theight: 198px;"); out.newLine(); out.write("\tbackground-repeat: repeat-y;"); out.newLine(); out.write("}"); out.newLine(); out.write("#main"); out.newLine(); out.write("{"); out.newLine(); out.write("\tfloat: left;"); out.newLine(); out.write("\twidth: 629px;"); out.newLine(); out.write("\tbackground: transparent;"); out.newLine(); out.write("}"); out.newLine(); out.write("#main p"); out.newLine(); out.write("{"); out.newLine(); out.write("\tfont: 0.7em Verdana,sans-serif;"); out.newLine(); out.write("\tcolor: #ffffff;"); out.newLine(); out.write("\tline-height: 1.7em;"); out.newLine(); out.write("\tmargin: .5em 100px .5em 100px;"); out.newLine(); out.write("}"); out.newLine(); out.write("#main a"); out.newLine(); out.write("{"); out.newLine(); out.write("\tcolor: #00ffff;"); out.newLine(); out.write("}"); out.newLine(); out.write("#main img"); out.newLine(); out.write("{"); out.newLine(); out.write("\tmargin-left: 10px;"); out.newLine(); out.write("\tpadding: 2px;"); out.newLine(); out.write("}"); out.newLine(); out.write("#sidebar"); out.newLine(); out.write("{"); out.newLine(); out.write("\tfloat: right;"); out.newLine(); out.write("\twidth: 150px;"); out.newLine(); out.write("\tpadding: 0 0 1em 0;"); out.newLine(); out.write("\tbackground: transparent;"); out.newLine(); out.write("}"); out.newLine(); out.write("#sidebar li"); out.newLine(); out.write("{"); out.newLine(); out.write("\tmargin: 0 .2 0 0em;"); out.newLine(); out.write("\tpadding: 2px 0 0 .5em;"); out.newLine(); out.write("\tlist-style-type: none;"); out.newLine(); out.write("}"); out.newLine(); out.write("#sidebar a"); out.newLine(); out.write("{"); out.newLine(); out.write("\ttext-align: right;"); out.newLine(); out.write("\tcolor: #00ffff;"); out.newLine(); out.write("\tfont: .6em Verdana,sans-serif;"); out.newLine(); out.write("}"); out.newLine(); out.write("#sidebar p"); out.newLine(); out.write("{"); out.newLine(); out.write("\ttext-align: left;"); out.newLine(); out.write("\tpadding: 2px 0 0 .0;"); out.newLine(); out.write("\tcolor: #ffffff;"); out.newLine(); out.write("\tfont: .8em Verdana,sans-serif;"); out.newLine(); out.write("}"); out.newLine(); out.write("#footer"); out.newLine(); out.write("{"); out.newLine(); out.write("\tclear: both;"); out.newLine(); out.write("\tmargin: 0 auto;"); out.newLine(); out.write("\tpadding: .5em;"); out.newLine(); out.write("\ttext-align: center;"); out.newLine(); out.write("\tbackground-image: url(http://www.thesarcasm.com/images/foot.jpg);"); out.newLine(); out.write("\theight: 24px;"); out.newLine(); out.write("}"); out.newLine(); out.write("#footer a"); out.newLine(); out.write("{"); out.newLine(); out.write("\tfont: .6em Verdana,sans-serif;"); out.newLine(); out.write("\tcolor: #00ffff;"); out.newLine(); out.write("}"); out.newLine(); out.write("#footer p"); out.newLine(); out.write("{"); out.newLine(); out.write("\tfont: .6em Verdana,sans-serif;"); out.newLine(); out.write("\tcolor: #ffffff;"); out.newLine(); out.write("}"); out.newLine(); out.write("</style>"); out.newLine(); out.write("\t<body>"); out.newLine(); out.write("\t\t<br /><br />"); out.newLine(); out.write("\t\t<div id=\"wrapper\">"); out.newLine(); out.write("\t\t<div id=\"header\">"); out.newLine(); out.write("\t\t\t<p align=\"center\"><br />"); out.newLine(); out.write("\t\t\t\t<img src=\"images/front.jpg\" />"); out.newLine(); out.write("\t\t\t</p>"); out.newLine(); out.write("\t\t</div>"); out.newLine(); out.write("\t\t<div id=\"main\"><br /><br />"); out.newLine(); out.write("\t\t\t<center>"); out.newLine(); out.write("\t\t\t\t<TABLE BORDER=\"1\">"); out.newLine(); out.write("\t\t\t\t<TR>"); out.newLine(); out.write("\t\t\t\t<TD ALIGN=\"center\"><p>Artist</p></TD>"); out.newLine(); out.write("\t\t\t\t<TD ALIGN=\"center\"><p>Title</p></TD>"); out.newLine(); out.write("\t\t\t\t</TR>"); out.newLine(); } public static void writeSong(String artist, String title) throws IOException { out.write("\n"); out.write("\t\t\t\t<TR>"); out.newLine(); out.write("\t\t\t\t<TD ALIGN=\"center\"><p>" + artist + "</p></TD>"); out.newLine(); out.write("\t\t\t\t<TD ALIGN=\"center\"><p>" + title + "</p></TD>"); out.newLine(); out.write("\t\t\t\t</TR>"); out.newLine(); } public static void writeFooter() throws IOException { out.write("</TABLE>"); out.newLine(); out.write("</center>"); out.newLine(); out.write("<br /><br />"); out.newLine(); out.write("</div>"); out.newLine(); out.write("<div id=\"footer\">"); out.newLine(); out.write("<a href=\"http://www.thesarcasm.com\">A Cock In Everyone's Mouth</a><br />"); out.newLine(); out.write("<a href=\"http://www.whitepaperclip.com\">WPC Productions</a>"); out.newLine(); out.write("</DIV>"); out.newLine(); out.write("</div>"); out.newLine(); out.write("<br /><br />"); out.newLine(); out.write("</body>"); out.newLine(); out.write("</html>"); out.newLine(); } }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Loveforum Breaktime
love

Loveforum also recommend

  • Green tea - Help in weight loss and decrease rate of getting cancer.
  #2 (permalink)  
Old 08-11-06, 09:54 AM
King Zarathu
 
Posts: n/a
Code:
class MP3Class { private static String MP3Location = ""; private static int idNum = 0; public static ID3v1 id3v1; public static ID3v2_2 id3v2_2; public static ID3v2_3 id3v2_3; public static ID3v2_4 id3v2_4; public MP3Class(String loc) throws IOException, TagException { try { id3v1 = new ID3v1(new RandomAccessFile(loc, "r")); idNum = 1; } catch (TagNotFoundException e) { try { id3v2_2 = new ID3v2_2(new RandomAccessFile(loc, "r")); idNum = 22; } catch (TagNotFoundException e1) { try { id3v2_3 = new ID3v2_3(new RandomAccessFile(loc, "r")); idNum = 23; } catch (TagNotFoundException e2) { try { id3v2_4 = new ID3v2_4(new RandomAccessFile(loc, "r")); idNum = 24; } catch (TagNotFoundException e3) {} } } } MP3Location = loc; } public void setLocation(String path) { MP3Location = path; } public String getLocation() { return MP3Location; } public int getType() { return idNum; } public String toString() { return MP3Location; } }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 09-11-06, 01:40 PM
Illusional Illusional is offline
different state of mind
 
Join Date: Sep 2001
Gender: Male
Posts: 12,831
My Mood:
Thanks: 14
Thanked 302 Times in 254 Posts
Illusional is a jewel in the roughIllusional is a jewel in the roughIllusional is a jewel in the roughIllusional is a jewel in the roughIllusional is a jewel in the rough
Send a message via ICQ to Illusional Send a message via AIM to Illusional Send a message via MSN to Illusional
speaking of which, what program do you use to d/l music?

raverboy
__________________
...this is just my perspective on the situation...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Loveforum Breaktime
love

Loveforum also recommend

  • Green tea - Help in weight loss and decrease rate of getting cancer.
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +8. The time now is 09:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

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