Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 12-21-2016, 11:14 AM   #931
valdor27
Junior Member
valdor27 began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Dec 2016
Device: Kindle Paperwhite (PW3)
Quote:
Originally Posted by JimmXinu View Post
I cheat and include other info in the title using metadata plugins. See attached.
I actually managed to do something nice by adding the pages count and the Gunning fog next to the author name and it is working like a charm.

Thank you very much !
valdor27 is offline   Reply With Quote
Old 12-30-2016, 08:33 PM   #932
Dirk-71
Groupie
Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.
 
Posts: 160
Karma: 35462
Join Date: Dec 2016
Location: Germany
Device: Kobo: Clara BW, Libra 2, Aura One
Since Calibre Version 2.76 (Mac Version) Count Pages is not working anymore when using ADE algorithm. Windows Version of Calibre 2.76 is working perfectly.

The result is always zero.
Dirk-71 is offline   Reply With Quote
Advert
Old 12-30-2016, 09:03 PM   #933
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by Dirk-71 View Post
Since Calibre Version 2.76 (Mac Version) Count Pages is not working anymore when using ADE algorithm. Windows Version of Calibre 2.76 is working perfectly.
I don't know of anything that has changed that would affect the Mac version. I don't have a Mac, so I cannot test this. But, the first thing to do is check the configuration is still correct. Then, after running a count pages job, look at the job details. You do this by clicking "Jobs" in the bottom right corner of the calibre screen to open the job list. Then select the count job and press the "Show job details" button. This should show the counts done and some other details from the job. Please post these.
davidfor is offline   Reply With Quote
Old 12-31-2016, 06:23 AM   #934
Dirk-71
Groupie
Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.
 
Posts: 160
Karma: 35462
Join Date: Dec 2016
Location: Germany
Device: Kobo: Clara BW, Libra 2, Aura One
Quote:
Originally Posted by davidfor View Post
I don't know of anything that has changed that would affect the Mac version. I don't have a Mac, so I cannot test this. But, the first thing to do is check the configuration is still correct. Then, after running a count pages job, look at the job details. You do this by clicking "Jobs" in the bottom right corner of the calibre screen to open the job list. Then select the count job and press the "Show job details" button. This should show the counts done and some other details from the job. Please post these.
I checked the configuration. I uninstalled and reinstalled "Count Pages". I tried everything but it seems to be a bug. I reported to Kovid Goyal but he answered, he doesn't support third party plugins.

Here is the result on Mac Version 2.76:

Count Page/Word Statistics
-------------------------------
Logfile for book ID 2 (Die Stille vor dem Tod)
2
Page count: 0.0

And here is the result on Windows Version 2.76:

Count Page/Word Statistics
-------------------------------
Logfile for book ID 2 (Die Stille vor dem Tod)
Found 42 pages
2
C:\Program Files\Calibre2\pylib.zip\dateutil\parser.py:339: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
Page count: 42.0

Here is the result on Mac Version 2.75.1:

Count Page/Word Statistics
-------------------------------
Logfile for book ID 2 (Die Stille vor dem Tod)
Found 42 pages
2
Page count: 42.0

Here is the result on Windows Version 2.75.1:

Count Page/Word Statistics
-------------------------------
Logfile for book ID 2 (Die Stille vor dem Tod)
Found 42 pages
2
C:\Program Files\Calibre2\pylib.zip\dateutil\parser.py:339: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
Page count: 42.0
Attached Thumbnails
Click image for larger version

Name:	Configuration-Mac.png
Views:	242
Size:	85.4 KB
ID:	153873   Click image for larger version

Name:	Configuration-Windows.png
Views:	228
Size:	59.8 KB
ID:	153874  
Dirk-71 is offline   Reply With Quote
Old 01-01-2017, 03:27 AM   #935
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@Dirk-71: OK, that's pretty conclusive that it isn't working.

Do you know if you are using temporary directory that is a symlink? Looking at the changes between 2.75.1 and 2.76.0, I found this. It is to fix a problem with the viewer when running on Mac where the temp directory is a symlink. And the count pages plugin does use this. It is used to open the book to get the parts in it and then run the statistics over it. If this is broken for the plugin for you, I would think it would also break the viewer.

