0

I'm working on a website that lists music for a user to chose from that based on data in a json file. The file contains information like the album name, artist, year it was released, the number of tracks etc. and, where I'm struggling, an .m3u file containing a playlist for all the songs on that album.

I'm not having a problem actually playing the .m3u file but my problem comes where I need to extract the .mp3 file names from the .m3u file and display them in a list on the website so the user can see the songs on the album before they play it or choose individual songs to listen to.

I have everything in place to display a list, even using the number of tracks data from the json file to make sure it's the right length, but I'm struggling with a way to extract this data.

Here's an example of one of the files;

#EXTM3U

#EXTINF:9,Horrible Theme
mp3/01 - Horrible Theme.mp3

#EXTINF:114,My Freeze Ray
mp3/02 - My Freeze Ray.mp3

#EXTINF:35,Bad Horse Chorus
mp3/03 - Bad Horse Chorus.mp3

And so on all the way down to the final file

#EXTINF:132,Horrible Credits
mp3/14 - Horrible Credits.mp3

I'm not sure if this will be a problem, but there are also some .m3u files that I need to extract the .mp3 file names from that have all data on a single line. Like this;

#EXTM3U#EXTINF:9,Horrible Thememp3/01 - Horrible Theme.mp3#EXTINF:114,My Freeze Raymp3/02 - My Freeze Ray.mp3#EXTINF:35,Bad Horse Chorusmp3/03 - Bad Horse Chorus.mp3

I was wondering if anyone has dealt with something similar to this before and whether or not they could help explain how this might be done using jquery?

Thanks.

marekful
  • 14,986
  • 6
  • 37
  • 59
OTill
  • 1
  • 1
  • Welcome to SO! While I think it's basically a good question, without any specific problems in your existing code it's way too broad to fit here. I suggest you show what you've tried and what doesn't work specifically. – MeanGreen Aug 12 '15 at 09:28
  • what is source for this .m3u files, are you getting from any web service? – venkat7668 Aug 12 '15 at 09:29
  • @venkat7668 The m3u file is from a server, the paths for the mp3 files are relative to the position of the m3u file on the server which is why they're not complete paths. – OTill Aug 12 '15 at 09:35

1 Answers1

0

You have newline characters generated by one system and read/interpreted by another. E.g. the file was created on Mac and read on Windows or Linux or vice verse. Some advanced editors like Editplus or Kate allow you to convert line endings between different formats in a single operation. It's also possible to process the file with a program or script that detects different types of newline characters and parses accordingly.

marekful
  • 14,986
  • 6
  • 37
  • 59