Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to mobi format #299

Closed
dxcore35 opened this issue Feb 8, 2021 · 15 comments
Closed

Convert to mobi format #299

dxcore35 opened this issue Feb 8, 2021 · 15 comments

Comments

@dxcore35
Copy link

dxcore35 commented Feb 8, 2021

System: Mac OS Big sur
Software: PyGlossary Version 4.0.11


Hello,

I would like to convert my AppleDictionary into Kindle format. I'm using this option:
Screenshot 2021-02-08 at 10 08 14

But I don't know what file to chose.... I don't fully understand what you mean by binary.

  • if I chose the folder I got error
  • if I chose some of the files inside example.dictionary I got error

Error msg

[INFO] Failed to detect sourceLang and targetLang from glossary name 'Apple.xml'

@ilius ilius added Q&A and removed Feature labels Feb 8, 2021
@ilius
Copy link
Owner

ilius commented Feb 8, 2021

You can either choose the directory, or Contents/Body.data file insids it.

What error do you get?

@dxcore35
Copy link
Author

dxcore35 commented Feb 8, 2021

[INFO] Failed to detect sourceLang and targetLang from glossary name ....

@ilius
Copy link
Owner

ilius commented Feb 8, 2021

That's not error, it says INFO
Please paste the full console output/error.

@dxcore35
Copy link
Author

dxcore35 commented Feb 8, 2021

When chosing "Example.dictionary" as folder.

[DEBUG] readOptions: {}
[DEBUG] writeOptions: {}
Traceback (most recent call last):
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 840, in read
    reader.open(filename)
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/plugins/appledict_bin.py", line 80, in open
    self._file = open(filename, "rb")
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dxcore35/Documents/db_Dictionaries/Cambridge International Dictionary of Idioms (20000)/Apple/objects/Idioms.dictionary/Contents/Resources/Body.data'

The file is there:

Screenshot 2021-02-08 at 10 27 51

This when chosing "Body.data"

[DEBUG] readOptions: {}
[DEBUG] writeOptions: {}
[INFO] Failed to detect sourceLang and targetLang from glossary name 'Idioms'

[WARNING] Full sort enabled, falling back to indirect mode
[CRITICAL] Traceback (most recent call last):
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/ui/ui_gtk.py", line 1190, in convertClicked
    finalOutputFile = self.glos.convert(
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 1279, in convert
    finalOutputFile = self.write(
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 1108, in write
    self._inactivateDirectMode()
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 897, in _inactivateDirectMode
    self.loadReader(reader)
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 876, in loadReader
    for index, entry in enumerate(self._applyEntryFiltersGen(reader)):
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 421, in _applyEntryFiltersGen
    for index, entry in enumerate(gen):
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/plugins/appledict_bin.py", line 173, in __iter__
    self._absPos = file.tell()
AttributeError: 'NoneType' object has no attribute 'tell'
Traceback locals:
    self = <appledict_bin.Reader object at 0x7fbc0b8e2880>
    file = None
    limit = 1852976752

@ilius
Copy link
Owner

ilius commented Feb 8, 2021

I pushed some changes, please try again.

Also, how big is the file?
Can you upload it?

@dxcore35
Copy link
Author

dxcore35 commented Feb 8, 2021

I updated the appledict_bin.py

But still getting error:

Traceback (most recent call last):
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/glossary.py", line 840, in read
    reader.open(filename)
  File "/Users/dxcore35/Python/Functional scripts/Pyglossary - building dictionaries/pyglossary/plugins/appledict_bin.py", line 80, in open
    dbname = parts[-4]
FileNotFoundError: [Errno 2] No such file or directory: '/Users/dxcore35/Library/Dictionaries/Idioms.dictionary/Contents/Resources/Body.data'

Why the script is trying to add /Resources/ folder in file path. There is not such folder in Apple dictionaries....
'/Users/dxcore35/Library/Dictionaries/Idioms.dictionary/Contents/Resources/Body.data'
'/Users/dxcore35/Library/Dictionaries/Idioms.dictionary/Contents/Body.data'

@ilius
Copy link
Owner

ilius commented Feb 8, 2021

I don't think the code is updated.
Please download the whole project and replace the old one.

It tries to find both.

@dxcore35
Copy link
Author

dxcore35 commented Feb 8, 2021

  1. You were right! It has produced the folder - But why it isn't mobi format?
  2. I see there is no CSS file inside

@ilius
Copy link
Owner

ilius commented Feb 8, 2021

I added css file, please try again.

What makes you think it's not mobi format?
Does it need to become a zip file?
I don't recall.

@dxcore35
Copy link
Author

dxcore35 commented Feb 8, 2021

It has become just folder.... and inside 2 folders (It has same structure of the EPUBs what I recall)

  • OEBPS
  • META-INF

I know that EPUB is just zipped html's, but when I zip it and rename it to .mobi the mobi is corupted.

What is inside the folder

Screenshot 2021-02-08 at 12 45 59

@ilius ilius changed the title AppleDict Binary (conversion) Convert to mobi format Feb 9, 2021
@dxcore35
Copy link
Author

Hello, any progress after few months in fixing this issue?
Or do you have any work around?

@ilius
Copy link
Owner

ilius commented May 27, 2021

Sorry.
I don't have a compatible device.
I based the plugin on a code from Penelope.
I don't remember actually testing or confirming the format.

@dxcore35
Copy link
Author

Ok so the output from the tool should be processed by KindleGen software by Amazon (discontinued).

Here is some tip how to still use it on MacOS:
asciidoctor/asciidoctor-epub3#363 (comment)

So basically user can:

  1. Set the new KindleGen path in pyglossary settings of mobi format
  2. Output the file, edit OPF file, and run KindleGen manually

@dxcore35
Copy link
Author

So my proposal is to write either:

  • in documentation that KindleGen is required for converting of MOBI
  • check if KindleGen exist if no throw error during conversion process

I'm confirming that I was able to convert the output files made by Pyglossary via manually executing the KindleGen.
Even when I set the KindleGen path in Pyglossary, the tool throw error and produce only the files I mentioned before.

@ilius
Copy link
Owner

ilius commented Jun 7, 2021

I updated the code and documentation.
Thanks.

@ilius ilius closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants