ciromattia / kcc

KCC (a.k.a. Kindle Comic Converter) is a comic and manga converter for ebook readers.
ISC License
2.6k stars 208 forks source link

Kindle Scribe Cover generation after mtp firmware #508

Open axu2 opened 1 year ago

axu2 commented 1 year ago

Would be nice to have option to manually upload covers after the fact for longer batch conversions without needing kindle plugged in.

Additionally, Kindle Scribe uses MTP so cover upload no longer works.

https://www.mobileread.com/forums/showthread.php?t=355924&highlight=mtp

Hacky workaround

TLDR use kcc normally with a special flash drive inserted.

1) Plug in a flash drive that will pretend to be kindle. Must be fat32 or msdos fat 2) Create system/thumbnails and documents folders at root of flash drive. Based on https://github.com/ciromattia/kcc/blob/master/kindlecomicconverter/kindle.py#L42 3) Convert with KCC and thumbnails will be generated there. 4) Copy the thumbnails onto your Scribe in the appropriate location. On Mac use MTP client Android File Transfer. Remember, on mac/linux only 1 program can access mtp at a time, so any other book transfer software running will interfere 5) Copy your books AFTER the thumbnails to avoid the Kindle blanking them out.

To create a fake physical flash drive, refer to https://support.apple.com/guide/disk-utility/create-a-disk-image-dskutl11888/mac and use msdos format.

image

On Windows https://learn.microsoft.com/en-us/windows-server/storage/disk-management/manage-virtual-hard-disks use FAT not FAT32. 100 mb should be good, default on mac.

pretenderlu commented 7 months ago

This looks absolutely fantastic! I wonder if it's feasible?

axu2 commented 7 months ago

@pretenderlu what's not feasible? The workaround works but I'm not sure if it's possible to automate like before.

If anything this is more convenient since kindle doesn't need to be plugged in.

pretenderlu commented 7 months ago

Yes, what I mean is I don't know if it can be fully automated. If full automation is possible, that would be perfect.

axu2 commented 7 months ago

@pretenderlu May be possible with a python library that supports MTP. the biggest issue is that Mac and Linux prevent more than one MTP connection, so Android File Transfer running will interfere. Android File Transfer is required on Mac to transfer the mobis and auto starts when kindle is plugged in.

pretenderlu commented 7 months ago

@axu2 Indeed, it seems inevitable that human intervention is needed. However, the ability to directly generate corresponding comics and covers is already great, and manually operating one step is also very convenient.

jaroslawjanas commented 6 months ago

It's a lot of effort, to be honest. I just hope Calibre fixes it soon since it's what I have been using to sideload all of my content.

tomsem commented 4 months ago

It is fully automatable, in theory.

But there is effectively no Python library for MTP. For example, this one doesn't work on Python 3, and has not been updated in over 12 years: https://pypi.org/project/PyMTP/

The closest thing to a Python MTP library is what calibre has, but it would need refactoring to use outside of calibre. Ideally, that is what KCC would use.

Another option would be to call command line tools from Python.

On Windows, you can use Powershell commands to automate Windows Explorer (e.g. [https://github.com/nosalan/powershell-mtp-file-transfer]).

On macOS (and maybe Linux), installing libmtp (e.g. 'brew install libmtp') provides a set of command line tools, like mtp-folders, mtp-sendfile, mtp-getfile, etc.

jaroslawjanas commented 4 months ago

The closest thing to a Python MTP library is what calibre has, but it would need refactoring to use outside of calibre. Ideally, that is what KCC would use.

Well... I wouldn't mind seeing KCC being implemented into Calibre as a plugin since we are on the topic.

axu2 commented 4 months ago

KCC calls lots of command lines tools like kindlegen, 7z, etc. it wouldn't be unusual to do mtp as well.

tomsem commented 3 months ago

It is fully automatable, in theory.

But there is effectively no Python library for MTP. For example, this one doesn't work on Python 3, and has not been updated in over 12 years: https://pypi.org/project/PyMTP/

I think I have got it working!

It is just one Python file (pymtp.py), and after running 2to3 and changing 2 other lines of code that for some reason were calling dunder methods (probably something to do with an older MTP library), I'm able to run example code (also updated with 2to3).

I think one can just add the migrated pymtp.py to a project, and as long as the MTP C library is installed on system, it will just work without needing to pip install anything.