- 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:
@@ -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
|
||||
|
||||
@@ -16,7 +16,7 @@ class TorrentProvider(YarrProvider):
|
||||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar))
|
||||
urllib2.install_opener(opener)
|
||||
f = opener.open(self.urls['login'], params)
|
||||
data = f.read()
|
||||
loginData = f.read()
|
||||
f.close()
|
||||
|
||||
except:
|
||||
|
||||
@@ -53,7 +53,7 @@ class SceneAccess(TorrentProvider):
|
||||
log.info("Couldn't login at SceneAccess")
|
||||
return results
|
||||
|
||||
data = self.getCache(cache_key, searchUrl)
|
||||
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||
|
||||
if data:
|
||||
html = BeautifulSoup(data)
|
||||
|
||||
@@ -48,7 +48,7 @@ class SceneHD(TorrentProvider):
|
||||
log.error("Couldn't login at SceneHD")
|
||||
return results
|
||||
|
||||
data = self.getCache(cache_key, searchUrl)
|
||||
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||
|
||||
if data:
|
||||
html = BeautifulSoup(data)
|
||||
|
||||
@@ -22,7 +22,7 @@ class TorrentLeech(TorrentProvider):
|
||||
|
||||
urls = {
|
||||
'test' : 'http://torrentleech.org/',
|
||||
'login' : 'http://torrentleech.org/user/account/login/',
|
||||
'login' : 'http://torrentleech.org/user/account/login/',
|
||||
'detail' : 'http://torrentleech.org/torrent/%s',
|
||||
'search' : 'http://torrentleech.org/torrents/browse/index/query/%s/categories/%d',
|
||||
'download' : 'http://torrentleech.org%s',
|
||||
@@ -42,7 +42,7 @@ class TorrentLeech(TorrentProvider):
|
||||
|
||||
def getLoginParams(self):
|
||||
loginParams = urllib.urlencode(dict(username=''+self.conf('username'), password=''+self.conf('password'), remember_me='on', login='submit'))
|
||||
return loginParams
|
||||
return loginParams
|
||||
|
||||
def search(self, movie, quality):
|
||||
|
||||
@@ -59,7 +59,7 @@ class TorrentLeech(TorrentProvider):
|
||||
log.info("Couldn't login at Torrentleech")
|
||||
return results
|
||||
|
||||
data = self.getCache(cache_key, searchUrl)
|
||||
data = self.getCache(cache_key, searchUrl, opener = opener)
|
||||
|
||||
if data:
|
||||
html = BeautifulSoup(data)
|
||||
|
||||
Reference in New Issue
Block a user