diff options
author | mkaay <mkaay@mkaay.de> | 2010-05-06 21:15:03 +0200 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2010-05-06 21:15:03 +0200 |
commit | 4adeedcf1e09fcefe2f8c758199d6fafebebce28 (patch) | |
tree | 7c0e9b33b4be03fd68e0484d4cfd7d006a683f46 /module/RequestFactory.py | |
parent | better request factory (diff) | |
download | pyload-4adeedcf1e09fcefe2f8c758199d6fafebebce28.tar.xz |
account plugins: first draft
Diffstat (limited to 'module/RequestFactory.py')
-rw-r--r-- | module/RequestFactory.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/module/RequestFactory.py b/module/RequestFactory.py index 9b56f4778..803e12814 100644 --- a/module/RequestFactory.py +++ b/module/RequestFactory.py @@ -20,12 +20,14 @@ from threading import Lock from module.network.Request import Request from tempfile import NamedTemporaryFile +import pycurl class RequestFactory(): def __init__(self, core): self.lock = Lock() self.core = core self.requests = [] + self.cookiejars = {} def getRequest(self, pluginName, account=None): self.lock.acquire() @@ -44,7 +46,9 @@ class RequestFactory(): cookieFile = th.name th.close() - req = Request(cookieFile) + req = Request(str(cookieFile)) + s = self.getCookieJar(str(cookieFile)) + req.setCookieJar(s) self.requests.append((pluginName, account, req)) self.lock.release() return req @@ -54,3 +58,22 @@ class RequestFactory(): for req in self.requests: req[2].clean() self.lock.release() + + def getCookieJar(self, cookieFile): + if self.cookiejars.has_key(cookieFile): + return self.cookiejars[cookieFile] + j = CookieJar() + self.cookiejars[cookieFile] = j + return j + +class CookieJar(): + def __init__(self): + self.cookies = {} + + def addCookies(self, clist): + for c in clist: + name = c.split("\t")[5] + self.cookies[name] = c + + def getCookies(self): + return self.cookies.values() |