Browse Source

- 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.
pull/482/head
bwq 13 years ago
parent
commit
3bf3e4bb7f
  1. 13
      couchpotato/core/plugins/base.py
  2. 2
      couchpotato/core/providers/torrent/base.py
  3. 2
      couchpotato/core/providers/torrent/sceneaccess/main.py
  4. 2
      couchpotato/core/providers/torrent/scenehd/main.py
  5. 6
      couchpotato/core/providers/torrent/torrentleech/main.py

13
couchpotato/core/plugins/base.py

@ -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

2
couchpotato/core/providers/torrent/base.py

@ -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:

2
couchpotato/core/providers/torrent/sceneaccess/main.py

@ -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)

2
couchpotato/core/providers/torrent/scenehd/main.py

@ -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)

6
couchpotato/core/providers/torrent/torrentleech/main.py

@ -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)

Loading…
Cancel
Save