- if item['enclosure'] is not None:
- handler.addQuickElement(u"link", '',
- {u"rel": u"http://opds-spec.org/acquisition",
- u"href": item['enclosure'].url,
- u"length": item['enclosure'].length,
- u"type": item['enclosure'].mime_type})
- # add a "red book" icon
- handler.addQuickElement(u"link", '',
- {u"rel": u"http://opds-spec.org/thumbnail",
- u"href": self._book_img,
- u"length": self._book_img_size,
- u"type": u"image/png"})
+ for enc in item.get('enclosures', []):
+ handler.startElement(
+ "link",
+ {
+ "rel": "http://opds-spec.org/acquisition",
+ "href": enc.url,
+ "length": str(enc.length),
+ "type": enc.mime_type,
+ })
+ if hasattr(enc, 'indirect'):
+ NS = 'http://opds-spec.org/2010/catalog'
+ handler.startPrefixMapping('opds', NS)
+ handler.startElementNS((NS, 'indirectAcquisition'), 'opds:indirectAcquisition', {
+ (None, 'type'): enc.indirect,
+ })
+ handler.endElementNS((NS, 'indirectAcquisition'), 'opds:indirectAcquisition')
+ handler.endPrefixMapping('opds')
+ handler.endElement('link')
+ # add a "red book" icon
+ handler.addQuickElement(
+ "link", '',
+ {
+ "rel": "http://opds-spec.org/thumbnail",
+ "href": self._book_img,
+ "length": self._book_img_size,
+ "type": "image/png",
+ })