: Aka Morten Skoglys nerdcave

Delicious Screenshots – my first wordpress plugin

Published oktober 21st, 2008 by
Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/7/5/b/ on line 75 Warning: file_get_contents( failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /customers/7/5/b/ on line 75 Warning: Invalid argument supplied for foreach() in /customers/7/5/b/ on line 79

If this works there should be about 6 thumbnails on this page, showing links bookmarked using Delicious, and tagged with «art».

Download here, version 0.7 of my very first wordpress plugin.

Activate plugin. And add your username to the options page. (under settings in the WordPress toolbar)

14.02.2017: Changed from rss to json and cleaned the code up a bit. Also removed Snapcasa from options.

What’s next:

  1. The first version of this plugin used Snapcasa for creating thumbnails, but I switched to to get a higher success rate.
  2. The count param doesn’t seem to do anything when calling the api, it always returns 10 results, so I need to handle that in the code instead. I’ve notified them of the bug.
  3. Testing other screenshotting services or making my own.
  4. Choosing an image from the page metadata when available.

Posted in Code, Open Source

Podcastplayer in flash! Php script to convert RSS to XSPF

Published mars 3rd, 2006 by

Big Sound, Little Ears

photo credit: …Tim

Create your own free flash based podcast / mp3 player

I like the flashbased XSPF mp3 player. I had planned to rewrite the actionscript so that it could read rss with enclosures instead, but I liked the possibility to have unique pictures on each track, and I wanted to check out the XSPF format.

So I wrote a PHP script that uses DOMXML and xpath to convert an existing rss to xspf, it even have a search function of sorts.

I’m going to use it on a project I’m working on after a little more tweaking but I wanted to share it with other people who has a podcast and want a quick open source way to present their podcasts on their website.

Localino meets elePHPant
photo credit: Chregu


$path = «»;

$showfile = file_get_contents($path);

if(!$doc = domxml_open_mem($showfile)) {

echo «Error while parsing the document…»;



$xpath = xpath_new_context($doc);

$root = $doc->document_element();


//echo domxml_version();

//var_dump(xpath_eval_expression($xpath, ‘/rss/channel/item’)); //

//debugging – memory dump

//echo $doc->dump_mem( true, ‘UTF-8′ ) ; //

//print » Path: <a href=\»$path\»>$path</a><br>\n»;

//print » Showfile: <a href=\»$showfile\»>$showfile</a><br>\n»;

//print » domDoc: <a href=\»$domDoc\»>$domDoc</a><br>\n»;

//print » root: <a href=\»$root\»>$root</a><br>\n»;

// playlist plus search function

$playlist = $xpath->xpath_eval(«/rss/channel/item[contains(translate(title,’abcdefghijklmnopqrstuvwxyzæøåö’, ‘ABCDEFGHIJKLMNOPQRSTUVWXYZÆØÅÖ’), ‘».strtoupper($_REQUEST[«search»]).»‘)]»);


//print «playlist found: «.count($playlist->nodeset).»\n»;

print «<?xml version=\»1.0\» encoding=\»UTF-8\» ?>\n»;

print «<playlist version=\»0\» xmlns=\»\»>\n»;

print » <title>Put clever title here, or get it from the rss</title>\n»;

print » <annotation>Description of some sort</annotation>\n»;

print » <creator>Who made this</creator>\n»;

print » <info>http://link to more info</info>\n»;

print » <location></location>\n»;

print » <license></license>\n»;

print «<trackList>\n»;

foreach ($playlist->nodeset as $tracklist) {

$description = «»;

$title = «»;

$enclosureurl = «»;

//$enclosureurl = $tracklist->get_attribute(«length»);

//$spor = $tracklist->get_attribute(«spor»);

//$sangid = «$arkivnr-$spor»;

foreach ($tracklist->child_nodes() as $child) {

if ($child->node_name() == «title») $title = $child->get_content();

if ($child->node_name() == «description») $description = $child->get_content();

if ($child->node_name() == «enclosure») $enclosureurl = $child->get_attribute(«url»);


print «<track>\n»;

print » <location>$enclosureurl</location>\n»;

print » <image>hassan/bilder/else150.jpg</image>\n»;

print » <annotation>$title</annotation>\n»;

print » <info></info>\n»;

print » <info_text>$description</info_text>\n»;

print » </track>\n»;


print «</trackList>\n»;

print «</playlist>\n»;


Copypaste the above code into a new file and save it as rss2xspf.php and upload it to your server to test if you have domxml support. (If you don’t it will say something like Call to undefined function: domxml_open_mem. In that case, tough luck, find a new host.)

Download the exellent XSPF flash based mp3 player here: XSPF Web Music Player (Flash) – Plays MP3 on your website

Read more about XSPF over at

And please drop a comment if you use it and like or have problems.

You can also send me an email at morten.skogly _at_ gmail dot com.

There’s a lot of room for improvement, like using the rss image in place of a staticly defined image, or inserting a random image, or doing som web2.0 stuff like snarfing the images from amazon or whatever, please let me know if you make something superclever with it :)

Idea for your site: You can use to make your own mp3 podcast, visit bands you like bookmark the mp3s you like with, go there to get the rss, and your set to go, you have the same music on your site as on your ipod :) (You might have to use as a gobetween to create the enclosures and make it itunes-compatible.)

Updated: 06.04.2008: Unless you really really digg the XSPF player linked up above, I suggest you use the superb Jeroen Media Player instead. It is open source and supports both XSPF and RSS directly. It takes up more space, but it has video support and a very cool javascript api.

Posted in Open Source Amazon Sambok and BIBSYS ISBN Search

Published oktober 1st, 2005 by

La caverne aux livres
photo credit: gadl

Hey, my first Greasemonkey userscript! Amazon Sambok ISBN Search:

This is just a fast remake of the Hight Library Linky script. Its my first script, just wanted to check out how hard it would be to rework. Luckily for me it was super easy. It inserts links to two norwegian bibliographical databases.

Bibsys, containing material from universities and colleges.
And Sambok, containing material from most Public Libraries in Norway.

Pretty useful, at least in theory, since ISBN search is quite limiting. But it will have to do for now.

Posted in Code, Ideas, Portfolio, Webdev