corrected handling with http response headers

This commit is contained in:
Roman Mukhin 2019-12-16 15:01:21 +01:00
parent f1ce7c0cf9
commit 8dddfb9c05

View File

@ -85,7 +85,7 @@ class LitResStore(BasicStoreConfig, StorePlugin):
sRes = SearchResult() sRes = SearchResult()
sRes.drm = SearchResult.DRM_UNLOCKED sRes.drm = SearchResult.DRM_UNLOCKED
sRes.detail_item = data.xpath(xp_template.format('hub_id')) sRes.detail_item = data.xpath(xp_template.format('hub_id'))
sRes.title = data.xpath('string(.//title-info/book-title/text()|.//publish-info/book-name/text())') sRes.title = data.xpath('string(.//title-info/book-title/text()|.//publish-info/book-name/text())')
# aut = concat('.//title-info/author/first-name', ' ') # aut = concat('.//title-info/author/first-name', ' ')
authors = data.xpath('.//title-info/author/first-name/text()|' authors = data.xpath('.//title-info/author/first-name/text()|'
@ -121,7 +121,7 @@ def format_price_in_RUR(price):
def ungzipResponse(r,b): def ungzipResponse(r,b):
headers = r.info() headers = r.info()
if headers['Content-Encoding']=='gzip': if headers.get('Content-Encoding', '')=='gzip':
import gzip import gzip
gz = gzip.GzipFile(fileobj=r, mode='rb') gz = gzip.GzipFile(fileobj=r, mode='rb')
data = gz.read() data = gz.read()