From b0d9967fdafa38fdf7875a4b8f43d10e97c6f4f7 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 16 Nov 2009 17:43:33 +0100 Subject: added lastEffectiveURL --- module/network/Request.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'module') diff --git a/module/network/Request.py b/module/network/Request.py index eb67da95d..9f27af4ec 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -47,6 +47,7 @@ class Request: self.abort = False + self.lastEffectiveURL = None self.lastURL = None self.auth = False @@ -138,6 +139,7 @@ class Request: self.pycurl.perform() + self.lastEffectiveURL = self.pycurl.getinfo(pycurl.EFFECTIVE_URL) self.lastURL = url header = self.get_header() @@ -165,6 +167,7 @@ class Request: if rep.headers["content-encoding"] == "gzip": output = GzipFile('', 'r', 0, StringIO(output)).read() + self.lastEffectiveURL = rep.geturl() self.lastURL = url return output -- cgit v1.2.3 From 032bb8d837dc91742746ba39d6e9cb8e1323f22b Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 16 Nov 2009 18:22:29 +0100 Subject: relink.us fix --- module/plugins/RelinkUs.py | 50 +++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'module') diff --git a/module/plugins/RelinkUs.py b/module/plugins/RelinkUs.py index 4bfa5a18b..840497413 100644 --- a/module/plugins/RelinkUs.py +++ b/module/plugins/RelinkUs.py @@ -2,8 +2,9 @@ # -*- coding: utf-8 -*- import re +import time -from module.Plugin import Plugin +from Plugin import Plugin class RelinkUs(Plugin): @@ -12,14 +13,15 @@ class RelinkUs(Plugin): props = {} props['name'] = "RelinkUs" props['type'] = "container" - props['pattern'] = r"http://(www\.)?relink.us/go.php" - props['version'] = "0.1" + props['pattern'] = r"http://(www\.)?relink.us/(f|((view|go).php))" + props['version'] = "0.2" props['description'] = """Relink.us Container Plugin""" - props['author_name'] = ("spoob") - props['author_mail'] = ("spoob@pyload.org") + props['author_name'] = ("Sleeper-") + props['author_mail'] = ("@nonymous") self.props = props self.parent = parent self.html = None + self.multi_dl = False def file_exists(self): """ returns True or False @@ -27,13 +29,33 @@ class RelinkUs(Plugin): return True def proceed(self, url, location): - url = self.parent.url - self.html = self.req.load(url) - container_id = url.split("id=")[-1] + container_id = self.parent.url.split("/")[-1].split("id=")[-1] + url = "http://relink.us/view.php?id="+container_id + self.html = self.req.load(url, cookies=True) temp_links = [] - link_number = len(re.findall(r"test_\d+", self.html)) - for number in range(0, link_number): - new_link = re.search("src='(.*)'>", self.req.load("http://relink.us/f/%s/1/%i" % (container_id, number))).group(1) - temp_links.append(new_link) - print temp_links - self.links = temp_links + + # Download Ad-Frames, otherwise we aren't enabled for download + iframes = re.findall("src=['\"]([^'\"]*)['\"](.*)>", self.html) + for iframe in iframes: + self.req.load("http://relink.us/"+iframe[0], cookies=True) + + link_strings = re.findall(r"onclick=\"getFile\(\'([^)]*)\'\);changeBackgroundColor", self.html) + + for link_string in link_strings: + self.req.lastURL = url + + # Set Download File + framereq = self.req.load("http://relink.us/frame.php?"+link_string, cookies=True) + + new_link = self.req.lastEffectiveURL + + if re.match(r"http://(www\.)?relink.us/",new_link): + # Find iframe + new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) + # Wait some secs for relink.us server... + time.sleep(5) + + print new_link + temp_links.append(new_link) + + self.links = temp_links -- cgit v1.2.3 From a49bae7ba97ae64f61f38c4e64b671a650203910 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 16 Nov 2009 18:32:37 +0100 Subject: indentation fix --- module/plugins/RelinkUs.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'module') diff --git a/module/plugins/RelinkUs.py b/module/plugins/RelinkUs.py index 840497413..9ca209be3 100644 --- a/module/plugins/RelinkUs.py +++ b/module/plugins/RelinkUs.py @@ -34,28 +34,28 @@ class RelinkUs(Plugin): self.html = self.req.load(url, cookies=True) temp_links = [] - # Download Ad-Frames, otherwise we aren't enabled for download - iframes = re.findall("src=['\"]([^'\"]*)['\"](.*)>", self.html) - for iframe in iframes: - self.req.load("http://relink.us/"+iframe[0], cookies=True) + # Download Ad-Frames, otherwise we aren't enabled for download + iframes = re.findall("src=['\"]([^'\"]*)['\"](.*)>", self.html) + for iframe in iframes: + self.req.load("http://relink.us/"+iframe[0], cookies=True) - link_strings = re.findall(r"onclick=\"getFile\(\'([^)]*)\'\);changeBackgroundColor", self.html) + link_strings = re.findall(r"onclick=\"getFile\(\'([^)]*)\'\);changeBackgroundColor", self.html) - for link_string in link_strings: - self.req.lastURL = url + for link_string in link_strings: + self.req.lastURL = url - # Set Download File - framereq = self.req.load("http://relink.us/frame.php?"+link_string, cookies=True) + # Set Download File + framereq = self.req.load("http://relink.us/frame.php?"+link_string, cookies=True) - new_link = self.req.lastEffectiveURL + new_link = self.req.lastEffectiveURL - if re.match(r"http://(www\.)?relink.us/",new_link): - # Find iframe - new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) - # Wait some secs for relink.us server... - time.sleep(5) + if re.match(r"http://(www\.)?relink.us/",new_link): + # Find iframe + new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) + # Wait some secs for relink.us server... + time.sleep(5) - print new_link - temp_links.append(new_link) + print new_link + temp_links.append(new_link) - self.links = temp_links + self.links = temp_links -- cgit v1.2.3 From 20a3ae56f5eea95a0f9641eabb273e0410fe2309 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 16 Nov 2009 18:38:16 +0100 Subject: indentation fix, 2nd try -.- --- module/plugins/RelinkUs.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'module') diff --git a/module/plugins/RelinkUs.py b/module/plugins/RelinkUs.py index 9ca209be3..1700beb2b 100644 --- a/module/plugins/RelinkUs.py +++ b/module/plugins/RelinkUs.py @@ -34,28 +34,28 @@ class RelinkUs(Plugin): self.html = self.req.load(url, cookies=True) temp_links = [] - # Download Ad-Frames, otherwise we aren't enabled for download - iframes = re.findall("src=['\"]([^'\"]*)['\"](.*)>", self.html) - for iframe in iframes: - self.req.load("http://relink.us/"+iframe[0], cookies=True) + # Download Ad-Frames, otherwise we aren't enabled for download + iframes = re.findall("src=['\"]([^'\"]*)['\"](.*)>", self.html) + for iframe in iframes: + self.req.load("http://relink.us/"+iframe[0], cookies=True) - link_strings = re.findall(r"onclick=\"getFile\(\'([^)]*)\'\);changeBackgroundColor", self.html) + link_strings = re.findall(r"onclick=\"getFile\(\'([^)]*)\'\);changeBackgroundColor", self.html) - for link_string in link_strings: - self.req.lastURL = url + for link_string in link_strings: + self.req.lastURL = url - # Set Download File - framereq = self.req.load("http://relink.us/frame.php?"+link_string, cookies=True) + # Set Download File + framereq = self.req.load("http://relink.us/frame.php?"+link_string, cookies=True) - new_link = self.req.lastEffectiveURL + new_link = self.req.lastEffectiveURL - if re.match(r"http://(www\.)?relink.us/",new_link): - # Find iframe - new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) - # Wait some secs for relink.us server... - time.sleep(5) + if re.match(r"http://(www\.)?relink.us/",new_link): + # Find iframe + new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) + # Wait some secs for relink.us server... + time.sleep(5) - print new_link - temp_links.append(new_link) + print new_link + temp_links.append(new_link) - self.links = temp_links + self.links = temp_links -- cgit v1.2.3 From 80b31ff0d1f1b4eaf4f3ded0347114b0d0390dc3 Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 16 Nov 2009 18:40:28 +0100 Subject: indentation fix, 3nd try.. --- module/plugins/RelinkUs.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module') diff --git a/module/plugins/RelinkUs.py b/module/plugins/RelinkUs.py index 1700beb2b..786733558 100644 --- a/module/plugins/RelinkUs.py +++ b/module/plugins/RelinkUs.py @@ -50,10 +50,10 @@ class RelinkUs(Plugin): new_link = self.req.lastEffectiveURL if re.match(r"http://(www\.)?relink.us/",new_link): - # Find iframe - new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) - # Wait some secs for relink.us server... - time.sleep(5) + # Find iframe + new_link = re.search("src=['\"]([^'\"]*)['\"](.*)>", framereq).group(1) + # Wait some secs for relink.us server... + time.sleep(5) print new_link temp_links.append(new_link) -- cgit v1.2.3 From ed688632fb44f6c71e8053722895502cc4315494 Mon Sep 17 00:00:00 2001 From: spoob Date: Mon, 16 Nov 2009 18:56:44 +0100 Subject: Fixed DLC Plugin for new Plugin System --- module/plugins/DLC.pyc | Bin 3692 -> 2228 bytes module/plugins/UploadedTo.py | 3 +-- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'module') diff --git a/module/plugins/DLC.pyc b/module/plugins/DLC.pyc index 5d4809178..3adddec00 100644 Binary files a/module/plugins/DLC.pyc and b/module/plugins/DLC.pyc differ diff --git a/module/plugins/UploadedTo.py b/module/plugins/UploadedTo.py index bcb0a7008..4bddbd6f1 100644 --- a/module/plugins/UploadedTo.py +++ b/module/plugins/UploadedTo.py @@ -69,8 +69,7 @@ class UploadedTo(Plugin): tries += 1 if tries > 5: - raise Exception, "Error while preparing DL, HTML dump: %s" % self.html - + raise Exception, "Error while preparing DL" return True def download_api_data(self): -- cgit v1.2.3 From f22b9cebe1f800127658f94b9e4c9b9b2481c59e Mon Sep 17 00:00:00 2001 From: spoob Date: Mon, 16 Nov 2009 20:28:33 +0100 Subject: Fixed DLC Plugin --- module/plugins/DLC.pyc | Bin 2228 -> 2231 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'module') diff --git a/module/plugins/DLC.pyc b/module/plugins/DLC.pyc index 3adddec00..980dd8ace 100644 Binary files a/module/plugins/DLC.pyc and b/module/plugins/DLC.pyc differ -- cgit v1.2.3 From d862585e35c87498023882f02fc9e4b014becf2a Mon Sep 17 00:00:00 2001 From: sitacuisses Date: Wed, 18 Nov 2009 00:47:28 +0100 Subject: user: sitacuisses branch 'default' added module/plugins/FilesmonsterCom.py --- module/plugins/FilesmonsterCom.py | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 module/plugins/FilesmonsterCom.py (limited to 'module') diff --git a/module/plugins/FilesmonsterCom.py b/module/plugins/FilesmonsterCom.py new file mode 100644 index 000000000..27c687363 --- /dev/null +++ b/module/plugins/FilesmonsterCom.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Plugin for www.filesmonster.com +# this plugin isn't fully implemented yet,but it does download +# todo: +# detect, if reconnect is necessary +# download-error handling +# postpone download, if speed is below a set limit +# implement premium-access +# optional replace blanks in filename with underscores + +import re +import urllib +import time +from Plugin import Plugin + +class FilesmonsterCom(Plugin): + + def __init__(self, parent): + Plugin.__init__(self, parent) + props = {} + props['name'] = "FilesmonsterCom" + props['type'] = "hoster" + props['pattern'] = r"http://(www.)??filesmonster.com/download.php" + props['version'] = "0.1" + props['description'] = """Filesmonster.com Download Plugin""" + props['author_name'] = ("sitacuisses","spoob") + props['author_mail'] = ("sitacuisses@yahoo.de","spoob@pyload.org") + self.props = props + self.parent = parent + self.html = None + self.want_reconnect = False + self.multi_dl = False + self.htmlwithlink = None + self.url = None + self.filerequest = None + + def download_html(self): + self.url = self.parent.url + self.html = self.req.load(self.url) # get the start page + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + if not self.want_reconnect: + self.get_download_page() # the complex work is done here + file_url = self.htmlwithlink + return file_url + else: + return False + + def get_file_name(self): + if self.html == None: + self.download_html() + if not self.want_reconnect: + file_name = re.search(r"File\sname:\s(.*?)", self.html).group(1) + return file_name + else: + return self.parent.url + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + if re.search(r"Such file does not exist or it has been removed for infringement of copyrights.", self.html) != None: + return False + else: + return True + + def get_download_page(self): + herewego = re.findall(r"\s*\n\s*", self.html) + the_download_page = self.req.load("http://filesmonster.com/get/free/", None, herewego) + temporary_filtered = re.search(r"\s*\n(\s*\s*\n)*?\s*", the_download_page).group(0) + all_the_tuples = re.findall(r" Date: Sun, 29 Nov 2009 20:59:53 +0100 Subject: First Version, works but doesn't reconnect branch 'default' added module/plugins/FreakshareNet.py --- module/plugins/FreakshareNet.py | 144 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 module/plugins/FreakshareNet.py (limited to 'module') diff --git a/module/plugins/FreakshareNet.py b/module/plugins/FreakshareNet.py new file mode 100644 index 000000000..0768b5476 --- /dev/null +++ b/module/plugins/FreakshareNet.py @@ -0,0 +1,144 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +import urllib +import httplib +from module.Plugin import Plugin +from time import time + + +class FreakshareNet(Plugin): + + def __init__(self, parent): + Plugin.__init__(self, parent) + props = {} + props['name'] = "FreakshareNet" + props['type'] = "hoster" + props['pattern'] = r"http://(?:www\.)?freakshare\.net/files/\S*?/" + props['version'] = "0.1" + props['description'] = """Freakshare.com Download Plugin""" + props['author_name'] = ("sitacuisses","spoob","mkaay") + props['author_mail'] = ("sitacuisses@yahoo.de","spoob@pyload.org","mkaay@mkaay.de") + self.props = props + self.parent = parent + self.html = None + self.want_reconnect = False + self.multi_dl = False + self.req_opts = list() + + def prepare(self, thread): + pyfile = self.parent + + self.want_reconnect = False + + self.download_html() + + pyfile.status.exists = self.file_exists() + + if not pyfile.status.exists: + raise Exception, "The file was not found on the server." + return False + + self.get_waiting_time() + + pyfile.status.filename = self.get_file_name() + + pyfile.status.waituntil = self.time_plus_wait + thread.wait(self.parent) + pyfile.status.url = self.get_file_url() + pyfile.status.want_reconnect = self.want_reconnect + + return True + + def download_html(self): + url = self.parent.url + self.html = self.req.load(url, cookies=True) + + def get_file_url(self): + """ returns the absolute downloadable filepath + """ + if self.html == None: + self.download_html() + if not self.want_reconnect: + self.req_opts = self.get_download_options() # get the Post options for the Request + file_url = self.parent.url + return file_url + else: + return False + + def get_file_name(self): + if self.html == None: + self.download_html() + if not self.want_reconnect: + file_name = re.search(r"(.*?)<\/h1>", self.html).group(1) + return file_name + else: + return self.parent.url + + def get_waiting_time(self): + if self.html == None: + self.download_html() + timestring = re.search('\s*var\stime\s=\s(\d*?)\.\d*;', self.html).group(1) + if timestring: + sec = int(timestring) + 1 #add 1 sec as tenths of seconds are cut off + else: + sec = 0 + self.time_plus_wait = time() + sec + + def file_exists(self): + """ returns True or False + """ + if self.html == None: + self.download_html() + if re.search(r"Sorry, this Download doesnt exist anymore", self.html) != None: + return False + else: + return True + + def get_download_options(self): + re_envelope = re.search(r".*?value=\"Free\sDownload\".*?\n*?(.*?<.*?>\n*)*?\n*\s*?", self.html).group(0) #get the whole request + to_sort = re.findall(r"", re_envelope) + request_options = list() + for item in to_sort: #Name value pairs are output reversed from regex, so we reorder them + request_options.append((item[1], item[0])) + herewego = self.req.load(self.parent.url, None, request_options, cookies=True) # the actual download-Page + to_sort = None + to_sort = re.findall(r"", herewego) + request_options = list() + for item in to_sort: #Same as above + request_options.append((item[1], item[0])) + return request_options + + def proceed(self, url, location): + """ + request.download doesn't handle the 302 redirect correctly + that's why the data are posted "manually" via httplib + and the redirect-url is read from the header. + Important: The cookies may not be posted to the download-url + otherwise the downloaded file only contains "bad try" + Need to come up with a better idea to handle the redirect, + help is appreciated. + """ + temp_options = urllib.urlencode(self.req_opts) + temp_url = re.match(r"http://(.*?)/.*", url).group(1) # get the server name + temp_extended = re.match(r"http://.*?(/.*)", url).group(1) # get the url relative to serverroot + cookie_list = "" + for temp_cookie in self.req.cookies: #prepare cookies + cookie_list += temp_cookie.name + "=" + temp_cookie.value +";" + temp_headers = [ #create the additional header fields + ["Content-type", "application/x-www-form-urlencoded"], #this is very important + ["User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.10"], + ["Accept-Encoding", "deflate"], + ["Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"], + ["Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"], + ["Connection", "keep-alive"], + ["Keep-Alive", "300"], + ["Referer", self.req.lastURL], + ["Cookie", cookie_list]] + temp_conn = httplib.HTTPConnection(temp_url) + temp_conn.request("POST", temp_extended, temp_options, dict(temp_headers)) + temp_response = temp_conn.getresponse() + new_url = temp_response.getheader("Location") # we need the Location-header + temp_conn.close + self.req.download(new_url, location, None, None, cookies=False) -- cgit v1.2.3 From 5d04894e73a52e69968cb4a4bfd9a581cd2fb86c Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 1 Feb 2010 18:54:19 +0100 Subject: new update system for remote clients --- module/download_thread.py | 4 + module/file_list.py | 24 ++++- module/gui/Collector.py | 230 +++++++++++++++++++++------------------------- module/gui/Queue.py | 132 +++++++++++++++++--------- module/gui/connector.py | 19 +++- 5 files changed, 240 insertions(+), 169 deletions(-) (limited to 'module') diff --git a/module/download_thread.py b/module/download_thread.py index 4a031a04c..65c7e1e23 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -23,6 +23,7 @@ from os.path import join from time import sleep, time from module.network.Request import AbortDownload +from module.PullEvents import UpdateEvent class Status(object): """ Saves all status information @@ -116,6 +117,7 @@ class Download_Thread(threading.Thread): self.loadedPyFile.status.error = str(e) finally: self.parent.job_finished(self.loadedPyFile) + self.parent.parent.pullManager.addEvent(UpdateEvent("file", self.loadedPyFile.id, "queue")) else: sleep(3) sleep(0.8) @@ -126,6 +128,7 @@ class Download_Thread(threading.Thread): def download(self, pyfile): status = pyfile.status status.type = "starting" + self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue")) pyfile.init_download() @@ -136,6 +139,7 @@ class Download_Thread(threading.Thread): status.type = "decrypting" else: status.type = "downloading" + self.parent.parent.pullManager.addEvent(UpdateEvent("file", pyfile.id, "queue")) location = join(pyfile.folder, status.filename) pyfile.plugin.proceed(status.url, location) diff --git a/module/file_list.py b/module/file_list.py index 7c68a7427..b9f70bd27 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -33,6 +33,8 @@ from operator import attrgetter from os import sep from time import sleep +from module.PullEvents import UpdateEvent, RemoveEvent, InsertEvent + class NoSuchElementException(Exception): pass @@ -148,6 +150,10 @@ class File_List(object): info["size"] = pyfile.status.size() info["active"] = pyfile.active info["plugin"] = pyfile.plugin.props['name'] + try: + info["package"] = pypack.data["id"] + except: + pass return info def continueAborted(self): @@ -194,6 +200,7 @@ class File_List(object): try: n, pyfile = collector._getFileFromID(id) del collector.file_list.data["collector"][n] + collector.file_list.core.pullManager.addEvent(RemoveEvent("file", id, "collector")) except Exception, e: raise Exception, e else: @@ -211,6 +218,7 @@ class File_List(object): collector.file_list.lock.acquire() collector.file_list.data["collector"].append(pyfile) collector.file_list.lock.release() + collector.file_list.core.pullManager.addEvent(InsertEvent("file", pyfile.id, -2, "collector")) return pyfile.id def removeFile(collector, id): @@ -218,6 +226,7 @@ class File_List(object): removes PyLoadFile instance with the given id from collector """ collector.popFile(id) + collector.file_list.core.pullManager.addEvent(RemoveEvent("file", id, "collector")) def replaceFile(collector, newpyfile): """ @@ -227,6 +236,7 @@ class File_List(object): try: n, pyfile = collector._getFileFromID(newpyfile.id) collector.file_list.data["collector"][n] = newpyfile + collector.file_list.core.pullManager.addEvent(UpdateEvent("file", newpyfile.id, "collector")) finally: collector.file_list.lock.release() @@ -277,6 +287,7 @@ class File_List(object): if package_name is not None: pypack.data["package_name"] = package_name packager.file_list.data["packages"].append(pypack) + packager.file_list.core.pullManager.addEvent(InsertEvent("pack", pypack.data["id"], -2, "packages")) return pypack.data["id"] def removePackage(packager, id): @@ -287,6 +298,9 @@ class File_List(object): pyfile.plugin.req.abort = True sleep(0.1) del packager.file_list.data[key][n] + if key == "packages": + key = "collector" + packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, key)) finally: packager.file_list.lock.release() @@ -312,6 +326,8 @@ class File_List(object): if key == "packages": del packager.file_list.data["packages"][n] packager.file_list.data["queue"].append(pypack) + packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, "packages")) + packager.file_list.core.pullManager.addEvent(InsertEvent("pack", id, -2, "queue")) finally: packager.file_list.lock.release() @@ -322,6 +338,8 @@ class File_List(object): if key == "queue": del packager.file_list.data["queue"][n] packager.file_list.data["packages"].append(pypack) + packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, "queue")) + packager.file_list.core.pullManager.addEvent(InsertEvent("pack", id, -2, "packages")) finally: packager.file_list.lock.release() @@ -334,6 +352,7 @@ class File_List(object): if folder is not None: pypack.data["folder"] = folder packager.file_list.data[key][n] = pypack + packager.file_list.core.pullManager.addEvent(UpdateEvent("pack", id, key)) finally: packager.file_list.lock.release() @@ -352,6 +371,7 @@ class File_List(object): pyfile.package = pypack pypack.files.append(pyfile) packager.file_list.data[key][n] = pypack + packager.file_list.core.pullManager.addEvent(InsertEvent("file", pyfile.id, -2, key)) def resetFileStatus(packager, fileid): packager.file_list.lock.acquire() @@ -359,6 +379,7 @@ class File_List(object): key, n, pyfile, pypack, pid = packager._getFileFromID(fileid) pyfile.init() pyfile.status.type = None + packager.file_list.core.pullManager.addEvent(UpdateEvent("file", fileid, key)) finally: packager.file_list.lock.release() @@ -367,15 +388,16 @@ class File_List(object): try: key, n, pyfile, pypack, pid = packager._getFileFromID(fileid) pyfile.plugin.req.abort = True + packager.file_list.core.pullManager.addEvent(UpdateEvent("file", fileid, key)) finally: packager.file_list.lock.release() - #oooops, duplicate? def removeFileFromPackage(packager, id, pid): key, n, pypack = packager._getPackageFromID(pid) for k, pyfile in enumerate(pypack.files): if id == pyfile.id: del pypack.files[k] + packager.file_list.core.pullManager.addEvent(RemoveEvent("file", pyfile.id, key)) if not pypack.files: packager.removePackage(pid) return True diff --git a/module/gui/Collector.py b/module/gui/Collector.py index 0aad5d1ba..c0754aa42 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -27,7 +27,6 @@ class PackageCollector(QObject): self.view = view self.connector = connector self.collector = [] - self.interval = 2 self.rootItem = self.view.invisibleRootItem() self.mutex = QMutex() item = self.PackageCollectorPack(self) @@ -36,48 +35,80 @@ class PackageCollector(QObject): item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) self.rootItem.addChild(item) self.linkCollector = item - self.pauseIDs = [] - self.updater = self.CollectorUpdater(self.interval) - self.connect(self.updater, SIGNAL("update()"), self.update) - class CollectorUpdater(QThread): - def __init__(self, interval): - QThread.__init__(self) - self.interval = interval - self.running = True - - def run(self): - while self.running: - self.emit(SIGNAL("update()")) - self.sleep(self.interval) - - def start(self): - self.updater.start() - - def wait(self): - self.updater.wait() - - def stop(self): - self.updater.running = False - - def update(self): + def fullReload(self): locker = QMutexLocker(self.mutex) + self.clearAll() packs = self.connector.getPackageCollector() - ids = [] - for data in packs: - ids.append(data["id"]) - self.clear(ids) for data in packs: - if data["id"] in self.pauseIDs: - continue - ids.append(data["id"]) - pack = self.getPack(data["id"]) - if not pack: - pack = self.PackageCollectorPack(self) + pack = self.PackageCollectorPack(self) pack.setPackData(data) + files = self.connector.getPackageFiles(data["id"]) + for fid in files: + info = self.connector.getLinkInfo(fid) + child = self.PackageCollectorFile(self, pack) + child.setFileData(info) + pack.addPackChild(fid, child) self.addPack(data["id"], pack) + + def addEvent(self, event): + if event[0] == "reload": + self.fullReload() + elif event[0] == "remove": + self.removeEvent(event) + elif event[0] == "insert": + self.insertEvent(event) + elif event[0] == "update": + self.updateEvent(event) + + def removeEvent(self, event): + if event[2] == "file": + for pack in ItemIterator(self.rootItem): + for k, child in enumerate(pack.getChildren()): + if child.getFileData()["id"] == event[3]: + pack.takeChild(k) + break + else: + for k, pack in enumerate(ItemIterator(self.rootItem)): + if pack.getPackData()["id"] == event[3]: + self.rootItem.takeChild(k) + break + + def insertEvent(self, event): + if event[2] == "file": + info = self.connector.getLinkInfo(event[3]) + for pack in ItemIterator(self.rootItem): + if pack.getPackData()["id"] == info["package"]: + child = self.PackageCollectorFile(self, pack) + child.setFileData(info) + pack.addPackChild(info["id"], child) + break + else: + data = self.connector.getPackageInfo(event[3]) + pack = self.PackageCollectorPack(self) + pack.setPackData(data) + self.addPack(data["id"], pack) + files = self.connector.getPackageFiles(data["id"]) + for fid in files: + info = self.connector.getLinkInfo(fid) + child = self.PackageCollectorFile(self, pack) + child.setFileData(info) + pack.addPackChild(fid, child) + self.addPack(data["id"], pack) + + def updateEvent(self, event): + if event[2] == "file": + info = self.connector.getLinkInfo(event[3]) + for pack in ItemIterator(self.rootItem): + if pack.getPackData()["id"] == info["package"]: + child = pack.getChild(event[3]) + child.setFileData(info) + pack.addPackChild(info["id"], child) + else: + data = self.connector.getPackageInfo(event[3]) + pack = self.getPack(event[3]) + pack.setPackData(data) files = self.connector.getPackageFiles(data["id"]) - pack.clear(files) for fid in files: info = self.connector.getLinkInfo(fid) child = pack.getChild(fid) @@ -85,6 +116,7 @@ class PackageCollector(QObject): child = self.PackageCollectorFile(self, pack) child.setFileData(info) pack.addPackChild(fid, child) + self.addPack(data["id"], pack) def addPack(self, pid, newPack): pos = None @@ -110,38 +142,10 @@ class PackageCollector(QObject): return pack return None - def clear(self, ids): - clear = False - remove = [] + def clearAll(self): for k, pack in enumerate(ItemIterator(self.rootItem)): - if not pack.getPackData()["id"] in ids and not pack.getPackData()["id"] == "fixed": - clear = True - remove.append(k) - if not clear: - return - remove.sort() - remove.reverse() - for k in remove: - self.rootItem.takeChild(k) - for pack in ItemIterator(self.rootItem): - if pack.getPackData()["id"] == "fixed": - return - item = self.PackageCollectorPack(self) - item.setPackData({"id":"fixed"}) - item.setData(0, Qt.DisplayRole, QVariant("Single Links")) - item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) - self.rootItem.addChild(item) - self.linkCollector = item - - def pauseItemUpdate(self, pid, pause=True): - locker = QMutexLocker(self.mutex) - if pause and not pid in self.pauseIDs: - self.pauseIDs.append(int(pid)) - else: - try: - self.pauseIDs.remove(int(pid)) - except: - pass + if not pack.getPackData()["id"] == "fixed": + self.rootItem.takeChild(k) class PackageCollectorPack(QTreeWidgetItem): def __init__(self, collector): @@ -184,25 +188,6 @@ class PackageCollector(QObject): if item.getFileData()["id"] == cid: return item return None - - def clear(self, ids): - clear = False - remove = [] - children = [] - for k, file in enumerate(self.getChildren()): - if not file.getFileData()["id"] in ids: - remove.append(file.getFileData()["id"]) - if file.getFileData()["id"] in children and not file.getFileData()["id"] in remove: - remove.append(file.getFileData()["id"]) - continue - children.append(file.getFileData()["id"]) - if not remove: - return - remove.sort() - remove.reverse() - parent = self - for k in remove: - parent.takeChild(k) class PackageCollectorFile(QTreeWidgetItem): def __init__(self, collector, pack): @@ -226,44 +211,50 @@ class LinkCollector(QObject): QObject.__init__(self) self.view = view self.connector = connector - self.interval = 2 self.rootItem = root self.mutex = QMutex() - self.updater = self.CollectorUpdater(self.interval) - self.connect(self.updater, SIGNAL("update()"), self.update) - class CollectorUpdater(QThread): - def __init__(self, interval): - QThread.__init__(self) - self.interval = interval - self.running = True - - def run(self): - while self.running: - self.emit(SIGNAL("update()")) - self.sleep(self.interval) - - def start(self): - self.updater.start() - - def wait(self): - self.updater.wait() - - def stop(self): - self.updater.running = False - - def update(self): + def fullReload(self): locker = QMutexLocker(self.mutex) + self.clearAll() ids = self.connector.getLinkCollector() - self.clear(ids) for fid in ids: data = self.connector.getLinkInfo(fid) - file = self.getFile(fid) - if not file: - file = self.LinkCollectorFile(self) + file = self.LinkCollectorFile(self) file.setFileData(data) self.addFile(fid, file) + def addEvent(self, event): + if event[0] == "reload": + self.fullReload() + elif event[0] == "remove": + self.removeEvent(event) + elif event[0] == "insert": + self.insertEvent(event) + elif event[0] == "update": + self.updateEvent(event) + + def removeEvent(self, event): + if event[2] == "file": + for k, file in enumerate(ItemIterator(self.rootItem)): + if file.getFileData()["id"] == event[3]: + self.rootItem.takeChild(k) + break + + def insertEvent(self, event): + if event[2] == "file": + data = self.connector.getLinkInfo(event[3]) + file = self.LinkCollectorFile(self) + file.setFileData(data) + self.addFile(event[3], file) + + def updateEvent(self, event): + if event[2] == "file": + data = self.connector.getLinkInfo(event[3]) + file = getFile(event[3]) + file.setFileData(data) + self.addFile(event[3], file) + def addFile(self, pid, newFile): pos = None try: @@ -289,16 +280,9 @@ class LinkCollector(QObject): return file return None - def clear(self, ids): - clear = False - for file in ItemIterator(self.rootItem): - if not file.getFileData()["id"] in ids: - clear = True - break - if not clear: - return + def clearAll(self): self.rootItem.takeChildren() - + class LinkCollectorFile(QTreeWidgetItem): def __init__(self, collector): QTreeWidgetItem.__init__(self) diff --git a/module/gui/Queue.py b/module/gui/Queue.py index 8681d3bb1..9659137ec 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -77,28 +77,101 @@ class Queue(QObject): del d["name"] del d["status"] downloading[did] = d - ids = [] - for data in packs: - ids.append(data["id"]) - self.clear(ids) + for pack in ItemIterator(self.rootItem): + for child in pack.getChildren(): + info = child.getFileData() + try: + info["downloading"] = downloading[info["id"]] + except: + info["downloading"] = None + child.setFileData(info) + pack.addPackChild(info["id"], child) + self.addPack(pack.getPackData()["id"], pack) + + def fullReload(self): + locker = QMutexLocker(self.mutex) + self.clearAll() + packs = self.connector.getPackageQueue() for data in packs: - pack = self.getPack(data["id"]) - if not pack: - pack = self.QueuePack(self) + pack = self.QueuePack(self) pack.setPackData(data) files = self.connector.getPackageFiles(data["id"]) - pack.clear(files) + for fid in files: + info = self.connector.getLinkInfo(fid) + child = self.QueueFile(self, pack) + if not info["status_type"]: + info["status_type"] = "queued" + child.setFileData(info) + pack.addPackChild(fid, child) self.addPack(data["id"], pack) + + def addEvent(self, event): + if event[0] == "reload": + self.fullReload() + elif event[0] == "remove": + self.removeEvent(event) + elif event[0] == "insert": + self.insertEvent(event) + elif event[0] == "update": + self.updateEvent(event) + + def removeEvent(self, event): + if event[2] == "file": + for pack in ItemIterator(self.rootItem): + for k, child in enumerate(pack.getChildren()): + if child.getFileData()["id"] == event[3]: + pack.takeChild(k) + break + else: + for k, pack in enumerate(ItemIterator(self.rootItem)): + if pack.getPackData()["id"] == event[3]: + self.rootItem.takeChild(k) + break + + def insertEvent(self, event): + if event[2] == "file": + info = self.connector.getLinkInfo(event[3]) + for pack in ItemIterator(self.rootItem): + if pack.getPackData()["id"] == info["package"]: + child = self.QueueFile(self, pack) + child.setFileData(info) + pack.addPackChild(info["id"], child) + break + else: + data = self.connector.getPackageInfo(event[3]) + pack = self.QueuePack(self) + pack.setPackData(data) + self.addPack(data["id"], pack) + files = self.connector.getPackageFiles(data["id"]) + for fid in files: + info = self.connector.getLinkInfo(fid) + child = self.QueueFile(self, pack) + if not info["status_type"]: + info["status_type"] = "queued" + child.setFileData(info) + pack.addPackChild(fid, child) + self.addPack(data["id"], pack) + + def updateEvent(self, event): + if event[2] == "file": + info = self.connector.getLinkInfo(event[3]) + for pack in ItemIterator(self.rootItem): + if pack.getPackData()["id"] == info["package"]: + child = pack.getChild(event[3]) + if not info["status_type"]: + info["status_type"] = "queued" + child.setFileData(info) + pack.addPackChild(info["id"], child) + else: + data = self.connector.getPackageInfo(event[3]) + pack = self.getPack(event[3]) + pack.setPackData(data) + files = self.connector.getPackageFiles(data["id"]) for fid in files: info = self.connector.getLinkInfo(fid) child = pack.getChild(fid) if not child: child = self.QueueFile(self, pack) - info["downloading"] = None - try: - info["downloading"] = downloading[info["id"]] - except: - pass if not info["status_type"]: info["status_type"] = "queued" child.setFileData(info) @@ -145,19 +218,8 @@ class Queue(QObject): return pack return None - def clear(self, ids): - clear = False - remove = [] - for k, pack in enumerate(ItemIterator(self.rootItem)): - if not pack.getPackData()["id"] in ids: - clear = True - remove.append(k) - if not clear: - return - remove.sort() - remove.reverse() - for k in remove: - self.rootItem.takeChild(k) + def clearAll(self): + self.rootItem.takeChildren() def getWaitingProgress(self, q): locker = QMutexLocker(self.mutex) @@ -282,24 +344,6 @@ class Queue(QObject): if item.getFileData()["id"] == cid: return item return None - - def clear(self, ids): - clear = False - remove = [] - children = [] - for k, file in enumerate(self.getChildren()): - if not file.getFileData()["id"] in ids: - remove.append(file.getFileData()["id"]) - if file.getFileData()["id"] in children and not file.getFileData()["id"] in remove: - remove.append(file.getFileData()["id"]) - continue - children.append(file.getFileData()["id"]) - if not remove: - return - remove.sort() - remove.reverse() - for k in remove: - self.takeChild(k) class QueueFile(QTreeWidgetItem): def __init__(self, queue, pack): diff --git a/module/gui/connector.py b/module/gui/connector.py index 432999161..3146ecf5b 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -19,6 +19,7 @@ SERVER_VERSION = "0.3" from time import sleep +from uuid import uuid4 as uuid from PyQt4.QtCore import * from PyQt4.QtGui import * @@ -35,6 +36,7 @@ class connector(QThread): self.running = True self.proxy = None self.addr = None + self.connectionID = None self.errorQueue = [] self.connect(self, SIGNAL("proxy_error"), self._proxyError) @@ -72,6 +74,7 @@ class connector(QThread): self.proxy = ServerProxy(addr, allow_none=True) try: server_version = self.proxy.get_server_version() + self.connectionID = uuid().hex except: return False if not server_version == SERVER_VERSION: @@ -124,7 +127,9 @@ class connector(QThread): """ self.mutex.lock() try: - return self.proxy.get_file_info(id) + info = self.proxy.get_file_info(id) + info["downloading"] = None + return info except Exception, e: self.emit(SIGNAL("proxy_error"), "getLinkInfo", e) finally: @@ -421,4 +426,16 @@ class connector(QThread): self.emit(SIGNAL("proxy_error"), "setCaptchaResult", e) finally: self.mutex.unlock() + + def getEvents(self): + """ + get events + """ + self.mutex.lock() + try: + return self.proxy.get_events(self.connectionID) + except Exception, e: + self.emit(SIGNAL("proxy_error"), "getEvents", e) + finally: + self.mutex.unlock() -- cgit v1.2.3 From d27b972bffd0c38b3131dc46ff7a0f371508dffb Mon Sep 17 00:00:00 2001 From: mkaay Date: Mon, 1 Feb 2010 18:55:01 +0100 Subject: forgot file --- module/PullEvents.py | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 module/PullEvents.py (limited to 'module') diff --git a/module/PullEvents.py b/module/PullEvents.py new file mode 100644 index 000000000..7b23cf8b8 --- /dev/null +++ b/module/PullEvents.py @@ -0,0 +1,111 @@ +# -*- coding: utf-8 -*- + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: mkaay +""" + +from time import time + +class PullManager(): + def __init__(self, core): + self.core = core + self.clients = [] + + def newClient(self, uuid): + self.clients.append(Client(uuid)) + + def clean(self): + for n, client in enumerate(self.clients): + if client.lastActive + 30 < time(): + del self.clients[n] + + def getEvents(self, uuid): + events = [] + validUuid = False + for client in self.clients: + if client.uuid == uuid: + client.lastActive = time() + validUuid = True + while client.newEvents(): + events.append(client.popEvent().toList()) + break + if not validUuid: + self.newClient(uuid) + events = [ReloadAllEvent("queue").toList(), ReloadAllEvent("packages").toList(), ReloadAllEvent("collector").toList()] + return events + + def addEvent(self, event): + for client in self.clients: + client.addEvent(event) + +class Client(): + def __init__(self, uuid): + self.uuid = uuid + self.lastActive = time() + self.events = [] + + def newEvents(self): + return (len(self.events) > 0) + + def popEvent(self): + if not len(self.events): + return None + return self.events.pop(0) + + def addEvent(self, event): + self.events.append(event) + +class UpdateEvent(): + def __init__(self, itype, iid, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" or destination == "packages" + self.type = itype + self.id = iid + self.destination = destination + + def toList(self): + return ["update", self.destination, self.type, self.id] + +class RemoveEvent(): + def __init__(self, itype, iid, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" or destination == "packages" + self.type = itype + self.id = iid + self.destination = destination + + def toList(self): + return ["remove", self.destination, self.type, self.id] + +class InsertEvent(): + def __init__(self, itype, iid, after, destination): + assert itype == "pack" or itype == "file" + assert destination == "queue" or destination == "collector" or destination == "packages" + self.type = itype + self.id = iid + self.after = after + self.destination = destination + + def toList(self): + return ["insert", self.destination, self.type, self.id, self.after] + +class ReloadAllEvent(): + def __init__(self, destination): + assert destination == "queue" or destination == "collector" or destination == "packages" + self.destination = destination + + def toList(self): + return ["reload", self.destination] -- cgit v1.2.3 From dc97a68f74dc0966b1df9e8f8231d76ecd9f2673 Mon Sep 17 00:00:00 2001 From: mkaay Date: Tue, 2 Feb 2010 22:15:48 +0100 Subject: some gui fixes, i18n update --- module/download_thread.py | 50 +++++++++++++----------- module/file_list.py | 8 ++-- module/gui/Collector.py | 15 +++++--- module/gui/Queue.py | 11 ++++-- module/gui/connector.py | 3 +- module/plugins/decrypter/SerienjunkiesOrg.py | 1 + module/thread_list.py | 57 +++++++++++++++------------- 7 files changed, 81 insertions(+), 64 deletions(-) (limited to 'module') diff --git a/module/download_thread.py b/module/download_thread.py index 65c7e1e23..7c899b185 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -1,22 +1,26 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# -#Copyright (C) 2009 sp00b, sebnapi -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 3 of the License, -#or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#See the GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -### + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: mkaay + @author: spoob + @author: sebnapi + @version: v0.3 +""" + import threading import traceback from os.path import join @@ -108,9 +112,9 @@ class Download_Thread(threading.Thread): code, msg = e if code == 7: sleep(60) - self.parent.parent.logger.info("Hoster unvailable, wait 60 seconds") + self.parent.parent.logger.info(_("Hoster unvailable, wait 60 seconds")) except Exception, f: - self.parent.parent.logger.debug("Error getting error code: "+ str(f)) + self.parent.parent.logger.debug(_("Error getting error code: %s") % f) if self.parent.parent.config['general']['debug_mode']: traceback.print_exc() self.loadedPyFile.status.type = "failed" @@ -156,13 +160,13 @@ class Download_Thread(threading.Thread): 20 - unknown error """ if code == 0: - self.parent.parent.logger.info("Checksum ok ('%s')" % status.filename) + self.parent.parent.logger.info(_("Checksum ok ('%s')") % status.filename) elif code == 1: - self.parent.parent.logger.info("Checksum not matched! ('%s')" % status.filename) + self.parent.parent.logger.info(_("Checksum not matched! ('%s')") % status.filename) elif code == 5: - self.parent.parent.logger.debug("Can't get checksum for %s" % status.filename) + self.parent.parent.logger.debug(_("Can't get checksum for %s") % status.filename) elif code == 10: - self.parent.parent.logger.debug("Checksum not implemented for %s" % status.filename) + self.parent.parent.logger.debug(_("Checksum not implemented for %s") % status.filename) if not check: raise Checksum(code, location) diff --git a/module/file_list.py b/module/file_list.py index b9f70bd27..d251868b9 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -84,11 +84,11 @@ class File_List(object): self.lock.release() if len(self.data["collector"]) > 0: - self.core.logger.info("Found %s links in linkcollector" % len(self.data["collector"])) + self.core.logger.info(_("Found %s links in linkcollector") % len(self.data["collector"])) if len(self.data["packages"]) > 0: - self.core.logger.info("Found %s unqueued packages" % len(self.data["packages"])) + self.core.logger.info(_("Found %s unqueued packages") % len(self.data["packages"])) if len(self.data["queue"]) > 0: - self.core.logger.info("Added %s packages to queue" % len(self.data["queue"])) + self.core.logger.info(_("Added %s packages to queue") % len(self.data["queue"])) def save(self): self.lock.acquire() @@ -298,8 +298,6 @@ class File_List(object): pyfile.plugin.req.abort = True sleep(0.1) del packager.file_list.data[key][n] - if key == "packages": - key = "collector" packager.file_list.core.pullManager.addEvent(RemoveEvent("pack", id, key)) finally: packager.file_list.lock.release() diff --git a/module/gui/Collector.py b/module/gui/Collector.py index c0754aa42..ebdbd372d 100644 --- a/module/gui/Collector.py +++ b/module/gui/Collector.py @@ -66,12 +66,12 @@ class PackageCollector(QObject): for pack in ItemIterator(self.rootItem): for k, child in enumerate(pack.getChildren()): if child.getFileData()["id"] == event[3]: - pack.takeChild(k) + pack.removeChild(child) break else: for k, pack in enumerate(ItemIterator(self.rootItem)): if pack.getPackData()["id"] == event[3]: - self.rootItem.takeChild(k) + self.rootItem.removeChild(pack) break def insertEvent(self, event): @@ -99,6 +99,8 @@ class PackageCollector(QObject): def updateEvent(self, event): if event[2] == "file": info = self.connector.getLinkInfo(event[3]) + if not info: + return for pack in ItemIterator(self.rootItem): if pack.getPackData()["id"] == info["package"]: child = pack.getChild(event[3]) @@ -145,7 +147,7 @@ class PackageCollector(QObject): def clearAll(self): for k, pack in enumerate(ItemIterator(self.rootItem)): if not pack.getPackData()["id"] == "fixed": - self.rootItem.takeChild(k) + self.rootItem.removeChild(pack) class PackageCollectorPack(QTreeWidgetItem): def __init__(self, collector): @@ -238,7 +240,7 @@ class LinkCollector(QObject): if event[2] == "file": for k, file in enumerate(ItemIterator(self.rootItem)): if file.getFileData()["id"] == event[3]: - self.rootItem.takeChild(k) + self.rootItem.removeChild(file) break def insertEvent(self, event): @@ -251,6 +253,8 @@ class LinkCollector(QObject): def updateEvent(self, event): if event[2] == "file": data = self.connector.getLinkInfo(event[3]) + if not data: + return file = getFile(event[3]) file.setFileData(data) self.addFile(event[3], file) @@ -281,7 +285,8 @@ class LinkCollector(QObject): return None def clearAll(self): - self.rootItem.takeChildren() + for k, file in enumerate(ItemIterator(self.rootItem)): + self.rootItem.removeChild(file) class LinkCollectorFile(QTreeWidgetItem): def __init__(self, collector): diff --git a/module/gui/Queue.py b/module/gui/Queue.py index 9659137ec..bd45e27dc 100644 --- a/module/gui/Queue.py +++ b/module/gui/Queue.py @@ -89,7 +89,6 @@ class Queue(QObject): self.addPack(pack.getPackData()["id"], pack) def fullReload(self): - locker = QMutexLocker(self.mutex) self.clearAll() packs = self.connector.getPackageQueue() for data in packs: @@ -106,6 +105,7 @@ class Queue(QObject): self.addPack(data["id"], pack) def addEvent(self, event): + locker = QMutexLocker(self.mutex) if event[0] == "reload": self.fullReload() elif event[0] == "remove": @@ -120,12 +120,12 @@ class Queue(QObject): for pack in ItemIterator(self.rootItem): for k, child in enumerate(pack.getChildren()): if child.getFileData()["id"] == event[3]: - pack.takeChild(k) + pack.removeChild(child) break else: for k, pack in enumerate(ItemIterator(self.rootItem)): if pack.getPackData()["id"] == event[3]: - self.rootItem.takeChild(k) + self.rootItem.removeChild(pack) break def insertEvent(self, event): @@ -155,6 +155,8 @@ class Queue(QObject): def updateEvent(self, event): if event[2] == "file": info = self.connector.getLinkInfo(event[3]) + if not info: + return for pack in ItemIterator(self.rootItem): if pack.getPackData()["id"] == info["package"]: child = pack.getChild(event[3]) @@ -219,7 +221,8 @@ class Queue(QObject): return None def clearAll(self): - self.rootItem.takeChildren() + for pack in ItemIterator(self.rootItem): + self.rootItem.removeChild(pack) def getWaitingProgress(self, q): locker = QMutexLocker(self.mutex) diff --git a/module/gui/connector.py b/module/gui/connector.py index 3146ecf5b..b6c383956 100644 --- a/module/gui/connector.py +++ b/module/gui/connector.py @@ -131,7 +131,8 @@ class connector(QThread): info["downloading"] = None return info except Exception, e: - self.emit(SIGNAL("proxy_error"), "getLinkInfo", e) + #self.emit(SIGNAL("proxy_error"), "getLinkInfo", e) + return None finally: self.mutex.unlock() diff --git a/module/plugins/decrypter/SerienjunkiesOrg.py b/module/plugins/decrypter/SerienjunkiesOrg.py index af7dc8169..d8396bd0b 100644 --- a/module/plugins/decrypter/SerienjunkiesOrg.py +++ b/module/plugins/decrypter/SerienjunkiesOrg.py @@ -5,6 +5,7 @@ import re from module.Plugin import Plugin from module.BeautifulSoup import BeautifulSoup from module.unescape import unescape +from module.download_thread import CaptchaError class SerienjunkiesOrg(Plugin): def __init__(self, parent): diff --git a/module/thread_list.py b/module/thread_list.py index 1a66bf6f5..a50d73aaf 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -1,22 +1,27 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -# -#Copyright (C) 2009 sp00b, sebnapi, RaNaN -# -#This program is free software; you can redistribute it and/or modify -#it under the terms of the GNU General Public License as published by -#the Free Software Foundation; either version 3 of the License, -#or (at your option) any later version. -# -#This program is distributed in the hope that it will be useful, -#but WITHOUT ANY WARRANTY; without even the implied warranty of -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -#See the GNU General Public License for more details. -# -#You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# -### + +""" + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, + or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, see . + + @author: mkaay + @author: spoob + @author: sebnapi + @author: RaNaN + @version: v0.3 +""" + from __future__ import with_statement from os.path import exists import re @@ -80,9 +85,9 @@ class Thread_List(object): self.occ_plugins.append(pyfile.modul.__name__) pyfile.active = True if pyfile.plugin.props['type'] == "container": - self.parent.logger.info('Get links from: ' + pyfile.url) + self.parent.logger.info(_("Get links from: %s") % pyfile.url) else: - self.parent.logger.info('Download starts: ' + pyfile.url) + self.parent.logger.info(_("Download starts: %s") % pyfile.url) self.lock.release() return pyfile @@ -128,27 +133,27 @@ class Thread_List(object): self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.data["id"]) if newLinks: - self.parent.logger.info("Parsed links from %s: %i" % (pyfile.status.filename, newLinks)) + self.parent.logger.info(_("Parsed links from %s: %i") % (pyfile.status.filename, newLinks)) else: - self.parent.logger.info("No links in %s" % pyfile.status.filename) + self.parent.logger.info(_("No links in %s") % pyfile.status.filename) #~ self.list.packager.removeFileFromPackage(pyfile.id, pyfile.package.id) #~ for link in pyfile.plugin.links: #~ id = self.list.collector.addLink(link) #~ pyfile.packager.pullOutPackage(pyfile.package.id) #~ pyfile.packager.addFileToPackage(pyfile.package.id, pyfile.collector.popFile(id)) else: - self.parent.logger.info("Download finished: %s" % pyfile.url) + self.parent.logger.info(_("Download finished: %s") % pyfile.url) elif pyfile.status.type == "reconnected": pyfile.plugin.req.init_curl() elif pyfile.status.type == "failed": - self.parent.logger.warning("Download failed: " + pyfile.url + " | " + pyfile.status.error) + self.parent.logger.warning(_("Download failed: %s | %s") % (pyfile.url, pyfile.status.error)) with open(self.parent.config['general']['failed_file'], 'a') as f: f.write(pyfile.url + "\n") elif pyfile.status.type == "aborted": - self.parent.logger.info("Download aborted: " + pyfile.url) + self.parent.logger.info(_("Download aborted: %s") % pyfile.url) self.list.save() @@ -198,7 +203,7 @@ class Thread_List(object): return False def reconnect(self): - self.parent.logger.info("Start reconnect") + self.parent.logger.info(_("Starting reconnect")) ip = re.match(".*Current IP Address: (.*).*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) self.parent.hookManager.beforeReconnecting(ip) reconn = subprocess.Popen(self.parent.config['reconnect']['method'])#, stdout=subprocess.PIPE) @@ -212,7 +217,7 @@ class Thread_List(object): ip = "" time.sleep(1) self.parent.hookManager.afterReconnecting(ip) - self.parent.logger.info("Reconnected, new IP: " + ip) + self.parent.logger.info(_("Reconnected, new IP: %s") % ip) def stopAllDownloads(self): self.pause = True -- cgit v1.2.3 From 58ff65301f3edeb1fcffae36b2fd6df3aa46258b Mon Sep 17 00:00:00 2001 From: mkaay Date: Tue, 2 Feb 2010 22:17:09 +0100 Subject: closes #70, thx kepheus --- module/plugins/container/CCF.py | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'module') diff --git a/module/plugins/container/CCF.py b/module/plugins/container/CCF.py index 88b567904..12728d022 100644 --- a/module/plugins/container/CCF.py +++ b/module/plugins/container/CCF.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import os.path -import random import re import tempfile import urllib2 @@ -36,20 +35,11 @@ class CCF(Plugin): "upload": open(infile, "rb")} tempdlc_content = opener.open('http://service.jdownloader.net/dlcrypt/getDLC.php', params).read() - random.seed() - tempdir = tempfile.gettempdir() - if tempdir[0] == '/': - delim = '/' - else: - delim = '\\' - tempdlc_name = tempdir + delim + str(random.randint(0, 100)) + '-tmp.dlc' - while os.path.exists(tempdlc_name): - tempdlc_name = tempfile.gettempdir() + '/' + str(random.randint(0, 100)) + '-tmp.dlc' - - tempdlc = open(tempdlc_name, "w") + tempdlc = tempfile.NamedTemporaryFile(delete=False, suffix='.dlc') tempdlc.write(re.search(r'(.*)', tempdlc_content, re.DOTALL).group(1)) - tempdlc.close + tempdlc.close() - self.links.append(tempdlc_name) + self.links.append(tempdlc.name) return True + -- cgit v1.2.3