mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Cleanup ISBNdb metadata plugin
This commit is contained in:
parent
93d92ee250
commit
05cf311555
@ -47,29 +47,43 @@ class ISBNDBMetadata(Metadata):
|
|||||||
def __init__(self, book):
|
def __init__(self, book):
|
||||||
Metadata.__init__(self, None, [])
|
Metadata.__init__(self, None, [])
|
||||||
|
|
||||||
|
def tostring(e):
|
||||||
|
if not hasattr(e, 'string'):
|
||||||
|
return None
|
||||||
|
ans = e.string
|
||||||
|
if ans is not None:
|
||||||
|
ans = unicode(ans).strip()
|
||||||
|
if not ans:
|
||||||
|
ans = None
|
||||||
|
return ans
|
||||||
|
|
||||||
self.isbn = unicode(book.get('isbn13', book.get('isbn')))
|
self.isbn = unicode(book.get('isbn13', book.get('isbn')))
|
||||||
self.title = unicode(book.find('titlelong').string)
|
self.title = tostring(book.find('titlelong'))
|
||||||
if not self.title:
|
if not self.title:
|
||||||
self.title = unicode(book.find('title').string)
|
self.title = tostring(book.find('title'))
|
||||||
|
if not self.title:
|
||||||
|
self.title = _('Unknown')
|
||||||
self.title = unicode(self.title).strip()
|
self.title = unicode(self.title).strip()
|
||||||
au = unicode(book.find('authorstext').string).strip()
|
|
||||||
temp = au.split(',')
|
|
||||||
self.authors = []
|
self.authors = []
|
||||||
|
au = tostring(book.find('authorstext'))
|
||||||
|
if au:
|
||||||
|
au = au.strip()
|
||||||
|
temp = au.split(',')
|
||||||
for au in temp:
|
for au in temp:
|
||||||
if not au: continue
|
if not au: continue
|
||||||
self.authors.extend([a.strip() for a in au.split('&')])
|
self.authors.extend([a.strip() for a in au.split('&')])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.author_sort = book.find('authors').find('person').string
|
self.author_sort = tostring(book.find('authors').find('person'))
|
||||||
if self.authors and self.author_sort == self.authors[0]:
|
if self.authors and self.author_sort == self.authors[0]:
|
||||||
self.author_sort = None
|
self.author_sort = None
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.publisher = unicode(book.find('publishertext').string)
|
self.publisher = tostring(book.find('publishertext'))
|
||||||
|
|
||||||
summ = book.find('summary')
|
summ = tostring(book.find('summary'))
|
||||||
if summ and hasattr(summ, 'string') and summ.string:
|
if summ:
|
||||||
self.comments = 'SUMMARY:\n'+unicode(summ.string)
|
self.comments = 'SUMMARY:\n'+summ.string
|
||||||
|
|
||||||
|
|
||||||
def build_isbn(base_url, opts):
|
def build_isbn(base_url, opts):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user