fredag 16 februari 2018

SPA <-> Spotify






Länkar


Kod

var endpointUrl = 'https://query.wikidata.org/sparql',
    sparqlQuery = "#defaultView:ImageGrid\n" +
        "select  ?person ?personLabel ?personDescription ?pic ?SPA  ?Spotify (SAMPLE(?birth) AS ?birth) {\n" +
        "{\n" +
        "   ?person wdt:P4819 ?SPAid . # SPAid\n" +
        "   ?person wdt:P1902 ?Spotifyid . # Spotify\n" +
        "   OPTIONAL {?person wdt:P569 ?birth} .\n" +
        "   OPTIONAL{ ?person wdt:P18 ?pic .} # If we have an illustration\n" +
        "   BIND (URI(CONCAT(\"https://porträttarkiv.se/details/\",?SPAid)) AS ?SPA)\n" +
        "   BIND (URI(CONCAT(\"https://open.spotify.com/artist/\",?Spotifyid)) AS ?Spotify)\n" +
        "  OPTIONAL { ?article schema:about ?person. }\n" +
        "\n" +
        " }   \n" +
        "  SERVICE wikibase:label { bd:serviceParam wikibase:language \"sv\",\"en\"}\n" +
        " }\n" +
        "Group by ?person ?personLabel ?personDescription ?pic ?SPA ?Geni ?SBL ?Spotify \n" +
        "Order by DESC(?birth)",
    settings = {
        headers: { Accept: 'application/sparql-results+json' },
        data: { query: sparqlQuery }
    };

$.ajax( endpointUrl, settings ).then( function ( data ) {
    $( 'body' ).append( ( $('<pre>').text( JSON.stringify( data) ) ) );
    console.log( data );
} );

Inga kommentarer:

Skicka en kommentar