Skip to content

Commit

Permalink
Update safaribooks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzodifuccia committed Nov 26, 2020
1 parent 7e8248d commit db37f8d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions safaribooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def parse_description(self, desc):
return "n/d"

def book_info(self, info):
description = self.parse_description(info["description"]).replace("\n", " ")
description = self.parse_description(info.get("description", None)).replace("\n", " ")
for t in [
("Title", info.get("title", "")), ("Authors", ", ".join(aut.get("name", "") for aut in info.get("authors", []))),
("Identifier", info.get("identifier", "")), ("ISBN", info.get("isbn", "")),
Expand Down Expand Up @@ -948,10 +948,10 @@ def create_content_opf(self):
"media-type=\"text/css\" />".format(i))

authors = "\n".join("<dc:creator opf:file-as=\"{0}\" opf:role=\"aut\">{0}</dc:creator>".format(
escape(aut["name"])
) for aut in self.book_info["authors"])
escape(aut.get("name", "n/d")])
) for aut in self.book_info.get("authors", []))

subjects = "\n".join("<dc:subject>{0}</dc:subject>".format(escape(sub.get("name", "")))
subjects = "\n".join("<dc:subject>{0}</dc:subject>".format(escape(sub.get("name", "n/d")))
for sub in self.book_info.get("subjects", []))

return self.CONTENT_OPF.format(
Expand Down

0 comments on commit db37f8d

Please sign in to comment.