From f369e22de0d62d3159a99295497a0b420761153f Mon Sep 17 00:00:00 2001 From: Christophe Dumez Date: Sat, 19 Jan 2013 18:54:18 +0200 Subject: [PATCH] Fix kat.ph search with python3 --- src/searchengine/nova3/helpers.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/searchengine/nova3/helpers.py b/src/searchengine/nova3/helpers.py index 13b932ba6..98ce6ffb8 100644 --- a/src/searchengine/nova3/helpers.py +++ b/src/searchengine/nova3/helpers.py @@ -22,7 +22,7 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. -#VERSION: 1.31 +#VERSION: 1.32 # Author: # Christophe DUMEZ (chris@qbittorrent.org) @@ -63,6 +63,13 @@ def retrieve_url(url): """ Return the content of the url page as a string """ response = urllib.request.urlopen(url) dat = response.read() + # Check if it is gzipped + if dat[:2] == '\037\213': + # Data is gzip encoded, decode it + compressedstream = StringIO.StringIO(dat) + gzipper = gzip.GzipFile(fileobj=compressedstream) + extracted_data = gzipper.read() + dat = extracted_data info = response.info() charset = 'utf-8' try: