From 6a6c7a01058d27fab14ecfaf4cdc2a9294f27052 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 20 Feb 2016 10:07:09 +0530 Subject: [PATCH] Support old style /get/thumb/book_id_w_h endpoint for backwards compat --- src/calibre/srv/content.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/calibre/srv/content.py b/src/calibre/srv/content.py index 1ba7a94f7a..9c7f330157 100644 --- a/src/calibre/srv/content.py +++ b/src/calibre/srv/content.py @@ -10,6 +10,7 @@ import os from binascii import hexlify from io import BytesIO from threading import Lock +from future_builtins import map from calibre import fit_image from calibre.constants import config_dir, iswindows @@ -226,8 +227,13 @@ def icon(ctx, rd, which): return ans -@endpoint('/get/{what}/{book_id}/{library_id=None}', types={'book_id':int}) +@endpoint('/get/{what}/{book_id}/{library_id=None}') def get(ctx, rd, what, book_id, library_id): + book_id, rest = book_id.partition('_')[::2] + try: + book_id = int(book_id) + except Exception: + raise HTTPNotFound('Book with id %r does not exist' % book_id) db = ctx.get_library(library_id) if db is None: raise HTTPNotFound('Library %r not found' % library_id) @@ -239,7 +245,10 @@ def get(ctx, rd, what, book_id, library_id): sz = rd.query.get('sz') w, h = 60, 80 if sz is None: - pass + try: + w, h = map(int, rest.split('_')) + except Exception: + pass elif sz == 'full': w = h = None elif 'x' in sz: