mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Content server: OPDS feeds: Change the value of <updated> for entries in the acquisition feed to be the last modified date for the book. Also make the size and last modified timestamp available as attributes in the acquisition links.
This commit is contained in:
parent
62ea49ad02
commit
93c31cdaff
@ -205,19 +205,24 @@ def ACQUISITION_ENTRY(item, version, db, updated, CFM, CKEYS, prefix):
|
||||
idm = 'calibre' if version == 0 else 'uuid'
|
||||
id_ = 'urn:%s:%s'%(idm, item[FM['uuid']])
|
||||
ans = E.entry(TITLE(title), E.author(E.name(authors)), ID(id_),
|
||||
UPDATED(updated))
|
||||
UPDATED(item[FM['last_modified']]))
|
||||
if len(extra):
|
||||
ans.append(E.content(extra, type='xhtml'))
|
||||
formats = item[FM['formats']]
|
||||
if formats:
|
||||
book_id = item[FM['id']]
|
||||
for fmt in formats.split(','):
|
||||
fmt = fmt.lower()
|
||||
mt = guess_type('a.'+fmt)[0]
|
||||
href = prefix + '/get/%s/%s'%(fmt, item[FM['id']])
|
||||
href = prefix + '/get/%s/%s'%(fmt, book_id)
|
||||
if mt:
|
||||
link = E.link(type=mt, href=href)
|
||||
if version > 0:
|
||||
link.set('rel', "http://opds-spec.org/acquisition")
|
||||
fm = db.format_metadata(book_id, fmt)
|
||||
if fm:
|
||||
link.set('length', str(fm['size']))
|
||||
link.set('mtime', fm['mtime'].isoformat())
|
||||
ans.append(link)
|
||||
ans.append(E.link(type='image/jpeg', href=prefix+'/get/cover/%s'%item[FM['id']],
|
||||
rel="x-stanza-cover-image" if version == 0 else
|
||||
|
@ -198,16 +198,22 @@ def ACQUISITION_ENTRY(book_id, updated, request_context):
|
||||
extra.append(comments)
|
||||
if extra:
|
||||
extra = html_to_lxml('\n'.join(extra))
|
||||
ans = E.entry(TITLE(mi.title), E.author(E.name(authors_to_string(mi.authors))), ID('urn:uuid:' + mi.uuid), UPDATED(updated))
|
||||
ans = E.entry(TITLE(mi.title), E.author(E.name(authors_to_string(mi.authors))), ID('urn:uuid:' + mi.uuid), UPDATED(mi.last_modified))
|
||||
if len(extra):
|
||||
ans.append(E.content(extra, type='xhtml'))
|
||||
get = partial(request_context.ctx.url_for, '/get', book_id=book_id, library_id=request_context.library_id)
|
||||
if mi.formats:
|
||||
fm = mi.format_metadata
|
||||
for fmt in mi.formats:
|
||||
fmt = fmt.lower()
|
||||
mt = guess_type('a.'+fmt)[0]
|
||||
if mt:
|
||||
ans.append(E.link(type=mt, href=get(what=fmt), rel="http://opds-spec.org/acquisition"))
|
||||
link = E.link(type=mt, href=get(what=fmt), rel="http://opds-spec.org/acquisition")
|
||||
ffm = fm.get(fmt.upper())
|
||||
if ffm:
|
||||
link.set('length', str(ffm['size']))
|
||||
link.set('mtime', ffm['mtime'].isoformat())
|
||||
ans.append(link)
|
||||
ans.append(E.link(type='image/jpeg', href=get(what='cover'), rel="http://opds-spec.org/cover"))
|
||||
ans.append(E.link(type='image/jpeg', href=get(what='thumb'), rel="http://opds-spec.org/thumbnail"))
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user