Code Monkey home page Code Monkey logo

Comments (16)

giorgio130 avatar giorgio130 commented on May 24, 2024

I wanted to point out there's an easier way to get covers to show on kepub: in the OPF file, the line describing the cover has to be like this:
item href="Images/cover.jpg" id="cover.jpg" media-type="image/jpeg" properties="cover-image"

i.e. the string properties="cover-image" has to be added in order for the reader to pick up the cover and process it.
I think adding this to the converting code will simplify a bit things, since you won't have to add rows to the database relating to cover and such.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

Awesome, thanks for that info. I'll see about getting that in there next chance I get. Probably this weekend.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

Per http://www.mobileread.com/forums/showpost.php?p=2402644&postcount=39 and http://idpf.org/epub/30/spec/epub30-publications.html#sec-opf-dctitle the EPUB3 spec has the ability to set series information by defining a title-type meta tag set to collection and a group-position meta tag set to the series index. It appears that there would be no harm in setting these extra tags in an EPUB2 document and if the Kobo device reads these tags even for an EPUB2 document the database code would be unnecessary entirely. Something to investigate in the next few days.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

First patch from me ;)

Your code assumes the id of the cover image is "cover", this is not always the case. This checks also the id specified in the metadata:

diff --git a/driver.py b/driver.py
index 2494872..3f7d849 100644
--- a/driver.py
+++ b/driver.py
@@ -132,6 +132,15 @@ class KOBOTOUCHEXTENDED(KOBOTOUCH):
            return False

        opf = container.get_parsed(container.opf_file)
+       for node in opf.xpath('./ns:metadata/ns:meta[@name="cover"]', namespaces = {"ns": container.opf_ns}):
+           cover_id = node.attrib["content"]
+       for node in opf.xpath('./ns:manifest/ns:item', namespaces = {"ns": container.opf_ns}):
+           if node.attrib["id"]==cover_id and ("properties" not in node.attrib or node.attrib["properties"] != 'cover-image'):
+               print("KoboTouchExtended:_modify_epub:Setting cover-image")
+               node.set("properties", "cover-image")
+               container.set(container.opf_file, opf)
+               changed = True
+
        for node in opf.xpath('./ns:manifest/ns:item[@id="cover"]', namespaces = {"ns": container.opf_ns}):
            if "properties" not in node.attrib or node.attrib["properties"] != 'cover-image':
                debug_print("KoboTouchExtended:_modify_epub:Setting cover-image")

It seems to work with most or all of my ebooks, while before I got the cover to show for only about half of them.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

Someone got around to testing the EPUB3 series metadata before I did and reported that it does not work.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

Some more issues on this code:

calibre, version 0.9.17
ERRORE: Errore: Errore di comunicazione col dispositivo

'list' object has no attribute 'attrib'

Traceback (most recent call last):
File "site-packages/calibre/gui2/device.py", line 85, in run
File "site-packages/calibre/gui2/device.py", line 551, in _upload_books
File "calibre_plugins.kobotouch_extended.driver", line 202, in upload_books
File "calibre_plugins.kobotouch_extended.driver", line 139, in _modify_epub
AttributeError: 'list' object has no attribute 'attrib'

affected opf: http://dl.dropbox.com/u/29092891/content.opf

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

I've pushed up a new copy of the code, the fixes are unrelated to this (I think) but the change I made should make it impossible to reference a list object at that point.

By the way, watch out for the removal of the no-database branch. The database manipulation code was removed from master, so no-database is no longer needed.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

I didn't check right away when you committed your version of my patch, however current code can't detect covers that were correctly tagged with my code. I don't know where it went wrong.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

Can you send me some OPF files from books that were working with your
patch but not when I modified it?

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

this is an example:

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookID" version="2.0">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
        <dc:identifier id="BookID" opf:scheme="UUID">A4D65303-C14E-420C-BF55-121B49B49034</dc:identifier>
        <dc:contributor opf:role="bkp">Created with writer2epub 1.1.20 by Luca Calcinai http://lukesblog.it/writer2epub</dc:contributor>
        <dc:date opf:event="creation">2013-02-08</dc:date>
        <dc:creator opf:role="aut">Author</dc:creator>
        <dc:description>
        <![CDATA[Description]]>
        </dc:description>
        <dc:language>it</dc:language>
        <dc:source>Title</dc:source>
        <dc:publisher>Autoprodotto</dc:publisher>
        <dc:date opf:event="publication">2013-02-08</dc:date>
        <dc:title>Title</dc:title>
        <meta content="1.1.20" name="writer2epub"/>
        <meta content="immagini1.jpg" name="cover"/>
        <meta content="0.6.2" name="Sigil version"/>
        <dc:date opf:event="modification">2013-02-08</dc:date>
    </metadata>
    <manifest>
        <item href="toc.ncx" id="ncx" media-type="application/x-dtbncx+xml"/>
        <item href="Images/immagini1.jpg" id="immagini1.jpg" media-type="image/jpeg"/>
        <item href="Styles/style001.css" id="style001.css" media-type="text/css"/>
        <item href="Text/content0001.xhtml" id="content0001.xhtml" media-type="application/xhtml+xml"/>
        <item href="Text/content0002.xhtml" id="content0002.xhtml" media-type="application/xhtml+xml"/>
        <item href="Text/content0003.xhtml" id="content0003.xhtml" media-type="application/xhtml+xml"/>
        <item href="Text/content0004.xhtml" id="content0004.xhtml" media-type="application/xhtml+xml"/>
        <item href="Text/content0005.xhtml" id="content0005.xhtml" media-type="application/xhtml+xml"/>
        <item href="Text/content0006.xhtml" id="content0006.xhtml" media-type="application/xhtml+xml"/>
    </manifest>
    <spine toc="ncx">
        <itemref idref="content0001.xhtml"/>
        <itemref idref="content0002.xhtml"/>
        <itemref idref="content0003.xhtml"/>
        <itemref idref="content0004.xhtml"/>
        <itemref idref="content0005.xhtml"/>
        <itemref idref="content0006.xhtml"/>
    </spine>
    <guide>
        <reference href="Text/content0001.xhtml" title="Cover Page" type="cover"/>
    </guide>
</package>

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

That's an odd one. It looks very straightforward, the cover is clearly identified and the specified ID is in the manifest as an image/jpeg. I'll run this one through next time I'm in front of my computer.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

Did you change anything related to this? Detection seems to be working fine now, for some reason.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

I haven't even looked at this yet, I've been distracted by some other things.

from calibre-kobo-driver.

giorgio130 avatar giorgio130 commented on May 24, 2024

Well this very example is now being properly detected. Maybe the chardet changes are involved?

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

You know, that's possible. The XML files are fetched the same way as everything else so maybe the chardet changes did actually fix this as well.

from calibre-kobo-driver.

jgoguen avatar jgoguen commented on May 24, 2024

The imageID is solved, the rest can be a new bug.

from calibre-kobo-driver.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.