Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 11-14-2011, 03:26 PM   #1
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
Calibre ASIN support in ".mobi" output

I was trying to get cross-device sync to work with the epubs that I bought from B&N and converted to .mobi.

It was not working with the UUID that is generated/created by default.

So, I modified "calibre/src/calibre/ebooks/mobi/writer2/main.py"

I modified the ASIN set block to look like this:
Code:
        # Write UUID as ASIN
        uuid = None
        from calibre.ebooks.oeb.base import OPF
        for x in oeb.metadata['identifier']:
            if x.get(OPF('scheme'), None).lower() == 'asin' or unicode(x).startswith('urn:asin:'):
                uuid = unicode(x).split(':')[-1]
                break
            if x.get(OPF('scheme'), None).lower() == 'amazon' or unicode(x).startswith('urn:amazon:'):
                uuid = unicode(x).split(':')[-1]
                break

        if uuid is None:
                for x in oeb.metadata['identifier']:
                    if x.get(OPF('scheme'), None).lower() == 'uuid' or unicode(x).startswith('urn:uuid:'):
                        uuid = unicode(x).split(':')[-1]
                        break

        if isinstance(uuid, unicode):
            uuid = uuid.encode('utf-8')
        if not self.opts.share_not_sync:
            exth.write(pack(b'>II', 113, len(uuid) + 8))
            exth.write(uuid)
            nrecs += 1
I feel like this provides support for the Amazon sync feature while still allowing a value to be input (UUID) without user intervention.

This feature only works if an ASIN has been set on the ebook.

