Skip to content

Commit

Permalink
Count Pages - use podofo rather than pdfinfo
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwidude68 committed Apr 7, 2024
1 parent 65ad164 commit a9b72b1
Show file tree
Hide file tree
Showing 21 changed files with 37 additions and 11 deletions.
6 changes: 6 additions & 0 deletions count_pages/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Count Pages Change Log

## [1.13.6] - 2024-04-07
### Changed
- Use podofo rather than pdfinfo to retrieve pdf page count. Shoudl fix issues for some users having problems with pdfinfo.exe
### Fixed
- Fix libpng warning: icCCP: known incorrect sRGB profile using `magick mogrify *.png`

## [1.13.5] - 2024-02-13
### Added
- Finnish translation
Expand Down
2 changes: 1 addition & 1 deletion count_pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ActionCountPages(InterfaceActionBase):
description = 'Count number of pages/words in an ePub/Mobi to store in custom columns'
supported_platforms = ['windows', 'osx', 'linux']
author = 'Grant Drake'
version = (1, 13, 5)
version = (1, 13, 6)
minimum_calibre_version = (2, 0, 0)

#: This field defines the GUI plugin class that contains all the code
Expand Down
Binary file modified count_pages/images/cbdb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/count_pages.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/databazeknih.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/download_all_sources.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/estimate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/goodreads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/lubimyczytac.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified count_pages/images/skoob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions count_pages/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@
RE_STRIP_MARKUP = re.compile(u'<[^>]+>', re.UNICODE)

def get_pdf_page_count(book_path):
'''
Try to use podofo to parse the page count.
This apparently can file for badly formatted pdfs in which case fall back to
trying to use pdfinfo (which some users have reported issues with).
'''
from calibre.utils.podofo import get_podofo
podofo = get_podofo()
try:
p = podofo.PDFDoc()
with open(book_path, 'rb') as f:
raw = f.read()
p.load(raw)
page_count = p.page_count()
print('\tPDF page count using podofo:', page_count)
return int(page_count)
except:
print('\tFailed to get count using podofo, trying pdfinfo')
return get_pdf_page_count_using_pdfinfo(book_path)

def get_pdf_page_count_using_pdfinfo(book_path):
'''
Optimisation to read the actual page count for PDFs from the PDF itself.
'''
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Grant Drake, 2022\n"
"Language-Team: Czech (https://app.transifex.com/calibre/teams/19337/cs/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: e13493b2a936f499f30a988e8a2df4be_22a66bf <faf36a540214319109e3a8bf5cbd8af8_453360>, 2023\n"
"Language-Team: German (https://app.transifex.com/calibre/teams/19337/de/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/es.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Jellby <jellby@yahoo.com>, 2024\n"
"Language-Team: Spanish (https://app.transifex.com/calibre/teams/19337/es/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/fi.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Veikko Muurikainen, 2024\n"
"Language-Team: Finnish (https://app.transifex.com/calibre/teams/19337/fi/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Walter Paterno <walter.paterno@gmail.com>, 2024\n"
"Language-Team: French (https://app.transifex.com/calibre/teams/19337/fr/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/pl.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Silatiw Witalis, 2022\n"
"Language-Team: Polish (https://app.transifex.com/calibre/teams/19337/pl/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: ashed <craysy@gmail.com>, 2022\n"
"Language-Team: Russian (https://app.transifex.com/calibre/teams/19337/ru/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/ta.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: தமிழ்நேரம் <anishprabu.t@gmail.com>, 2023\n"
"Language-Team: Tamil (https://app.transifex.com/calibre/teams/19337/ta/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/tr.po
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Bora Atıcı, 2023\n"
"Language-Team: Turkish (https://app.transifex.com/calibre/teams/19337/tr/)\n"
Expand Down
2 changes: 1 addition & 1 deletion count_pages/translations/uk.po
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-02-14 02:13+1000\n"
"POT-Creation-Date: 2024-03-24 17:57+1000\n"
"PO-Revision-Date: 2022-09-19 15:22+0000\n"
"Last-Translator: Yuri Chornoivan <yurchor@ukr.net>, 2024\n"
"Language-Team: Ukrainian (https://app.transifex.com/calibre/teams/19337/uk/)\n"
Expand Down

0 comments on commit a9b72b1

Please sign in to comment.