Skip to content

Instantly share code, notes, and snippets.

Last active Dec 23, 2015
What would you like to do?
Open Beelden data loader
<?php // written by AJ Slaghuis (c) 2013
$input = 'FIN-180912-3681a_hd'; // the video name we are looking for
// let's not bang too much on the openbeelden server
if (!file_exists('download.xml')) {
$file = file_get_contents('');
file_put_contents('download.xml', $file);
$xml = simplexml_load_file('download.xml'); // print_r(scandir('.'));
$namespaces = $xml->getNamespaces(true); //print_r($namespaces);
$records = $xml->ListRecords->record;
foreach ($records as $record) {
// $record->header->identifier, datestamp and setSpec
// print_r($record->header);
$data = $record->metadata->children($namespaces['oai_dc']);
$rows = $data->children($namespaces['dc']);
/* print_r($rows), $rows->title, creator, subject, description, publisher, contributor,
* date, type, format[i], identifier, source, relation[?], language, coverage[i], rights
/* use this for debugging your XML marker and checking namespaces
foreach ($rows->title as $title) {
if ($title == $input) {
print($title . "\n");
$uris = (array) $rows->format;
foreach ($uris as $uri) {
$arr = explode('.', $uri); //print(end($arr) . "\n");
if (end($arr) == 'png') {// print($uri);
$farr = explode('/', $arr[sizeof($arr) - 2]);
$filename = end($farr) . '.' . end($arr); // print($filename);
if (!file_exists($filename)) {
$content_file = file_get_contents($uri);
file_put_contents($filename, $content_file);
Copy link

gerbenjacobs commented Sep 17, 2013

Nice example, but uncommon input. Why not something more dynamic, with an hint of preventing information overflow?

Copy link

ajslaghu commented Sep 20, 2013

I thought to illustrate a bridge from searching the web interface (seeing a picture or categorie one likes ) to actually getting it.

Making it more dynamic. We could do some random stuf, in the other Gist (NieuwsQuiz) I actually do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment