Browse Source
- added global download func (same, downloading also requires cookies) These 2 functions were necessary to allow the user to download other found releases at a later time. In the current version this doesn't work because it goes to the url directly, without any cookies which causes it to download the login page instead of a torrent. All 3 providers now properly use the cache and have much better error handling.pull/482/head
4 changed files with 77 additions and 77 deletions
@ -1,5 +1,31 @@ |
|||
from couchpotato.core.providers.base import YarrProvider |
|||
from couchpotato.core.logger import CPLog |
|||
import urllib2 |
|||
import cookielib |
|||
|
|||
log = CPLog(__name__) |
|||
|
|||
|
|||
class TorrentProvider(YarrProvider): |
|||
type = 'torrent' |
|||
|
|||
def login(self, params): |
|||
|
|||
try: |
|||
cookiejar = cookielib.CookieJar() |
|||
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookiejar)) |
|||
urllib2.install_opener(opener) |
|||
f = opener.open(self.urls['login'], params) |
|||
data = f.read() |
|||
f.close() |
|||
|
|||
except: |
|||
log.error('Failed to login.') |
|||
|
|||
return opener |
|||
|
|||
def download(self, url = '', nzb_id = ''): |
|||
loginParams = self.getLoginParams() |
|||
self.login(params = loginParams) |
|||
torrent = self.urlopen(url) |
|||
return torrent |
|||
|
Loading…
Reference in new issue