View Single Post
Old 06-30-2015, 08:55 AM   #19
darryl
Wizard
darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.darryl ought to be getting tired of karma fortunes by now.
 
darryl's Avatar
 
Posts: 3,108
Karma: 60231510
Join Date: Nov 2011
Location: Australia
Device: Kobo Aura H2O, Kindle Oasis, Huwei Ascend Mate 7
Here are the very simple changes I made. I do not plan to submit them myself. Obviously the changes to the file in srv are not necessary given this is Kovid's re-write. With the changes to the file in library/server there is no problem now with creating a content server metadata plugboard for the kepub format. When downloading kepub books from the content server they do download as kepub epub and the metadata plugboard is applied, at least so far as my setup to modify the title is concerned. It does not, however, actually create a collection or add the book to the collection. Am I correct in assuming that this is a function purely of the driver? It does work over USB using the Kobo Touch driver, but not with the content server.

Given that adding support for new formats seems to be relatively trivial, is it actually worthwhile to support all formats with metadata writers? Support can easily be added on request of users or developers who use the particular format. Support for epub, mobi, azw3 and now kepub seems to cover all of the most common formats, with the exception, I suppose, of pdf, which is not really a great format for ereaders anyway.

Spoiler:
Subject: [PATCH] Content Server support for kepub format metadata plugboards

---
src/calibre/library/server/content.py | 4 ++--
src/calibre/srv/content.py | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/calibre/library/server/content.py b/src/calibre/library/server/content.py
index ef7a7a7..5295cdf 100644
--- a/src/calibre/library/server/content.py
+++ b/src/calibre/library/server/content.py
@@ -21,7 +21,7 @@ from calibre.ebooks.metadata.opf2 import metadata_to_opf
from calibre.utils.config import tweaks

plugboard_content_server_value = 'content_server'
-plugboard_content_server_formats = ['epub', 'mobi', 'azw3']
+plugboard_content_server_formats = ['epub', 'mobi', 'azw3', 'kepub']

class CSSortKeyGenerator(SortKeyGenerator):

@@ -216,7 +216,7 @@ class ContentServer(object):
fm = self.db.format_metadata(id, format, allow_cache=False)
if not fm:
raise cherrypy.HTTPError(404, 'book: %d does not have format: %s'%(id, format))
- update_metadata = format in {'MOBI', 'EPUB', 'AZW3'}
+ update_metadata = format in {'MOBI', 'EPUB', 'AZW3', 'KEPUB'}
mi = newmi = self.db.get_metadata(
id, index_is_id=True, cover_as_data=True, get_cover=update_metadata)

diff --git a/src/calibre/srv/content.py b/src/calibre/srv/content.py
index 4f3b13d..e2e7fa9 100644
--- a/src/calibre/srv/content.py
+++ b/src/calibre/srv/content.py
@@ -28,7 +28,7 @@ from calibre.utils.magick.draw import thumbnail, Image
from calibre.utils.shared_file import share_open

plugboard_content_server_value = 'content_server'
-plugboard_content_server_formats = ['epub', 'mobi', 'azw3']
+plugboard_content_server_formats = ['epub', 'mobi', 'azw3', 'kepub']
update_metadata_in_fmts = frozenset(plugboard_content_server_formats)
lock = Lock()

--
2.4.4
darryl is offline   Reply With Quote