mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-08-11 09:13:57 -04:00
Add UUID as a possible id type to content server ajax/book
This commit is contained in:
parent
810aa02b74
commit
653df51062
@ -2564,6 +2564,11 @@ class LibraryDatabase2(LibraryDatabase, SchemaUpgrade, CustomColumns):
|
|||||||
if notify:
|
if notify:
|
||||||
self.notify('metadata', [id])
|
self.notify('metadata', [id])
|
||||||
|
|
||||||
|
def get_id_from_uuid(self, uuid):
|
||||||
|
if uuid:
|
||||||
|
return self.conn.get('SELECT id FROM books WHERE uuid=?', (uuid,),
|
||||||
|
all=False)
|
||||||
|
|
||||||
# Convenience methods for tags_list_editor
|
# Convenience methods for tags_list_editor
|
||||||
# Note: we generally do not need to refresh_ids because library_view will
|
# Note: we generally do not need to refresh_ids because library_view will
|
||||||
# refresh everything.
|
# refresh everything.
|
||||||
|
@ -181,7 +181,7 @@ class AjaxServer(object):
|
|||||||
return data, mi.last_modified
|
return data, mi.last_modified
|
||||||
|
|
||||||
@Endpoint(set_last_modified=False)
|
@Endpoint(set_last_modified=False)
|
||||||
def ajax_book(self, book_id, category_urls='true'):
|
def ajax_book(self, book_id, category_urls='true', id_is_uuid='false'):
|
||||||
'''
|
'''
|
||||||
Return the metadata of the book as a JSON dictionary.
|
Return the metadata of the book as a JSON dictionary.
|
||||||
|
|
||||||
@ -192,7 +192,10 @@ class AjaxServer(object):
|
|||||||
cherrypy.response.timeout = 3600
|
cherrypy.response.timeout = 3600
|
||||||
|
|
||||||
try:
|
try:
|
||||||
book_id = int(book_id)
|
if id_is_uuid == 'true':
|
||||||
|
book_id = self.db.get_id_from_uuid(book_id)
|
||||||
|
else:
|
||||||
|
book_id = int(book_id)
|
||||||
data, last_modified = self.ajax_book_to_json(book_id,
|
data, last_modified = self.ajax_book_to_json(book_id,
|
||||||
get_category_urls=category_urls.lower()=='true')
|
get_category_urls=category_urls.lower()=='true')
|
||||||
except:
|
except:
|
||||||
@ -204,7 +207,7 @@ class AjaxServer(object):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@Endpoint(set_last_modified=False)
|
@Endpoint(set_last_modified=False)
|
||||||
def ajax_books(self, ids=None, category_urls='true'):
|
def ajax_books(self, ids=None, category_urls='true', id_is_uuid='false'):
|
||||||
'''
|
'''
|
||||||
Return the metadata for a list of books specified as a comma separated
|
Return the metadata for a list of books specified as a comma separated
|
||||||
list of ids. The metadata is returned as a dictionary mapping ids to
|
list of ids. The metadata is returned as a dictionary mapping ids to
|
||||||
@ -218,7 +221,10 @@ class AjaxServer(object):
|
|||||||
if ids is None:
|
if ids is None:
|
||||||
raise cherrypy.HTTPError(404, 'Must specify some ids')
|
raise cherrypy.HTTPError(404, 'Must specify some ids')
|
||||||
try:
|
try:
|
||||||
ids = set(int(x.strip()) for x in ids.split(','))
|
if id_is_uuid == 'true':
|
||||||
|
ids = set(self.db.get_id_from_uuid(x) for x in ids.split(','))
|
||||||
|
else:
|
||||||
|
ids = set(int(x.strip()) for x in ids.split(','))
|
||||||
except:
|
except:
|
||||||
raise cherrypy.HTTPError(404, 'ids must be a comma separated list'
|
raise cherrypy.HTTPError(404, 'ids must be a comma separated list'
|
||||||
' of integers')
|
' of integers')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user