Skip to content

Commit bdcc06d

Browse files
feat: support kepub files in web reader
AFAICT kepub files are compliant with the EPUB specification. In limited testing, the epub reader seems to handle them just fine.
1 parent b5cd3c2 commit bdcc06d

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

cps/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def check_send_to_ereader(entry):
206206
# Check if a reader is existing for any of the book formats, if not, return empty list, otherwise return
207207
# list with supported formats
208208
def check_read_formats(entry):
209-
extensions_reader = {'TXT', 'PDF', 'EPUB', 'CBZ', 'CBT', 'CBR', 'DJVU', 'DJV'}
209+
extensions_reader = {'TXT', 'PDF', 'EPUB', 'KEPUB', 'CBZ', 'CBT', 'CBR', 'DJVU', 'DJV'}
210210
book_formats = list()
211211
if len(entry.data):
212212
for ele in iter(entry.data):

cps/templates/read.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ <h3>{{_('Settings')}}</h3>
127127
window.calibre = {
128128
filePath: "{{ url_for('static', filename='js/libs/') }}",
129129
cssPath: "{{ url_for('static', filename='css/') }}",
130-
bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=bookid, book_format='EPUB') }}",
131-
bookUrl: "{{ url_for('web.serve_book', book_id=bookid, book_format='epub', anyname='file.epub') }}",
130+
bookmarkUrl: "{{ url_for('web.set_bookmark', book_id=bookid, book_format=book_format|upper) }}",
131+
bookUrl: "{{ url_for('web.serve_book', book_id=bookid, book_format=book_format, anyname='file.epub') }}",
132132
bookmark: "{{ bookmark.bookmark_key if bookmark != None }}",
133133
useBookmarks: "{{ current_user.is_authenticated | tojson }}",
134134
kosyncPercent: {{ kosync_progress | tojson if kosync_progress is not none else 'null' }}

cps/web.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,7 +1908,7 @@ def serve_book(book_id, book_format, anyname):
19081908
log.error_or_exception(ex)
19091909
return "File Not Found"
19101910
else:
1911-
if book_format.upper() == 'EPUB':
1911+
if book_format.upper() in ('EPUB', 'KEPUB'):
19121912
original_path = os.path.join(config.get_book_path(), book.path, data.name + "." + book_format)
19131913
fixed_path = _repair_epub_container_if_needed(book_id, original_path)
19141914
if fixed_path:
@@ -2845,10 +2845,11 @@ def read_book(book_id, book_format):
28452845
except Exception as e:
28462846
log.debug(f"Failed to log read activity: {e}")
28472847

2848-
if book_format.lower() == "epub":
2849-
log.debug("Start epub reader for %d", book_id)
2848+
if book_format.lower() in ("epub", "kepub"):
2849+
log.debug("Start epub reader for %d (%s)", book_id, book_format.lower())
28502850
return render_title_template('read.html', bookid=book_id, title=book.title,
2851-
bookmark=bookmark, kosync_progress=kosync_progress)
2851+
bookmark=bookmark, kosync_progress=kosync_progress,
2852+
book_format=book_format.lower())
28522853
elif book_format.lower() == "pdf":
28532854
log.debug("Start pdf reader for %d", book_id)
28542855
return render_title_template('readpdf.html', pdffile=book_id, title=book.title)

0 commit comments

Comments
 (0)