Creating web pages out of playlists

TridenT

Lifer
Sep 4, 2006
16,800
45
91
I want to take .txt files that are exported from iTunes, have them uploaded in a form on a website, then have those files processed, and finally have the output be a nice page with the playlist and other info I'll have the person put in. What languages should I be using to do this? I don't know many(or really any), but I'm willing to figure it out. There is another part that would involve storing the name of all songs, genres, albums, artists, etc., and then making statistics out of that, but I rather get this first part done before that. :p

Here is what iTunes does for a .txt file when exported.
Code:
Name    Artist    Composer    Album    Grouping    Genre    Size    Time    Disc Number    Disc Count    Track Number    Track Count    Year    Date Modified    Date Added    Bit Rate    Sample Rate    Volume Adjustment    Kind    Equalizer    Comments    Plays    Last Played    Skips    Last Skipped    My Rating    Location
Heaven Knows I'm Miserable Now    The Smiths        The Sound Of The Smiths        Indie    4236398    216    1    2    5    24    2008    1/22/2011 4:13 PM    8/27/2010 10:00 PM    156    44100        MPEG audio file            26    4/4/2011 6:11 PM                C:\SMITHY.MP3
Go Go Power Rangers (CD Version)    Aaron Waters - The Mighty RAW    Shuki Levy/Kussa Mahchi    Mighty Morphin Power Rangers: The Rock Adventure        Rock    4376576    273            1    12    1995    10/16/2010 7:59 PM    10/16/2010 8:00 PM    128    44100        MPEG audio file            22    4/4/2011 6:15 PM                C:\FILE\SOMEWHERE
Dancing Queen    ABBA         Top 100 Dance Hits        Dance    7352320    229            3            1/13/2011 7:44 PM    1/13/2011 7:43 PM    256    44100        MPEG audio file        jary    1    1/28/2011 6:47 PM                C:\SUPERLONG
I think the format iTunes uses should be easy to read. It's just the turning it into a web page part...

Where to start?:whiste:

View latest post to see latest version.
Currently has PLS, M3U, M3U8, iTunes TXT, and XML support.
http://www.sendspace.com/file/z4tb5y
If you want the PHP version:
http://www.sendspace.com/file/96x0tt
 
Last edited:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Any of the modern server-side scripting frameworks can easily handle this. You'll need a database or xml files for a store on the back end, some server script to process the uploaded text files and place the data in the store, and then some more server script to read the data from the store and format it into a page for display. Perhaps also some ancillary things like user registration, etc.

The Microsoft solution would be asp.net + sql server, with the implementation languages being c#, sql, and some javascript. The open source solution would be php or ruby on rails and MySQL. If you haven't done any of this before then starting from scratch will be daunting. You might be able to get most of the site functions from something like drupal, and write just enough code to handle the file processing and database calls.
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
Since you had some Java questions in here, that's also an option. You could create a simple JSP / servlet page that uses an XML API like JDOM to parse the text file upload into a XML document - then you could store in a database or wherever. Then you could run an XSL Transform on it to get your 'web page part'.

For testing without a webserver or backend, you can create a Java program that takes the file path to that txt file as input, then use the JDOM library to create XML and HTML files from your stylesheet. You'll have to write the XSL template.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
So many words here I don't know. D:

I would like to use any background I do have and Java is a bit of one, but very-very limited. I mean, really limited... I took one class with it.
 

mosco

Senior member
Sep 24, 2002
940
1
76
Since you had some Java questions in here, that's also an option. You could create a simple JSP / servlet page that uses an XML API like JDOM to parse the text file upload into a XML document - then you could store in a database or wherever. Then you could run an XSL Transform on it to get your 'web page part'.

For testing without a webserver or backend, you can create a Java program that takes the file path to that txt file as input, then use the JDOM library to create XML and HTML files from your stylesheet. You'll have to write the XSL template.

Wouldn't they also need something like Tomcat which is going above the limitations of cheap hosting.

You could do this a number of ways using php, perl, that would probably be faster and easier than trying to try a servlet to do this.


On a side note, have you searched for a utility to do this already? I think I have used programs in the past to make webpages out of itunes playlists.
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
My suggestion was solely based on him having done some java work, and the meat of it could be done without a server. Run a java class, get back two files.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Wouldn't they also need something like Tomcat which is going above the limitations of cheap hosting.

You could do this a number of ways using php, perl, that would probably be faster and easier than trying to try a servlet to do this.


On a side note, have you searched for a utility to do this already? I think I have used programs in the past to make webpages out of itunes playlists.

I'm not the best at finding anything in Google. I tried a little but got no results in my favor. Did a weird search. Found this: http://www.greeley.org/~hod/dj/iTunes.html It's not exactly what I want though. It's actually really off. It requires quite a few steps that I don't like at all.
 
Last edited:

TridenT

Lifer
Sep 4, 2006
16,800
45
91
I'm not the best at finding anything in Google. I tried a little but got no results in my favor. Did a weird search. Found this: http://www.greeley.org/~hod/dj/iTunes.html It's not exactly what I want though. It's actually really off. It requires quite a few steps that I don't like at all.

Reading XML/XSL files without knowing any XML at all is a real PITA. I don't know what I can or can't do or what most of these things do completely... For instance, it even has an
Code:
<xsl:if text="/include/@songs='yes'">
and so I think, "maybe it has other functions like loops and maybe I can have it load any file that is in some directory with a wildcard symbol?"
 

EagleKeeper

Discussion Club Moderator<br>Elite Member
Staff member
Oct 30, 2000
42,589
5
0
Using a multple set of tools.

Import the ASCII tet into Excel.

