[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1686] Proof-of-concept RDF dumper.
From: |
Toby Inkster |
Subject: |
[Librefm-commits] [1686] Proof-of-concept RDF dumper. |
Date: |
Mon, 18 May 2009 16:03:20 +0000 |
Revision: 1686
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1686
Author: tobyink
Date: 2009-05-18 16:03:19 +0000 (Mon, 18 May 2009)
Log Message:
-----------
Proof-of-concept RDF dumper.
Added Paths:
-----------
trunk/scripts/users_dump_rdf.php
Added: trunk/scripts/users_dump_rdf.php
===================================================================
--- trunk/scripts/users_dump_rdf.php (rev 0)
+++ trunk/scripts/users_dump_rdf.php 2009-05-18 16:03:19 UTC (rev 1686)
@@ -0,0 +1,64 @@
+<?php
+
+include '../nixtape/config.php';
+include '../nixtape/database.php';
+include '../nixtape/utils/linkeddata.php';
+
+function htmlnumericentities($str)
+{
+ return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)',
$str);
+}
+
+$username = $argv[1];
+if (! $username)
+{
+ die("Must provide a username.\n");
+}
+
+$user = new User($username);
+$scrobbles = $user->getScrobbles(10000);
+
+print "<rdf:RDF
+ xmlns=\"http://purl.org/ontology/mo/\"
+ xmlns:bio=\"http://purl.org/vocab/bio/0.1/\"
+ xmlns:dc=\"http://purl.org/dc/terms/\"
+ xmlns:foaf=\"http://xmlns.com/foaf/0.1/\"
+ xmlns:gob=\"http://purl.org/ontology/last-fm/\"
+ xmlns:mo=\"http://purl.org/ontology/mo/\"
+ xmlns:rdfs=\"http://www.w3.org/2000/01/rdf-schema#\"
+ xmlns:sioc=\"http://rdfs.org/sioc/ns#\"
+ xmlns:rss=\"http://purl.org/rss/1.0/\"
+ xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"
+ xmlns:geo=\"http://www.w3.org/2003/01/geo/wgs84_pos#\"
+ xml:lang=\"en\">\n";
+
+while ($s = array_shift($scrobbles))
+{
+ printf("
+ <gob:ScrobbleEvent rdf:about=\"%s\">
+ <gob:user rdf:resource=\"%s\" />
+ <gob:track_played>
+ <Track rdf:about=\"%s\" dc:title=\"%s\">
+ <foaf:maker>
+ <MusicArtist rdf:about=\"%s\"
foaf:name=\"%s\" />
+ </foaf:maker>
+ </Track>
+ </gob:track_played>
+ <dc:date
rdf:datatype=\"http://www.w3.org/2001/XMLSchema#dateTime\">%s</dc:date>
+ </gob:ScrobbleEvent>
+ <Record about=\"%s\">
+ <track rdf:resource=\"%s\" />
+ </Record>\n",
+ htmlnumericentities($s['id']),
+ htmlnumericentities($user->id),
+ htmlnumericentities($s['id_track']),
+ htmlnumericentities($s['track']),
+ htmlnumericentities($s['id_artist']),
+ htmlnumericentities($s['artist']),
+ htmlnumericentities($s['timeiso']),
+ htmlnumericentities($s['id_album']),
+ htmlnumericentities($s['id_track'])
+ );
+}
+
+print "</rdf:RDF>\n";
\ No newline at end of file
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1686] Proof-of-concept RDF dumper.,
Toby Inkster <=