diff --git a/oml/meta/openlibrary.py b/oml/meta/openlibrary.py index 8f583b1..d202881 100644 --- a/oml/meta/openlibrary.py +++ b/oml/meta/openlibrary.py @@ -72,7 +72,7 @@ def get_ids(key, value): return ids def lookup(id, return_all=False): - #print 'openlibrary.lookup', id + logger.debug('lookup %s', id) info = api.get('/books/' + id).get('result', {}) #url = 'https://openlibrary.org/books/%s.json' % id #info = json.loads(read_url(url)) @@ -84,6 +84,12 @@ def lookup(id, return_all=False): logger.debug('lookup %s => %s', id, data.keys()) return data +def get_type(obj): + type_ = obj.get('type') + if isinstance(type_, dict): + type_ = type_['key'] + return type_ + def format(info, return_all=False): data = {} if 'works' in info: @@ -96,7 +102,7 @@ def format(info, return_all=False): if key == 'authors': if work: value = resolve_names([r['author'] - for r in work['authors'] if r['type']['key'] == '/type/author_role']) + for r in work.get('authors', []) if get_type(r) == '/type/author_role']) else: value = resolve_names(value) elif key == 'publish_country': diff --git a/static/js/infoView.js b/static/js/infoView.js index 4c2a241..4c1d5ac 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -551,13 +551,26 @@ oml.ui.infoView = function(identifyData) { .appendTo($div); }); + // -------- Primary ID + + if (data.primaryid) { + $('