Feedback welcome! (I've never done python before I just made this work because I wanted the feature. I wanted to share it here in case other people needed it.)
cruffalo is offline   Reply With Quote
Old 11-14-2011, 11:31 PM   #2
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,885
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by cruffalo View Post
I was trying to get cross-device sync to work with the epubs that I bought from B&N and converted to .mobi.

It was not working with the UUID that is generated/created by default.

...

I feel like this provides support for the Amazon sync feature while still allowing a value to be input (UUID) without user intervention.

This feature only works if an ASIN has been set on the ebook.
I think it is great that you are exploring the possibilities and expressing them in actual code for review. I am not a programmer but any book converted to mobi with the current version of calibre should already work with the Amazon Sync feature.

What difficulties did you experience trying to sync?
DoctorOhh is online now   Reply With Quote
Old 11-14-2011, 11:34 PM   #3
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
I put the same book (same UUID as ASIN... I checked with Mobi2Mobi) on my iPhone Kindle App and on my Android Kindle App... and could not get them to sync at all.

Note: this procedure doesn't appear to change that. So I guess my code doesn't do anything anyway.
cruffalo is offline   Reply With Quote
Old 11-14-2011, 11:45 PM   #4
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,319
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
There is a long thread with discussions of this feature and its caveats in this forum. As far as I know, as long as you have the sync not share checkbox checked in the MOBI output options and you send the mobi files to your devices directly (i.e. not via amazon email) the feature works.
kovidgoyal is offline   Reply With Quote
Old 11-14-2011, 11:49 PM   #5
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,885
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by cruffalo View Post
I put the same book (same UUID as ASIN... I checked with Mobi2Mobi) on my iPhone Kindle App and on my Android Kindle App... and could not get them to sync at all.

Note: this procedure doesn't appear to change that. So I guess my code doesn't do anything anyway.
Did you follow the below steps?

Quote:
Originally Posted by Statch View Post
I use this Calibre feature all the time with books not bought at Amazon, but I realized that I've never used it with Kindle4PC (only with my Kindle 3 WiFi and my Android phone/Kindle app). So I tried sending a .mobi book from Calibre (using save to disk) to K4PC on my laptop and to my Kindle 3 (not via email). I read a bit on my laptop, then went to the same book on the Kindle 3. I chose the option to sync it to the last page read, and it worked. Then I read a few more pages, closed the book on the Kindle, and went to the laptop. When I opened the same book on the laptop with K4PC, it didn't automatically go to the last page read on the Kindle. I chose Go To -> Sync to Furthest Page Read, and then it did sync.

Last edited by DoctorOhh; 11-14-2011 at 11:57 PM.
DoctorOhh is online now   Reply With Quote
Old 11-14-2011, 11:50 PM   #6
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
The "Enable sharing of book content" checkbox? I've got it unchecked.

http://imgur.com/bNdkd

It says that checking it will disable sharing. I must have been reading out of date information however on how ASIN numbers are used to sync.

I've not got either option to work.

I use sideloading to the SD Card on the Android device, copy to My Documents on the kindle desktop app, and direct mobi download from content server on the iOS device.

Couldn't get it to work. I'm not here for support though, I can do more reading if the code is useless.
cruffalo is offline   Reply With Quote
Old 11-14-2011, 11:54 PM   #7
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
I don't have a Kindle 3 and the iOS app doesn't have a "Sync to Furthest Read" button on the phone.

Maybe it just doesn't work that way.
cruffalo is offline   Reply With Quote
Old 11-14-2011, 11:59 PM   #8
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 8,885
Karma: 12755553
Join Date: Feb 2009
Location: North Carolina
Device: Nexus 7
Quote:
Originally Posted by cruffalo View Post
I'm not here for support though, I can do more reading if the code is useless.
Ok, I'll let someone else with knowledge review the code.
DoctorOhh is online now   Reply With Quote
Old 11-15-2011, 12:00 AM   #9
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,319
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Having it unchecked is fine. I didn't recall which way the checkbox was written as share not sync or sync not share
kovidgoyal is offline   Reply With Quote
Old 11-15-2011, 12:01 AM   #10
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
Oh, the code works. It doesn't help though.
cruffalo is offline   Reply With Quote
Old 11-15-2011, 12:03 AM   #11
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 26,319
Karma: 5382313
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Can't help with that, as I've never actually used this feature, myself.
kovidgoyal is offline   Reply With Quote
Old 11-15-2011, 12:04 AM   #12
cruffalo
Junior Member
cruffalo began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Sep 2011
Device: iPad
I'll see if I can dig up the old thread. Just wanted to leave this code out here. It's probably not the best way to get it to work (two loops and all) but it can serve as an example of how to work it in to the writer if anyone else wants to experiment.

Python is not even in my usual language group so... yea.

If anyone else has thoughts... let me know.
cruffalo is offline   Reply With Quote
Old 11-17-2011, 07:28 PM   #13
Bob Butler
Connoisseur
Bob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheeseBob Butler can extract oil from cheese
 
Posts: 82
Karma: 1082
Join Date: Sep 2008
Device: Kindle, iPhone
I've tried putting a calibre generated mobi on two Kindles and an iPad. I loaded both Kindles through calibre and copied the exact file from one of the kindles onto the iPad through the kindle app file sharing section in iTunes. I also verified that there was a GUID in the ASIN metadata field using Mobi2MobiGUI.

The Kindles sync properly. The iPad doesn't. I also tried loading the same file through dropbox and it still didn't work. Books purchased through Amazon do sync, so it isn't that the feature is completely missing on the iPad. There must be something else going on.

Has anyone been able to get this working with the Kindle app on an iPad?
Bob Butler is offline   Reply With Quote
Old 11-21-2011, 03:53 PM   #14
hbtaylor
Enthusiast
hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!hbtaylor My eyes! My eyes! The light is just too bright!
 
Posts: 30
Karma: 80378
Join Date: Nov 2011
Device: iPad 3, Nexus 7 (2013)
Quote:
Originally Posted by Bob Butler View Post
Has anyone been able to get this working with the Kindle app on an iPad?
I have never had syncing for non-Amazon books work correctly on the iPad when using iTunes to load the documents. My guess is that the Kindle app intercepts the files and ensures they go in as personal documents and not books, and that the iPad app only does Whispersync for books. If I use iExplorer to put the files on the iPad (to the Apps/Kindle/Library/eBooks folder instead of to Apps/Kindle/Documents), it does sync as long as there is an ASIN of some type. If the ASIN is an Amazon ASIN, the Book Extras also work.

I appreciate Kovid's stance on writing Amazon ASINs as opposed to using a UUID, but my preference is to use Amazon's ASINs if possible.

To date I've been using mobi2mobi to set ASINs to the Amazon one if the calibre UUID isn't sufficient for me, then iExplorer to actually copy the files to the iPad. For my Kindle Fire and Android phones I just put the files in the right directory. My nerdvana would be to have calibre write the Amazon ASIN for me, even if I have to use iExplorer to make sure the files don't get re-worked by iTunes. I'm toying around with letting that be my first foray into calibre plugin creation. I figure it would be nice to have some type of plugin to set the ASIN, either by looking it up or grabbing it from a custom attribute.

H.B.
hbtaylor is offline   Reply With Quote
Old 11-27-2011, 10:55 PM   #15
snarf
Junior Member
snarf began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: iPhone Kindle App
H.B. I've gone through and done what you've explained above but still am not able to get the "Book Extras" to appear on the iPhone Kindle App for .mobi files I've manually uploaded via iExplorer.

To me, the Book Extras feature tremendously enhances my reading experience and am quite desperate to obtain this feature for epub/mobi files I have purchased outside of the Kindle marketplace.

Do you have any further advice or more specific instructions I could follow to properly add the ASIN number to my files so the iPhone Kindle App will recognize the file and associate the Book Extras from Shelfari?

Thank you!!!!
snarf is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Calibre to make doc -> mobi files. Problems with "start reading" section. Stodder Calibre 0 07-03-2011 11:32 AM
eopub output: omit "lang=XX" miwie Recipes 1 11-18-2010 06:16 PM
Getting calibre to detect "Prologue" and "Epilogue" for TOC sherman Calibre 2 09-20-2010 03:21 AM
Calibre doesn't support ".doc" files? megacoupe Calibre 11 11-13-2009 04:38 AM


All times are GMT -4. The time now is 08:35 AM.


MobileRead.com is a privately owned, operated and funded community.