X-Mas time...
I just got my wife a nice WiFi Radio (yes, she does not give a sh** about this blog). She loves to listen to internet radio stations so it seemed like a cool gift. We'll know for sure in less than 4 days.
Anyway. I unwrapped it to make sure it works and to preinitialize it with some presets she likes. But wait! What about my presets? Yes, I love to listen to podcasts. While the device itself has some support for RSS feeds (browsing my genre, country etc.) - it won't allow adding a RSS feed to your favorites / bookmarks. Here it will only accept playlists.
A minor inconvenience you can fix with some PHP and SimplePie. Here is a small script which will convert any arbitrary RSS Feed to a PLS ... well, playlist :)
<?php require_once("simplepie.inc"); function getFeedItems($rss, $numberOfFeedItemsToFetch = 50) { $feed = new SimplePie($rss); $feed->init(); $feed->handle_content_type(); return $feed->get_items(0,$numberOfFeedItemsToFetch); } $numEntries= $_GET["numEntries"]; if (!$numEntries) $numEntries=50; if (!$url) $url = "http://feeds.feedburner.com/cnet/buzzoutloud?tag=rtcol"; $items = getFeedItems($url,$numEntries); foreach($items as $item) { if ($item->get_enclosure()) { $plsEntry["title"] = $item->get_title(); $plsEntry["link"] = $item->get_enclosure()->link; $plsEntry["length"] = (int) $item->get_enclosure()->length; $plsItems[] = $plsEntry; } } ?>[playlist] <? for ($i=0; $i<count($plsItems); $i++) { } ?>
The usage is quite simple. Call the script like this:
http://myserver/the_script.php?url=[encoded rss url]&numEntries=[optional: max number of entries in the pls]
If you don't know how to encode a URL properly, try this:
javascript:document.write(escape("http://your.friggin.url/feed.xml")) into the address barIf the Feed-URL does not contain any parameters (chars such as &, ? or =) you probably won't need to encode it. Won't hurt though!
You also might want to add a fake URL part (path info) if your client needs that .pls ending in the url. so the script-call would be like:
http://myserver/the_script.php/fake.pls?url=...&numEntries=...
Oh! And you will need a copy of SimplePie for the script to work. Grab it over here