By or on
Hi there!
I'm in a middle of programming a drupal based radio station and wonder if someone can tell me
and easy way to take the songs&band title and put it on the block.
I'm working rith winamp and shoutcast.
I saw a very nice example at http://kwhl.com - which also have a link to buy it in amazon.
What is the best way to get this done? How they did it?
thanks
ori
Comments
Have you looked at
Have you looked at http://drupal.org/handbook/modules/station and http://groups.drupal.org/radio ?
If these modules don't have what you need, then your problem is twofold. You need:
- a way for the Drupal server to query the backend (shoutcast?) and find out what's currently playing. Presumably it's got some API? Check the module.
- a way to present this on the page, presumably in a block, maybe with AJAX refresh
Look at the links above, then post here if you're no closer to a solution.
Shoutcast XML stats
Shoutcast server provides a very simple method to request real-time stats as an XML file. Model your URL as follows:
http://adminuser:adminpass@example.com:port/admin.cgi?mode=viewxml
You should look at the FeedAPI module (http://drupal.org/project/feedapi) as a way to query that feed.
The SONGTITLE and SONGURL elements in the XML can be mapped to CCK fields. Note that your encoder or radio station software needs to be configured to send the song/artist to the Shoutcast server, otherwise those elements are going to be empty.
While the tip about
While the tip about shoutcast is useful, you only need feedapi/cck if you intend to create a node with this information. Otherwise just load it into XML, parse it with SimpleXML, and put it into a short-lifetime cache.
I haven't looked at it, and
I haven't looked at it, and it seems rather unmaintained, but see http://drupal.org/project/shoutcast
Good point...
Good point... if you don't need to maintain playlists and are just looking to display the real-time data, then there's no need to create a node.
very useful, thank you both
can you please tell me what should I learn in order to accomplish this?
I mean: "Otherwise just load it into XML, parse it with SimpleXML, and put it into a short-lifetime cache."
how do I make it?
You need to write a simple
You need to write a simple module, probably a dozen lines of code. The module would be configured with a shoutcast-server URL (say http://adminuser:adminpass@example.com:port/admin.cgi?mode=viewxml)
This module would also provide a block for your pages. In order to generate the block, the module would simple look in the Drupal cache, see if there was a recent copy (of the XML), and if so use it. If not, it would pull the XML from the backend and put it into the cache.
Either way, the result would then be formatted (via a theming function, with a default implementation in the module) to produce something presentable. If you talk nicely to me, and provide me with a shoutcast server to test, I might do this for you.
shoutcast "now playing" integration
At the end iv'e putted this bit of PHP code in a block
and it's work well!
so thank you, I very much appreciate your help!
so for now I talk to nice anyway :)
cheers
There are many optimizations
There are many optimizations you could/should make to this code. At the very least, cache your data (say, for 30 seconds), so every single web-user doesn't cause a hit to the shoutcast server. See http://www.lullabot.com/articles/a_beginners_guide_to_caching_data
hey, i know this thread is
hey, i know this thread is old but i made a little module wich provides 3 blocks.
2 x "now playing" (one with a link to the radio page and one w/)
1 x "song history"
there are also some config options.
but it's my very first module i wrote for drupal and i'm very unsure if it's good enough to upload/share. there you go for screenshots. drop me a line if you're interested in using it. i'll use it on my own radio project soon.
http://img43.imageshack.us/i/radiostatsnowplaying.png/
http://img22.imageshack.us/i/radiostatshistory.png/
http://img43.imageshack.us/i/radiostatsconfig.png/
greetings
ps: i didn't figured out yet how to enable caching correctly on this. i'll learn i guess ;-)
Maybe this is enough?
I did need the nodes, so I just changed the XML that shoucast provides to make it so the FeedAPI module CAN read it. A little auto block refresh, some views, and a fast acting cron gives your page a rather dynamic and live feel.
http://lukeollett.com/blog/2009/08/18/drupal-6-shoutcast-rss/