get_type, no authors
This commit is contained in:
parent
2749f22703
commit
e14c686dac
2 changed files with 22 additions and 3 deletions
|
@ -72,7 +72,7 @@ def get_ids(key, value):
|
||||||
return ids
|
return ids
|
||||||
|
|
||||||
def lookup(id, return_all=False):
|
def lookup(id, return_all=False):
|
||||||
#print 'openlibrary.lookup', id
|
logger.debug('lookup %s', id)
|
||||||
info = api.get('/books/' + id).get('result', {})
|
info = api.get('/books/' + id).get('result', {})
|
||||||
#url = 'https://openlibrary.org/books/%s.json' % id
|
#url = 'https://openlibrary.org/books/%s.json' % id
|
||||||
#info = json.loads(read_url(url))
|
#info = json.loads(read_url(url))
|
||||||
|
@ -84,6 +84,12 @@ def lookup(id, return_all=False):
|
||||||
logger.debug('lookup %s => %s', id, data.keys())
|
logger.debug('lookup %s => %s', id, data.keys())
|
||||||
return data
|
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):
|
def format(info, return_all=False):
|
||||||
data = {}
|
data = {}
|
||||||
if 'works' in info:
|
if 'works' in info:
|
||||||
|
@ -96,7 +102,7 @@ def format(info, return_all=False):
|
||||||
if key == 'authors':
|
if key == 'authors':
|
||||||
if work:
|
if work:
|
||||||
value = resolve_names([r['author']
|
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:
|
else:
|
||||||
value = resolve_names(value)
|
value = resolve_names(value)
|
||||||
elif key == 'publish_country':
|
elif key == 'publish_country':
|
||||||
|
|
|
@ -551,13 +551,26 @@ oml.ui.infoView = function(identifyData) {
|
||||||
.appendTo($div);
|
.appendTo($div);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// -------- Primary ID
|
||||||
|
|
||||||
|
if (data.primaryid) {
|
||||||
|
$('<div>')
|
||||||
|
.css({
|
||||||
|
marginTop: '4px',
|
||||||
|
})
|
||||||
|
.html(
|
||||||
|
'<b>' + Ox.getObjectById(oml.config.itemKeys, data.primaryid[0]).title
|
||||||
|
+ ':</b> ' + data.primaryid[1]
|
||||||
|
)
|
||||||
|
.appendTo($info);
|
||||||
|
}
|
||||||
|
|
||||||
// -------- Classification
|
// -------- Classification
|
||||||
|
|
||||||
if (data.classification) {
|
if (data.classification) {
|
||||||
$('<div>')
|
$('<div>')
|
||||||
.css({
|
.css({
|
||||||
marginTop: '8px',
|
marginTop: '8px',
|
||||||
textAlign: 'justify'
|
|
||||||
})
|
})
|
||||||
.html(
|
.html(
|
||||||
formatValue(data.classification, 'classification')
|
formatValue(data.classification, 'classification')
|
||||||
|
|
Loading…
Reference in a new issue