ToofDerling / CbzMage

Convert azw and pdf comic books to nice cbz files
MIT License
33 stars 1 forks source link

[macOS 13.1] Handle folders with azw files #23

Closed alehel closed 1 year ago

alehel commented 1 year ago

I'm trying to run CbzMage on my macOS 13.1 machine. I'm currently getting the current error when I run the command "./CbzMage AzwConvert".

CbzMage fatal error. InvalidDataException: Failed to load configuration from file '/Users/alehel/cbzmage/CbzMageSettings.json'.

My AzwDirectory is as follows "AzwDir": "/Users/alehel/kindle/My\ kindle\ Content/"

If I don't specify a AzwDir I get the following error.

CbzMage fatal error. Exception: Must configure AzwDir in AzwSettings.json or AzwSettings.User.json So CbzMage does seem able to read the json. It therefore seems it's the directory it's having issues with. Is it possible to get a more detailed error message so I can try and figure out what's wrong?

Also, on another note, I see my Kindle data directory has kcr files, not azw files. Not sure if this is causing the issue. CbzMage might not be able to handle kcr files?

alehel commented 1 year ago

After a bit of experimentation I don't seem to be able to install a version of the kindle app which is old enough to force azw downloads. Even if I install an older version, and disable automatic updates, it still updates to a version to new to get the azw files.

That said, it is possible to download the azw3 files from my amazon account by selecting download and transfer with usb. There I specify that I am downloading for my Kindle Fire, and it starts a download. It would be useful if CbzMage could also handle these files so one didn't have to deal with the Kindle desktop software.

ToofDerling commented 1 year ago

Lots of stuff to digest here :) let me see.

The "AzwDir": "/Users/alehel/kindle/My\ kindle\ Content/" line does not seem right. Try removing the backslashes in the directory: "/Users/alehel/kindle/My kindle Content/". Also since CbzMage 0.22 you should use AzwSettings.json when configuring the AzwDir.

I don't know anything about kcr files. Can you share one with me so I can check it out? Zip a _EBOK directory with a kcr file and put it up somewhere (google drive, dropbox, you can even attach the zipfile right here).

These Kindle File downloads what do they contain? I mean, just the azw file or a zipped _EBOK directory? It might be possible to simply point the AzwDir at the downloads, though it may need a little tweaking before it works.

alehel commented 1 year ago

The "AzwDir": "/Users/alehel/kindle/My\ kindle\ Content/" line does not seem right. Try removing the backslashes in the directory: "/Users/alehel/kindle/My kindle Content/".

Ah. I assumed I needed to escape the blank spaces. Didn't even occur to me that that might not be right. CbzMage now runs and reports 0 books.

There is an old Reddit thread discussing the kcr format. Seems it started showing up roughly 2019. Apparently it's also used on the latest version of Windows. On my Windows PC I used to use, when I downloaded regular books, they would come as kcr files, but the comixology stuff was azw3. Maybe they've started moving over to kcr for comics as well now.

These Kindle File downloads what do they contain? I mean, just the azw file or a zipped _EBOK directory? It might be possible to simply point the AzwDir at the downloads, though it may need a little tweaking before it works.

It is only the azw3 file. Calibre with plugins is able to read it, so I thought perhaps CbzMage might be able to handle a folder of them. Didn't occur to me that you might need info in the _EBOK directory. If you have any kind of a kindle device, you can download your comics for transfer via USB from this page (https://www.amazon.com/hz/mycd/digital-console/contentlist/booksAll/dateDsc/).

alehel commented 1 year ago

Ah, that's unfortunate. I found the following on MobileRead,

Important update: Amazon has made a change to their service so the books published since Jan 3 2023 can no longer be downloaded using Kindle for PC versions prior to 1.39.

https://www.mobileread.com/forums/showthread.php?p=3471461#post3471461

It seems that soon, the only way to get azw3 files will be by owning an older kindle device which doesn't support kcr.

ToofDerling commented 1 year ago

I'm on Windows using the latest Kdl for PC/Mac (and I don't have a Kdl device). I tried buying a comic released 4th of January and got a plain old .azw file which converted fine.

CbzMage does not need the EBOK directory for anything really, but the lookup mechanism uses the directory to group books under the "My" directory. But if the file you're downloading for your device is convertable it should be simple enough to support that.

So far I haven't seen any .kcr files (or .azw3 for that matter), so I don't know if I can do anything about them.

alehel commented 1 year ago

Interesting. I'll install kindle application on my windows machine tomorrow and see what file type I get.

It would be very useful if CbzMage could handle a folder of azw files. Currently I download them, import into Calibre, explode it, manually copy over the images into a zip file and rename to cbz. It's time consuming to say the least.

Wish I could help, but I've never touched C#.

ToofDerling commented 1 year ago

Handling folders with azw files is something I've been thinking of adding. I should have something in a day or two.

Still curious about the kcr files though :)

ToofDerling commented 1 year ago

Here's one thing you can try: Create a directory under "My" and name it after the azw file you downloaded, without the .azw extension (I'm assuming the download filename is something like this "B01BL1E3MW_EBOK.azw", maybe without the ebok.).

Now copy the downloaded file into the directory and run CbzMage and let's see what happens.

alehel commented 1 year ago

Here's one thing you can try: Create a directory under "My" and name it after the azw file you downloaded, without the .azw extension (I'm assuming the download filename is something like this "B01BL1E3MW_EBOK.azw", maybe without the ebok.).

Now copy the downloaded file into the directory and run CbzMage and let's see what happens.

That did work. I had to rename the extension from azw3 -> azw though, as CbzMage wasn't picking up the azw3 file. It also ended up changing the "_" to a "\ " in the filename. Hotell_1.awz became Hotell\ 1.cbz. Other than that I have a cbz copy of my comic now in record time. Can't believe I used to do this manually for all my comics.

alehel commented 1 year ago

Interesting. I did another comic. This one called "A Matter of Life.azw". Conversion went fine, but after that, when I now run azwconvert, I get the following, Reading archived titles: CbzMage fatal error. AggregateException: One or more errors occurred. ('M' is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.) The current directory structure is as follows,

image
ToofDerling commented 1 year ago

CbzMage_macOS_Debug.zip

Try this version. Beware that the names of the settings files have changed, but like before there's a default settings file you shouldn't touch and one for each of the convert modes.

This version does a couple of new things:

Also it's a debug build, so you'll see the full stacktrace should you get any exception.

alehel commented 1 year ago

That worked great. Picked up my azw3 file and converted it. Didn't have to put it in a folder either :).

alehel commented 1 year ago

I did some digging. Apparantly the Mac version of the Kindle desktop app uses KCR which is the Kindle Cloud something format. This uses a DRM that hasn't been broken. Kindle desktop software on Windows gives you a file that can be broken when downloading comics. However, newest ebooks can't be broken (and for them the download and transfer trick will continue to work).

I fired up my old Windows machine and CbzMage worked great on all my comics downloaded there. So I used that to get my previous purchases and will continue to get new issues on my Mac now that CbzMage can handle them from the website. That said, I'm guessing it's only a matter of time before the comics move over to newer, not broken drm schemes. Better fill my backlog while I can :p.

ToofDerling commented 1 year ago

v0.25 is up with support for converting/scanning azw/azw3 files directly.

I'm still interested in having a look at a azw3 file and especially a kcr file to see if I can do something about them.