From d1c6e551a97a8b3e0c3a8def0e3a5e8c41d75716 Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Fri, 4 Sep 2009 16:30:56 +0000 Subject: [PATCH] another patch from David Mohr adding basic cookies support in core --- deluge/plugins/feeder/feeder/core.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/deluge/plugins/feeder/feeder/core.py b/deluge/plugins/feeder/feeder/core.py index 4a7aae17e..28ec482fc 100644 --- a/deluge/plugins/feeder/feeder/core.py +++ b/deluge/plugins/feeder/feeder/core.py @@ -1,8 +1,8 @@ # # core.py # +# Copyright (C) 2008-2009 Fredrik Eriksson # Copyright (C) 2009 David Mohr -# Copyright (C) 2008 Fredrik Eriksson # # Basic plugin template created by: # Copyright (C) 2008 Martijn Voncken @@ -63,14 +63,21 @@ class Feed: """ def __init__(self): self.url = "" + self.cookies = {} self.updatetime = 15 def get_config(self): - return {'url': self.url, 'updatetime': self.updatetime} + try: + tmp = self.cookies + except Exception, e: + log.debug("Old feed without cookies... updating") + self.cookies = {} + return {'url': self.url, 'updatetime': self.updatetime, 'cookies': self.cookies} def set_config(self, config): self.url = config['url'] self.updatetime = config['updatetime'] + self.cookies = config['cookies'] class Filter: @@ -399,7 +406,7 @@ class Core(CorePluginBase): # check history to prevent multiple adds of the same torrent log.debug("testing %s", entry.link) if not entry.link in self.history: - self.add_torrent(entry.link, opts) + self.add_torrent(entry.link, opts, self.feeds[feedname].cookies) self.history.append(entry.link) #limit history to 50 entries @@ -420,6 +427,6 @@ class Core(CorePluginBase): else: return False - def add_torrent(self, url, torrent_options): + def add_torrent(self, url, torrent_options, headers): log.debug("Attempting to add torrent %s", url) - component.get("Core").add_torrent_url(url, torrent_options) + component.get("Core").add_torrent_url(url, torrent_options, headers)