So:

- What do you have you the temporary directory set to? Is this the system temp dir or one for calibre?
- Does the viewer work with calibre 2.76.0? Did it work for 2.75.1?
davidfor is offline   Reply With Quote
Advert
Old 01-01-2017, 05:58 AM   #936
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: 45,449
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
@davidfor: According to the logs the OP posted it does not work for 2.76 but does for 2.75.1 -- the reason is almost certainly the call to os.path.realpath() Presumably the plugin somewhere does something like os.path.relpath() or checks if the filename startswith the root directory, using the symlinked form of the root directory instead of EbookIterator.base (changing that should fix it).
kovidgoyal is offline   Reply With Quote
Old 01-01-2017, 06:00 AM   #937
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: 45,449
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can probably simulate the problem on windows by changing the self.base at line 142 in iterator/book.py to point to some other directory than os.path.realpath(self._tdir.__enter__())
kovidgoyal is offline   Reply With Quote
Old 01-01-2017, 08:53 AM   #938
Dirk-71
Groupie
Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.
 
Posts: 160
Karma: 35462
Join Date: Dec 2016
Location: Germany
Device: Kobo: Clara BW, Libra 2, Aura One
@davidfor: The viewer is working in all version. I think Kovid has already given the answer to fix the bug. Thank you for your support.
Dirk-71 is offline   Reply With Quote
Old 01-01-2017, 07:09 PM   #939
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@Kovid: Yes, that's what is happening. There is a call to "os.path.relpath()" using "EbookIterator.base". This is being done when calculating the page count via the Adobe method. All it is doing is finding what the name of the files would be so that the compressed file size can be found from the epub file

The code involved is below. The appropriate line is in red. I assume with the change in the way the EbookIterator.base is done, the "private" is no longer in the path. As I don't have access to a Mac to test this on, I have no idea what should be here. Or maybe it would be simpler to go back to the OPF and get the names from there as they should match the names in the file.

Code:
def _get_page_count_adobe(iterator, book_path):
    '''
    This algorithm uses the proper adobe count. We look at the compressed size in the
    zip of every file in the spine, and apply the 1024 bytes calculation to that...
    '''
    import math
    from calibre.utils.zipfile import ZipFile

    with ZipFile(book_path, 'r') as zf:
        size_map = dict({(ci.filename, ci.compress_size) for ci in zf.infolist()})

        pages = 0.0
        for i in iterator.opf.spine:
            spath = i.path
            ppath = spath.partition('#')[0]
            if not os.path.exists(spath) and os.path.exists(ppath):
                spath = ppath

            if isosx:
                internal_path = os.path.relpath(spath.replace('/private',''), iterator.base).replace('\\','/')
            else:
                internal_path = os.path.relpath(spath, iterator.base).replace('\\','/')
            if internal_path in size_map:
                pages += math.ceil(size_map[internal_path] / 1024.0)
        zf.close()

    return pages
davidfor is offline   Reply With Quote
Old 01-01-2017, 09:37 PM   #940
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: 45,449
Karma: 27757438
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
The robust way to do it would be something like:
Code:
base = iterator.base
csizes = {os.path.abspath(os.path.join(base, ci.filename)): ci.compress_size for ci in zf.infolist()}

for path in iterator.spine:
   sz = csizes.get(os.path.abspath(path))
   if sz is not None:
      ...
kovidgoyal is offline   Reply With Quote
Old 01-02-2017, 06:48 AM   #941
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
@Kovid: Yes, that's much better. I'll have a beta version up later, or maybe tomorrow.
davidfor is offline   Reply With Quote
Old 01-03-2017, 02:38 AM   #942
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Beta - Fix problem on Mac plus other things

Attached is a beta of the Count Pages plugin. The trigger for the release is the change in calibre for handling the temporary directory on Macs. The fix for this should work and be backwardly compatible with all calibre versions and OSes. But, there are a lot more changes than this.

