diff --git a/src/calibre/library/server/opds.py b/src/calibre/library/server/opds.py index 43cde646c6..41d3654890 100644 --- a/src/calibre/library/server/opds.py +++ b/src/calibre/library/server/opds.py @@ -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 diff --git a/src/calibre/srv/opds.py b/src/calibre/srv/opds.py index e5e8e95c1e..a1e50306e6 100644 --- a/src/calibre/srv/opds.py +++ b/src/calibre/srv/opds.py @@ -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"))