Skip to content
Snippets Groups Projects
Commit 6e3c7b25 authored by Donatus Herre's avatar Donatus Herre
Browse files

vd18 updated

parent 4f125088
Branches
No related tags found
No related merge requests found
......@@ -4,19 +4,19 @@
null
],
"1735": [
"005973589",
"005934303",
"10812180",
"10781420",
null
],
"1736": [
"005181674",
"025238787",
"006972160",
"005934133",
"005977274",
"025238795",
"10294651",
"10756035",
"11525584",
"10781315",
"10815171",
"10786686",
null,
"004835662",
"10097376",
null
]
}
......@@ -13,6 +13,7 @@ from librair import interfaces
online = schemas.json.reader("data/vd18-online.json")
vd18 = interfaces.unapi.Client("http://unapi.gbv.de", "vd18", "ppn")
vd18_sru = interfaces.sru.Client("http://sru.gbv.de/vd18")
printed_data = []
printed_years = []
......@@ -23,10 +24,52 @@ max_year = -1
FORMAT = "jsmf-json"
def vdn_query(vd18_nr):
return "pica.vdn={0}".format(vd18_nr)
def get_ppn(vd18_nr, bbg="O"):
items = vd18_sru.search(vdn_query(vd18_nr), schema="picaxml", records=5)
if type(items) == list:
for item in items:
bbg_val = extract_bbg(item)
if bbg_val.startswith(bbg):
item_ppn = extract_ppn(item)
if item_ppn != "":
return item_ppn
else:
bbg_val = extract_bbg(items)
if bbg_val.startswith(bbg):
item_ppn = extract_ppn(items)
if item_ppn != "":
return item_ppn
return None
def extract_bbg(item):
bbg_val = item.find(".//datafield[@tag='002@']/subfield[@code='0']",
namespaces=item.nsmap)
if bbg_val is not None:
if bbg_val.text is not None:
return bbg_val.text
return ""
def extract_ppn(item):
ppn_val = item.find(".//datafield[@tag='003@']/subfield[@code='0']",
namespaces=item.nsmap)
if ppn_val is not None:
if ppn_val.text is not None:
return ppn_val.text
return ""
for year in online:
for ppn in online[year]:
if ppn is not None:
for vd18_nr in online[year]:
if vd18_nr is not None:
counter += 1
ppn = get_ppn(vd18_nr)
item_data = vd18.request(ppn, FORMAT)
printed_data.append(item_data)
item_title = "!NO DATA!"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment