4
4
from kb .nl .collections import SETS
5
5
from kb .nl .helpers import etree
6
6
7
- OAI_BASEURL = 'http://services.kb.nl/mdo/oai'
8
7
9
8
10
9
class oai :
@@ -34,7 +33,10 @@ class oai:
34
33
current_set = False
35
34
oai_sets = SETS
36
35
resumptiontoken = False
36
+
37
37
DEBUG = False
38
+ KEY = False
39
+ OAI_BASEURL = 'http://services.kb.nl/mdo/oai'
38
40
39
41
def __init__ (self , current_set = False ):
40
42
if current_set :
@@ -46,6 +48,21 @@ def list_sets(self):
46
48
"""
47
49
return sorted (self .oai_sets .keys ())
48
50
51
+ def set_key (self , key ):
52
+ """
53
+ Sets the key for the OAI-session,
54
+ some parts of the collection are protected.
55
+ to request a key see this page:
56
+
57
+ https://www.kb.nl/en/resources-research-guides/data-services-apis
58
+
59
+ :param key: OAI key
60
+ """
61
+ if not self .KEY :
62
+ self .KEY = key
63
+ self .OAI_BASEURL += "/" + key
64
+ return
65
+
49
66
def list_records (self , setname , resumptiontoken = False ):
50
67
"""
51
68
Retrieves a list of records from the OAI server,
@@ -64,7 +81,7 @@ def list_records(self, setname, resumptiontoken=False):
64
81
if not resumptiontoken :
65
82
self .resumptiontoken = False
66
83
67
- url = OAI_BASEURL
84
+ url = self . OAI_BASEURL
68
85
url += '?verb=ListRecords'
69
86
url += '&metadataPrefix=' + self .oai_sets [setname ]['metadataPrefix' ]
70
87
url += '&set=' + self .oai_sets [setname ]['setname' ]
@@ -110,7 +127,7 @@ def get(self, identifier):
110
127
identifier = 'BYVANCK:' + identifier
111
128
identifier = identifier .replace ('BYVANCK' , 'ByvanckB' )
112
129
113
- url = OAI_BASEURL
130
+ url = self . OAI_BASEURL
114
131
url += '?verb=GetRecord'
115
132
url += '&identifier=' + identifier
116
133
0 commit comments