diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-12-29 13:28:16 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-12-29 13:28:16 +0100 |
commit | 02a12fe304da59c6a68071af0c8587270870803d (patch) | |
tree | fc5f0c147772ab20ff114f305ce960772f8a163b | |
parent | fixed accounts (diff) | |
download | pyload-02a12fe304da59c6a68071af0c8587270870803d.tar.xz |
better cleanup
-rw-r--r-- | module/PluginThread.py | 3 | ||||
-rw-r--r-- | module/PyFile.py | 3 | ||||
-rw-r--r-- | module/network/Browser.py | 9 | ||||
-rw-r--r-- | module/network/HTTPDownload.py | 2 | ||||
-rw-r--r-- | module/network/HTTPRequest.py | 14 | ||||
-rw-r--r-- | module/plugins/Plugin.py | 14 | ||||
-rw-r--r-- | module/plugins/hoster/MegauploadCom.py | 7 |
7 files changed, 33 insertions, 19 deletions
diff --git a/module/PluginThread.py b/module/PluginThread.py index f72e94eaf..4c1d93af2 100644 --- a/module/PluginThread.py +++ b/module/PluginThread.py @@ -108,8 +108,7 @@ class PluginThread(Thread): f.close() def clean(self, pyfile): - """ set thread unactive and clean pyfile """ - pyfile.plugin.req.clean() + """ set thread unactive and release pyfile """ self.active = False pyfile.release() diff --git a/module/PyFile.py b/module/PyFile.py index 648b7e838..45add5a47 100644 --- a/module/PyFile.py +++ b/module/PyFile.py @@ -121,9 +121,8 @@ class PyFile(): self.sync() if hasattr(self, "plugin"): + self.plugin.clean() del self.plugin - if hasattr(self, "download"): - del self.download self.m.releaseLink(self.id) diff --git a/module/network/Browser.py b/module/network/Browser.py index 19b6aca66..3a8cd94a0 100644 --- a/module/network/Browser.py +++ b/module/network/Browser.py @@ -22,7 +22,10 @@ class Browser(object): self.http = HTTPRequest(self.cj, interface, proxies) self.dl = None + # tunnel some attributes from HTTP Request to Browser lastEffectiveURL = property(lambda self: self.http.lastEffectiveURL) + lastURL = property(lambda self: self.http.lastURL) + code = property(lambda self: self.http.code) def setCookieJar(self, cj): self.cj = cj @@ -56,9 +59,10 @@ class Browser(object): def clearCookies(self): if self.cj: self.cj.clear() + self.http.clearCookies() def clearReferer(self): - self.lastURL = None + self.http.lastURL = None def abortDownloads(self): self.http.abort = True @@ -66,6 +70,7 @@ class Browser(object): self.dl.abort = True def httpDownload(self, url, filename, get={}, post={}, ref=True, cookies=True, chunks=1, resume=False): + """ this can also download ftp """ self.dl = HTTPDownload(url, filename, get, post, self.lastEffectiveURL if ref else None, self.cj if cookies else None, self.bucket, self.interface, self.proxies) @@ -85,7 +90,7 @@ class Browser(object): """ retrieves page """ return self.http.load(url, get, post, ref, cookies, just_header) - def clean(self): + def close(self): """ cleanup """ if hasattr(self, "http"): self.http.close() diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py index 5ee33608b..c1ca77e2c 100644 --- a/module/network/HTTPDownload.py +++ b/module/network/HTTPDownload.py @@ -98,7 +98,7 @@ class HTTPDownload(): break fo.write(data) fi.close() - if fo.tell() < self.info.getChunkName(i)[2]: + if fo.tell() < self.info.getChunkRange(i)[1]: raise Exception("Downloaded content was smaller than expected") remove(fname) #remove chunk fo.close() diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index b4bb0857a..e107831cd 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -50,6 +50,9 @@ class HTTPRequest(): self.initHandle() self.setInterface(interface, proxies) + self.c.setopt(pycurl.WRITEFUNCTION, self.write) + self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader) + def initHandle(self): """ sets common options to curl handle """ @@ -93,15 +96,20 @@ class HTTPRequest(): self.c.setopt(pycurl.PROXYUSERPWD, "%s:%s" % (proxy["username"], proxy["password"])) def addCookies(self): + """ put cookies from curl handle to cj """ if self.cj: self.cj.addCookies(self.c.getinfo(pycurl.INFO_COOKIELIST)) def getCookies(self): + """ add cookies from cj to curl handle """ if self.cj: for c in self.cj.getCookies(): self.c.setopt(pycurl.COOKIELIST, c) return + def clearCookies(self): + self.c.setopt(pycurl.COOKIELIST, "") + def setRequestContext(self, url, get, post, referer, cookies): """ sets everything needed for the request """ @@ -133,8 +141,7 @@ class HTTPRequest(): self.setRequestContext(url, get, post, referer, cookies) self.header = "" - self.c.setopt(pycurl.WRITEFUNCTION, self.write) - self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader) + #@TODO raw_cookies and some things in old backend, which are apperently not needed if just_header: @@ -184,10 +191,11 @@ class HTTPRequest(): def close(self): """ cleanup, unusable after this """ - self.c.close() self.rep.close() if hasattr(self, "cj"): del self.cj + if hasattr(self, "c"): + del self.c if __name__ == "__main__": diff --git a/module/plugins/Plugin.py b/module/plugins/Plugin.py index a7ee72fd2..8a26996d0 100644 --- a/module/plugins/Plugin.py +++ b/module/plugins/Plugin.py @@ -121,12 +121,6 @@ class Plugin(object): def __call__(self): return self.__name__ - def __del__(self): - if hasattr(self, "pyfile"): - del self.pyfile - if hasattr(self, "req"): - del self.req - def setup(self): """ more init stuff if needed """ pass @@ -387,3 +381,11 @@ class Plugin(object): remove(self.lastDownload) self.lastCheck = m return name + + def clean(self): + """ clean everything and remove references """ + if hasattr(self, "pyfile"): + del self.pyfile + if hasattr(self, "req"): + self.req.close() + del self.req
\ No newline at end of file diff --git a/module/plugins/hoster/MegauploadCom.py b/module/plugins/hoster/MegauploadCom.py index 23ddbadb0..e67237af2 100644 --- a/module/plugins/hoster/MegauploadCom.py +++ b/module/plugins/hoster/MegauploadCom.py @@ -59,9 +59,10 @@ class MegauploadCom(Hoster): if self.account: self.premium = self.account.getAccountInfo(self.user)["premium"] - if self.premium: - self.multiDL = True - self.req.canContinue = True + if not self.premium: + self.multiDL = False + self.resumeDownload = False + self.chunkLimit = 1 else: self.multiDL = False self.api = {} |