The other changes come largely from discussion here early last year about how to count words. At the time, I implemented a word count using the ICU method that had been added to calibre and released this as a beta. There were complaints and I never released this properly. Other changes were because of other discussions or because I was fiddling. Some have been in beta's, some haven't and I've forgotten which have. I think the German Flesch Reading Ease was, but I'm not sure. The full change list from the current released version is:
  • Fix Adobe Page count on Mac machines with calibre 2.76 or later.
  • Changed word count to use ICU BreakIterator. This accepts the book language, so it should be more accurate for non-English as well. Will fall back to old method if the ICU BreakIterator method cannot be loaded.
  • Add option to choose between ICU word count and the old one. The default is ICU word count.
  • Add callback for other plugins calling the count pages. See method call_plugin_callback in common_utils.py.
  • Add language awareness for ICU word count. Uses language in the book, otherwise defaults to English.
  • Added German version of Flesch Reading Ease.
  • Changed tooltip in configuration dialog to show on field as well as label.
  • Added localization support for dialogs.
  • Change way statistics were written the metadata to reduce side effects.

I have been default word count will be the ICU method. That's right, it isn't backwardly compatible, but that's the way I am doing it. If you don't like that, uncheck the option in the configuration before doing a count.

I have also add made the plugin localizable. If anyone wants to do a translation, you can use POEdit. This is an easy to use, free tool for translating. You need to extract the file "default.po" from the plugin file and open it POEdit, set the language and enter the translated text for each source string. POEdit shows what has and hasn't been translated. When you have done the translations, save the file and post or send it to me. And if you see something I missed, tell me.

I'll give this a few days for testing and hopefully some translations. If there are any problems, please report them here with as much detail as possible. Suggestions for improvements are also welcome, but I'll probably not do anything with them until after releasing these changes.
Attached Files
File Type: zip Count Pages-beta.zip (249.5 KB, 182 views)
davidfor is offline   Reply With Quote
Old 01-03-2017, 11:57 AM   #943
Dirk-71
Groupie
Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.
 
Posts: 160
Karma: 35462
Join Date: Dec 2016
Location: Germany
Device: Kobo: Clara BW, Libra 2, Aura One
@davidfor: Thank you. I just checked the beta and it's working now on my Mac. If you need support to translate your plugin in German I can help but need to know how to do it.
Dirk-71 is offline   Reply With Quote
Old 01-03-2017, 12:12 PM   #944
Terisa de morgan
Grand Sorcerer
Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.Terisa de morgan ought to be getting tired of karma fortunes by now.
 
Terisa de morgan's Avatar
 
Posts: 6,649
Karma: 12595249
Join Date: Jun 2009
Location: Madrid, Spain
Device: Kobo Clara/Aura One/Forma,XiaoMI 5, iPad, Huawei MediaPad, YotaPhone 2
@davidfor, I've checked the beta and the callback function works smoothly. Here I send you the translation in Spanish. I've found only a mistake "Updating" and "Updating ".
Attached Files
File Type: zip CountPages_es.zip (7.5 KB, 167 views)
Terisa de morgan is offline   Reply With Quote
Old 01-03-2017, 12:27 PM   #945
Dirk-71
Groupie
Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.Dirk-71 turned on, tuned in, and dropped out.
 
Posts: 160
Karma: 35462
Join Date: Dec 2016
Location: Germany
Device: Kobo: Clara BW, Libra 2, Aura One
Oh, I see, it's a po-File. I know how to do it :-).
I will elaborate on the German translation.
Dirk-71 is offline   Reply With Quote
Reply

Tags
count, count pages, page count, pages, plugin


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Quality Check kiwidude Plugins 1252 08-02-2025 09:53 AM
[GUI Plugin] Open With kiwidude Plugins 404 02-21-2025 05:42 AM
[GUI Plugin] Quick Preferences kiwidude Plugins 62 03-16-2024 11:47 PM
[GUI Plugin] Kindle Collections (old) meme Plugins 2070 08-11-2014 12:02 AM
[GUI Plugin] Plugin Updater **Deprecated** kiwidude Plugins 159 06-19-2011 12:27 PM


All times are GMT -4. The time now is 12:35 PM.


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