Use zlib instead of gzip
The reason to make this change is that I had problems with some URL's and I saw that the problem whas the Gunzip. I saw that the "gzip" http content is the same that we can found in this stackoverflow post: http://stackoverflow.com/a/3947241/1344260 And it fails too, here you have my test/problem: http://pastebin.com/3rvmCEkU It do a IOError: CRC check failed 0xac557afc != 0x2338b236L and torrenter fails. After that, I read this message and test the solution: http://stackoverflow.com/a/13692010/1344260 And its working. So I changed the code.
This commit is contained in:
		
							parent
							
								
									0d398c9feb
								
							
						
					
					
						commit
						0def096fb1
					
				@ -22,7 +22,7 @@ import urllib2
 | 
			
		||||
import hashlib
 | 
			
		||||
import re
 | 
			
		||||
from StringIO import StringIO
 | 
			
		||||
import gzip
 | 
			
		||||
import zlib
 | 
			
		||||
 | 
			
		||||
import xbmc
 | 
			
		||||
import xbmcgui
 | 
			
		||||
@ -205,8 +205,8 @@ class AnteoLoader:
 | 
			
		||||
                    result = urllib2.urlopen(request)
 | 
			
		||||
                    if result.info().get('Content-Encoding') == 'gzip':
 | 
			
		||||
                        buf = StringIO(result.read())
 | 
			
		||||
                        f = gzip.GzipFile(fileobj=buf)
 | 
			
		||||
                        content = f.read()
 | 
			
		||||
                        decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
 | 
			
		||||
                        content = decomp.decompress(buf.getvalue())
 | 
			
		||||
                    else:
 | 
			
		||||
                        content = result.read()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -24,7 +24,7 @@ import urllib2
 | 
			
		||||
import hashlib
 | 
			
		||||
import re
 | 
			
		||||
from StringIO import StringIO
 | 
			
		||||
import gzip
 | 
			
		||||
import zlib
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
import xbmc
 | 
			
		||||
@ -108,8 +108,8 @@ class Libtorrent:
 | 
			
		||||
                    result = urllib2.urlopen(request)
 | 
			
		||||
                    if result.info().get('Content-Encoding') == 'gzip':
 | 
			
		||||
                        buf = StringIO(result.read())
 | 
			
		||||
                        f = gzip.GzipFile(fileobj=buf)
 | 
			
		||||
                        content = f.read()
 | 
			
		||||
                        decomp = zlib.decompressobj(16 + zlib.MAX_WBITS)
 | 
			
		||||
                        content = decomp.decompress(buf.getvalue())
 | 
			
		||||
                    else:
 | 
			
		||||
                        content = result.read()
 | 
			
		||||
 | 
			
		||||
@ -428,7 +428,7 @@ class Libtorrent:
 | 
			
		||||
                       #'storage_mode': self.lt.storage_mode_t(1),
 | 
			
		||||
                       'paused': False,
 | 
			
		||||
                       #'auto_managed': False,
 | 
			
		||||
                       'duplicate_is_error': False
 | 
			
		||||
                       #'duplicate_is_error': True
 | 
			
		||||
                      }
 | 
			
		||||
        if self.save_resume_data:
 | 
			
		||||
            log('loading resume data')
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user