Skip to content

Commit

Permalink
Make cover art show in Apple Books library
Browse files Browse the repository at this point in the history
The <meta> tag for the cover needs to point to the <item> tag for the
cover image instead of pointing directly to the image file.
  • Loading branch information
stevenl committed Dec 17, 2022
1 parent 1c81fff commit abfb453
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion safaribooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,8 @@ def create_content_opf(self):
subjects = "\n".join("<dc:subject>{0}</dc:subject>".format(escape(sub.get("name", "n/d")))
for sub in self.book_info.get("subjects", []))

cover_id = re.search(r'/(\w+)\.', self.cover).group(1)

return self.CONTENT_OPF.format(
(self.book_info.get("isbn", self.book_id)),
escape(self.book_title),
Expand All @@ -973,7 +975,7 @@ def create_content_opf(self):
", ".join(escape(pub.get("name", "")) for pub in self.book_info.get("publishers", [])),
escape(self.book_info.get("rights", "")),
self.book_info.get("issued", ""),
self.cover,
f'img_{cover_id}',
"\n".join(manifest),
"\n".join(spine),
self.book_chapters[0]["filename"].replace(".html", ".xhtml")
Expand Down

0 comments on commit abfb453

Please sign in to comment.