fix bookloader when a bookdata is empty

pull/94/head^2
eric 2024-11-22 14:34:17 -05:00
parent 37a5486abe
commit 7bd6fba096
3 changed files with 21 additions and 17 deletions

View File

@ -1113,6 +1113,7 @@ def add_from_bookdatas(bookdatas):
editions = []
for bookdata in bookdatas:
edition = work = None
if bookdata and bookdata.metadata:
loader = BasePandataLoader(bookdata.base)
pandata = Pandata()
pandata.metadata = bookdata.metadata

View File

@ -69,9 +69,12 @@ class BaseScraper(object):
self.set('title', '!!! missing title !!!')
if not self.metadata.get('language', None):
self.set('language', 'en')
else:
self.metadata = {}
self.metadata['identifiers'] = self.identifiers
else:
self.metadata = None
else:
self.metadata = None
#
# utilities

View File

@ -146,9 +146,9 @@ class SpringerScraper(BaseScraper):
self.set('rights_url', lic_url)
def get_pubdate(self):
pubinfo = self.doc.select_one('#copyright-info')
pubinfo = self.doc.find(attrs={"data-test": "electronic_isbn_publication_date"})
if not pubinfo:
pubinfo = self.doc.select_one('header .c-article-identifiers')
pubinfo = self.doc.find(attrs={"data-test": "softcover_isbn_publication_date"})
if pubinfo:
for yearstring in pubinfo.stripped_strings:
yearmatch = HAS_YEAR.search(yearstring)