fix bookloader when a bookdata is empty
parent
37a5486abe
commit
7bd6fba096
|
@ -1113,13 +1113,14 @@ def add_from_bookdatas(bookdatas):
|
|||
editions = []
|
||||
for bookdata in bookdatas:
|
||||
edition = work = None
|
||||
loader = BasePandataLoader(bookdata.base)
|
||||
pandata = Pandata()
|
||||
pandata.metadata = bookdata.metadata
|
||||
for metadata in pandata.get_edition_list():
|
||||
edition = loader.load_from_pandata(metadata, work)
|
||||
work = edition.work
|
||||
loader.load_ebooks(pandata, edition)
|
||||
if edition:
|
||||
editions.append(edition)
|
||||
if bookdata and bookdata.metadata:
|
||||
loader = BasePandataLoader(bookdata.base)
|
||||
pandata = Pandata()
|
||||
pandata.metadata = bookdata.metadata
|
||||
for metadata in pandata.get_edition_list():
|
||||
edition = loader.load_from_pandata(metadata, work)
|
||||
work = edition.work
|
||||
loader.load_ebooks(pandata, edition)
|
||||
if edition:
|
||||
editions.append(edition)
|
||||
return editions
|
||||
|
|
|
@ -65,13 +65,16 @@ class BaseScraper(object):
|
|||
for review in self.doc.find_all(itemtype="http://schema.org/Review"):
|
||||
review.clear()
|
||||
self.get_all()
|
||||
if not self.metadata.get('title', None):
|
||||
self.set('title', '!!! missing title !!!')
|
||||
if not self.metadata.get('language', None):
|
||||
self.set('language', 'en')
|
||||
if not self.metadata.get('title', None):
|
||||
self.set('title', '!!! missing title !!!')
|
||||
if not self.metadata.get('language', None):
|
||||
self.set('language', 'en')
|
||||
self.metadata['identifiers'] = self.identifiers
|
||||
else:
|
||||
self.metadata = None
|
||||
else:
|
||||
self.metadata = {}
|
||||
self.metadata['identifiers'] = self.identifiers
|
||||
self.metadata = None
|
||||
|
||||
|
||||
#
|
||||
# utilities
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue