Fix #7114 (Problem with title in metadata download)

This commit is contained in:
Kovid Goyal 2010-10-10 12:24:29 -06:00
parent 85ee22a1fc
commit 0030630453

View File

@ -45,7 +45,7 @@ def fetch_metadata(url, max=100, timeout=5.):
class ISBNDBMetadata(Metadata): class ISBNDBMetadata(Metadata):
def __init__(self, book): def __init__(self, book):
Metadata.__init__(self, None, []) Metadata.__init__(self, None)
def tostring(e): def tostring(e):
if not hasattr(e, 'string'): if not hasattr(e, 'string'):
@ -58,21 +58,21 @@ class ISBNDBMetadata(Metadata):
return ans return ans
self.isbn = unicode(book.get('isbn13', book.get('isbn'))) self.isbn = unicode(book.get('isbn13', book.get('isbn')))
self.title = tostring(book.find('titlelong')) title = tostring(book.find('titlelong'))
if not self.title: if not title:
self.title = tostring(book.find('title')) title = tostring(book.find('title'))
if not self.title: self.title = title
self.title = _('Unknown')
self.title = unicode(self.title).strip() self.title = unicode(self.title).strip()
self.authors = [] authors = []
au = tostring(book.find('authorstext')) au = tostring(book.find('authorstext'))
if au: if au:
au = au.strip() au = au.strip()
temp = au.split(',') 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('&')]) authors.extend([a.strip() for a in au.split('&')])
if authors:
self.authors = authors
try: try:
self.author_sort = tostring(book.find('authors').find('person')) 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]: