- Added a new arg for getCache: 'opener', which is a urllib2 opener with a cookiejar installed

- The torrent providers now use getCache with the 'opener' argument which they
get after a succesful login, this way they can always access the site with proper authentication.
This commit is contained in:
bwq
2012-06-23 04:24:13 +02:00
parent 1edf7a1a4f
commit 3bf3e4bb7f
5 changed files with 18 additions and 7 deletions
+12 -1
View File
@@ -215,7 +215,18 @@ class Plugin(object):
cache_timeout = kwargs.get('cache_timeout')
del kwargs['cache_timeout']
data = self.urlopen(url, **kwargs)
if kwargs.get('opener'):
opener = kwargs.get('opener')
del kwargs['opener']
if opener:
log.info('Opening url: %s', url)
f = opener.open(url)
data = f.read()
f.close()
else:
data = self.urlopen(url, **kwargs)
if data:
self.setCache(cache_key, data, timeout = cache_timeout)
return data