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. 11
      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. 2
      couchpotato/core/providers/torrent/torrentleech/main.py

11
couchpotato/core/plugins/base.py

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save