- 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:
1 parent
1edf7a1a4f
commit
3bf3e4bb7f
5 files changed
+15
-4
No files matched your search
@@ -215,7 +215,18 @@ class Plugin(object):
|
|||||||
cache_timeout = kwargs.get('cache_timeout')
|
cache_timeout = kwargs.get('cache_timeout')
|
||||||
del kwargs['cache_timeout']
|
del kwargs['cache_timeout']
|
||||||
|
|
||||||
|
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)
|
data = self.urlopen(url, **kwargs)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
self.setCache(cache_key, data, timeout = cache_timeout)
|
self.setCache(cache_key, data, timeout = cache_timeout)
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class TorrentProvider(YarrProvider):
|
|||||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
|
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
|
||||||
urllib2.install_opener(opener)
|
urllib2.install_opener(opener)
|
||||||
f = opener.open(self.urls['login'], params)
|
f = opener.open(self.urls['login'], params)
|
||||||
data = f.read()
|
loginData = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
except:
|
except:
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class SceneAccess(TorrentProvider):
|
|||||||
log.info("Couldn't login at SceneAccess")
|
log.info("Couldn't login at SceneAccess")
|
||||||
return results
|
return results
|
||||||
|
|
||||||
data = self.getCache(cache_key, searchUrl)
|
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
html = BeautifulSoup(data)
|
html = BeautifulSoup(data)
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class SceneHD(TorrentProvider):
|
|||||||
log.error("Couldn't login at SceneHD")
|
log.error("Couldn't login at SceneHD")
|
||||||
return results
|
return results
|
||||||
|
|
||||||
data = self.getCache(cache_key, searchUrl)
|
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
html = BeautifulSoup(data)
|
html = BeautifulSoup(data)
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class TorrentLeech(TorrentProvider):
|
|||||||
log.info("Couldn't login at Torrentleech")
|
log.info("Couldn't login at Torrentleech")
|
||||||
return results
|
return results
|
||||||
|
|
||||||
data = self.getCache(cache_key, searchUrl)
|
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
html = BeautifulSoup(data)
|
html = BeautifulSoup(data)
|
||||||
|
|||||||
Reference in new issue
Block a user