kickass: Fix downloading gziped torrents
This commit is contained in:
parent
dc4fa48e53
commit
4b7aa7e9fd
1 changed files with 11 additions and 1 deletions
|
|
@ -23,6 +23,8 @@ from weboob.tools.backend import BaseBackend
|
|||
from .browser import KickassBrowser
|
||||
|
||||
from urllib import quote_plus
|
||||
from contextlib import closing
|
||||
from gzip import GzipFile
|
||||
|
||||
__all__ = ['KickassBackend']
|
||||
|
||||
|
|
@ -47,7 +49,15 @@ class KickassBackend(BaseBackend, ICapTorrent):
|
|||
if not torrent:
|
||||
return None
|
||||
|
||||
return self.browser.openurl(torrent.url.encode('utf-8')).read()
|
||||
# decode gzip if needed
|
||||
response = self.browser.openurl(torrent.url.encode('utf-8'))
|
||||
headers = response.info()
|
||||
if headers.get('Content-Encoding', '') == 'gzip':
|
||||
with closing(GzipFile(fileobj=response, mode='rb')) as gz:
|
||||
data = gz.read()
|
||||
else:
|
||||
data = response.read()
|
||||
return data
|
||||
|
||||
def iter_torrents(self, pattern):
|
||||
return self.browser.iter_torrents(quote_plus(pattern.encode('utf-8')))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue