PDA

Click to See Complete Forum and Search --> : Radio station - get playlist information


NickThissen
Apr 5th, 2010, 04:03 PM
Hi,

First of all, I have no idea where I should post this, so I decided to do it here... If it's not appropriate feel free to move it :)


I am creating a desktop application (using C#, but that's irrelevant) that plays a live stream of a popular radio station (3FM). I was previously using a Windows Gadget for this, but it's no longer working properly, and instead of trying to fix it I decided to make my own 'gadget'.

I have no problem playing the stream (it's simply a media player control that plays the URL of the live stream).

One of the nice features of the gadget however, and also one of the reasons it's no longer working, is that it displayed the name of the song and artist currently playing.
I've taken a look at the javascript behind the gadget, and it simply downloaded an XML file from the radio station's website, which is now no longer available (the radio station's website has been heavily updated).

So, I am now looking for a new way to get this information.
I found a promising website:
http://nieuw.3fm.nl/welkliedjewasdat

It shows the current song, the name of the program currently running, and a list of previously played songs.
Just in case your Dutch isn't up to scratch (come on ;)), here's a screenshot showing which part is which:
http://i44.tinypic.com/9aoie0.jpg
(of course, the songs will be different if you view it at a different time then my screenshot..)


Now, this is what I need to get. I have looked in the HTML source of this page, hoping to find out where they got this information from, but the song names seem 'hardcoded'.
For example, this is the HTML for the 'Huidige track' and 'Dit uur' part:
<div class="boxheader boxheader_between_medium boxheader_between_border">
<h3>Huidige track</h3>
</div>

<div class="boxcontent boxcontent_between_border padded nowplaying">
<span class="artist">coldplay</span> - <span class="track">hardest part</span>
</div>

<div class="boxheader boxheader_between_medium boxheader_between_border">
<h3>Dit uur: <a href="#">3VOOR12RADIO</a> - maandag 05 april 2010 - 22:00 - 23:00</h3>
</div>

(Note, I made the screenshot just before I opened the HTML source, so the HTML is at a later time. The song currently playing is now coldplay, no longer lady gaga (thank god for that..) as in the screenshot)

So, I can't figure out from this where they got it from...

Now finally my question.. Can you? Or do I have to find a different way to get the playlists? I am finding it kind of strange that the names are hardcoded into the HTML. Probably their server updates this particular HTML file every few seconds/minutes with the updated info... Right?

But, then, how does the refresh button work next to the current song? The page doesn't reload when you click it, only the current song!
But strangle enough, I cannot find that button anywhere in the HTML code. It should be in the little part that I posted, right? It's right between those two lines, yet it's not in the html code anywhere...

I'm stumped. Can anyone help me on this?


EDIT
Of course I may be able to just get the entire HTML source of this page, and then parse that manually to get the songs. That is kind of a last resort. I did things like that in the past and found it was pretty slow (using a web request or something?) and it would need to update at least once every 30 seconds or so to stay up to date.

techgnome
Apr 5th, 2010, 04:44 PM
Unless the website provides a file with the info... there's not much you can do about that.
It may be possible to extract the data from the stream itself... but only if the radio station sends that information along with the stream.
If they don't provide a file with the info and you can't get it out of the stream... then you're going to have to resort to what amounts to a screen scrape.

-tg

NickThissen
Apr 5th, 2010, 05:03 PM
Ah, I think I've found a better way. I found a Firefox addon that displays the current song for this radiostation, so I just took a peek and apparently the information is found here:
http://www.3fm.nl/data/dalet/dalet.xml

Easy enough to parse :)
Unfortunately no previous songs, etc. But I suppose I could just store them myself so that's not a big problem.

Thanks anyway!