Skip to content

Instantly share code, notes, and snippets.

View Abbe98's full-sized avatar
📧
Tons of notifications here, send me an email instead.

Albin Larsson Abbe98

📧
Tons of notifications here, send me an email instead.
View GitHub Profile
// ==UserScript==
// @name Riksarkivet tumbnails
// @namespace https://sok.riksarkivet.se/
// @description
// @version 1.0
// @author Albin Larsson
// @match https://sok.riksarkivet.se/*
// @grant none
// ==/UserScript==
import csv
import datetime
import requests
import pywikibot
site = pywikibot.Site('wikidata', 'wikidata')
repo = site.data_repository()
endpoint='https://api.smk.dk/api/v1/iiif/manifest/?id='
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Abbe98
Abbe98 / sparql.ql
Last active November 27, 2018 13:59
Europeana SparQL stuff
PREFIX edm: <http://www.europeana.eu/schemas/edm/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?ku ('sameAs' AS ?relation) ?uri WHERE {
?item dc:identifier ?ku .
filter contains(?ku, 'kulturarvsdata.se') .
BIND(REPLACE(STR(?item), "proxy/provider", "item") AS ?uri)
}
LIMIT 10
@Abbe98
Abbe98 / ugc-csv-import.py
Last active July 24, 2022 12:48
Python script for importing CSV to ugc.kulturarvsdata.se
import csv
from ksamsok import KSamsok
from sochugc import UGC
api_key = input('Please enter your API key: ')
file_name = input('The name of input CSV: ')
username = input('Which username would you like to use: ')
soch = KSamsok()
import csv
import datetime
import requests
import pywikibot
site = pywikibot.Site('wikidata', 'wikidata')
repo = site.data_repository()
endpoint='https://sync.nm.delorean.se/objects?id='
const fetchJson = async (url) => await (await fetch(url, { headers: new Headers({ 'Accept': 'application/json' }) })).json();
const sochQuery = async (query) => {
const json = await fetchJson(`http://www.kulturarvsdata.se/ksamsok/api?x-api=test&method=search&query=geoDataExists=n%20AND%20thumbnailExists=j%20AND%20itemType=foto&recordSchema=xml&fields=itemDescription,itemLabel,thumbnail,byline,copyright,mediaLicense&startRecord=10000`);
return json.result.records.record.map(r => r['field']);
}
console.log(sochQuery(''))
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns="http://kulturarvsdata.se/ksamsok#"
xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:time="http://www.w3.org/2006/time#">
<!-- här kommer nu institutionens alla objekt (resp alla nyligen ändrade objekt) -->
<Entity rdf:about="http://kulturarvsdata.se/{{inst}}/wikimedia/page-id">
<ksamsokVersion>1.1</ksamsokVersion>
<serviceName>wikimedia</serviceName>
<serviceOrganization>{{inst}}</serviceOrganization>
<buildDate>2018-09-10</buildDate>
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns="http://kulturarvsdata.se/ksamsok#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"">
<Entity rdf:about="http://kulturarvsdata.se/LSH/objects/21029">
<isVisualizedBy rdf:resource="https://commons.wikimedia.org/wiki/File:Fingerring_av_guld_med_smaragder_och_briljanter,_1800-tal_-_Hallwylska_museet_-_110182.tif"
</Entity>
</rdf:RDF>
@Abbe98
Abbe98 / 1.rq
Created June 2, 2018 15:01
Wikidata SparQL Queries
# Sign languages by count
SELECT (COUNT(?lang) as ?language) ?langLabel ?lang
WHERE {
?item wdt:P2919 ?file .
?item p:P2919 ?statement .
?statement pq:P407 ?lang .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" . }
}
GROUP BY ?langLabel ?lang
ORDER BY DESC(?language)