Paste the Excel table into Word.
Use Word to export a html file which should contain the table.
Not fancy, but it will work and is diffucult to foul up.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
My suggestion was solely based on him having done some java work, and the meat of it could be done without a server. Run a java class, get back two files.

I'd enjoy using Java almost solely for this, if that is possible. I would need to know the server requirements I guess. It would be nice for this to run on the server as a little applet then you upload the file into the applet, it processes it, and creates an HTML page which it will redirect you to. I'd also like it if it could update a page with the listings of all playlists with a link to the new one.
 

Tea Bag

Golden Member
Sep 11, 2004
1,575
3
0
Since iTunes can export the playlist format as XML, you don't need to generate XML again. But the most efficient way to go from that to HTML is using an XSLT, so there's really no escaping writing a transform to do what you're looking for regardless where you plan to host it for the extra stuff.

The most important part will be the stylesheet if you don't like any of the examples you've seen online. Then if you're hosting whatever language will have to perform that transform and return HTML. You can test the transform without any of that junk, you can do it with HTML and JavaScript.

Is doing this in Java overkill? Ya. But if you're ready for a learning curve and you have a google account, host it on App Engine and then you can tweak it and add stuff later if you want. Or try it in Python there. Or host it somewhere else, but at least you'll have your transform and you can use that regardless.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Bump.

I'm thinking of doing this with a Java Applet. Opinions and will it work?

Applet is there: you upload file. Applet then adds a link to an existing playlists page that will then take you to a new page that has the newly created playlist listed out for you.

Can I do that with a Java Applet reasonably?
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Bump.

I'm thinking of doing this with a Java Applet. Opinions and will it work?

Applet is there: you upload file. Applet then adds a link to an existing playlists page that will then take you to a new page that has the newly created playlist listed out for you.

Can I do that with a Java Applet reasonably?

Probably, but applets are really... I was going to say they suck but I just don't like them. You don't need an applet for this, but if that's the easiest approach for you then go for it.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Probably, but applets are really... I was going to say they suck but I just don't like them. You don't need an applet for this, but if that's the easiest approach for you then go for it.

I don't really know any other languages. :/ That's the only reason it seems easiest. I'm sure there are other methods and for this... I'm sure it'll be quick and painless for the users.

Preferably I'd have this applet enter all the data into a database and do some other fancy stuff, but that's way beyond my level.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Damn. I'm having trouble with the files. I can't use a scanner on them apparently. They just go, "HERP. NoSuchElement" when I do a scan.next(), but they do believe that scan.hasNextLine() is true.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Ok. Further along, but how do I get the Scanner class to not skip tabs? That's kinda essential to how my program will work... I don't know how the Pattern class works. It isn't very straight forward...

Figured a way to get around it.

Now I just have to do the implementing of HTML code.
 
Last edited:

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Alright. I made something stupid.
Just open an exported playlist from iTunes that is exported in .txt. It'll probably explode if you try anything else. Creates an HTML table of the stuff. It doesn't create a file though. You just copy the stuff from the text box.

http://www.sendspace.com/file/deeg0k


EDIT:Added a save functionality...
http://www.sendspace.com/file/7llc7x

EDIT2: Added no functionality, but did some changing. Thought about adding color options, but that's sorta useless at this point I think. Once we get to this being used on a server it will be different.
http://www.sendspace.com/file/jnmkn8
 
Last edited:

TridenT

Lifer
Sep 4, 2006
16,800
45
91
So, how am I supposed to get this to work online? I can't use just a Java Applet because Java Applets don't allow for access of client information. I need some script/program to upload the file then run the Java Applet with some extra information such as the file location on the server.

Ideas?
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
So, how am I supposed to get this to work online? I can't use just a Java Applet because Java Applets don't allow for access of client information. I need some script/program to upload the file then run the Java Applet with some extra information such as the file location on the server.

Ideas?
????
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net

I think you mostly answered your own question. Pre-HTML5, as far as I know, the only way to get the data from the user's hard drive and into the execution context of a script, applet, Silverlight app, etc., was to reflect the file off a server and let the code pull it from there.

In HTML5 there is a local sandboxed file system (implemented only in Chrome at this time, afaik), and I have read that you can copy files from the user's local file system into the sandbox and access them there. This page doesn't contain a complete explanation, but it should get you started...

http://www.html5rocks.com/en/tutorials/file/filesystem/
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
Btw. Found out there is this IDE called netbeans that has a GUI editor. That could make my life easier, but arguably it takes a quite a bit of learning.
 

TridenT

Lifer
Sep 4, 2006
16,800
45
91
I think you mostly answered your own question. Pre-HTML5, as far as I know, the only way to get the data from the user's hard drive and into the execution context of a script, applet, Silverlight app, etc., was to reflect the file off a server and let the code pull it from there.

In HTML5 there is a local sandboxed file system (implemented only in Chrome at this time, afaik), and I have read that you can copy files from the user's local file system into the sandbox and access them there. This page doesn't contain a complete explanation, but it should get you started...

http://www.html5rocks.com/en/tutorials/file/filesystem/

Yeah, I looked into some PHP stuff for the file uploading but I don't know how I am going to get it all to work.

Probably end up doing something like:
User uploads file in HTML environment by calling a PHP scriptything.
PHP then uploads file, saves it in one folder, and then puts it in another folder with the Java Applet. Redirects to page with Java Applet and Java Applet has code ready to be used because the Java Applet will automatically give code to the file just uploaded. (It will delete the file/clear-it after it is done converting it to HTML)


This all relies on me actually having a server to put it too... So annoying since I don't have a testbed for this shit.