Make subliminal work with Requests 1.0+
This commit is contained in:
1 parent
931951ff37
commit
b61de4866c
1 file changed
+4
-3
@@ -81,7 +81,8 @@ class ServiceBase(object):
|
|||||||
def init(self):
|
def init(self):
|
||||||
"""Initialize connection"""
|
"""Initialize connection"""
|
||||||
logger.debug(u'Initializing %s' % self.__class__.__name__)
|
logger.debug(u'Initializing %s' % self.__class__.__name__)
|
||||||
self.session = requests.session(timeout=10, headers={'User-Agent': self.user_agent})
|
self.session = requests.session()
|
||||||
|
self.session.headers.update({'User-Agent': self.user_agent})
|
||||||
|
|
||||||
def init_cache(self):
|
def init_cache(self):
|
||||||
"""Initialize cache, make sure it is loaded from disk"""
|
"""Initialize cache, make sure it is loaded from disk"""
|
||||||
@@ -191,7 +192,7 @@ class ServiceBase(object):
|
|||||||
"""
|
"""
|
||||||
logger.info(u'Downloading %s in %s' % (url, filepath))
|
logger.info(u'Downloading %s in %s' % (url, filepath))
|
||||||
try:
|
try:
|
||||||
r = self.session.get(url, headers={'Referer': url, 'User-Agent': self.user_agent})
|
r = self.session.get(url, timeout = 10, headers = {'Referer': url, 'User-Agent': self.user_agent})
|
||||||
with open(filepath, 'wb') as f:
|
with open(filepath, 'wb') as f:
|
||||||
f.write(r.content)
|
f.write(r.content)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@@ -212,7 +213,7 @@ class ServiceBase(object):
|
|||||||
logger.info(u'Downloading %s in %s' % (url, filepath))
|
logger.info(u'Downloading %s in %s' % (url, filepath))
|
||||||
try:
|
try:
|
||||||
zippath = filepath + '.zip'
|
zippath = filepath + '.zip'
|
||||||
r = self.session.get(url, headers={'Referer': url, 'User-Agent': self.user_agent})
|
r = self.session.get(url, timeout = 10, headers = {'Referer': url, 'User-Agent': self.user_agent})
|
||||||
with open(zippath, 'wb') as f:
|
with open(zippath, 'wb') as f:
|
||||||
f.write(r.content)
|
f.write(r.content)
|
||||||
if not zipfile.is_zipfile(zippath):
|
if not zipfile.is_zipfile(zippath):
|
||||||
|
|||||||
Reference in new issue
Block a user