mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-31 14:33:54 -04:00
Support old style /get/thumb/book_id_w_h endpoint for backwards compat
This commit is contained in:
parent
92aea42144
commit
6a6c7a0105
@ -10,6 +10,7 @@ import os
|
|||||||
from binascii import hexlify
|
from binascii import hexlify
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
from future_builtins import map
|
||||||
|
|
||||||
from calibre import fit_image
|
from calibre import fit_image
|
||||||
from calibre.constants import config_dir, iswindows
|
from calibre.constants import config_dir, iswindows
|
||||||
@ -226,8 +227,13 @@ def icon(ctx, rd, which):
|
|||||||
return ans
|
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):
|
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)
|
db = ctx.get_library(library_id)
|
||||||
if db is None:
|
if db is None:
|
||||||
raise HTTPNotFound('Library %r not found' % library_id)
|
raise HTTPNotFound('Library %r not found' % library_id)
|
||||||
@ -239,6 +245,9 @@ def get(ctx, rd, what, book_id, library_id):
|
|||||||
sz = rd.query.get('sz')
|
sz = rd.query.get('sz')
|
||||||
w, h = 60, 80
|
w, h = 60, 80
|
||||||
if sz is None:
|
if sz is None:
|
||||||
|
try:
|
||||||
|
w, h = map(int, rest.split('_'))
|
||||||
|
except Exception:
|
||||||
pass
|
pass
|
||||||
elif sz == 'full':
|
elif sz == 'full':
|
||||||
w = h = None
|
w = h = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user