diff options
-rw-r--r-- | Core.py | 35 | ||||
-rw-r--r-- | Plugins/BluehostTo.py | 6 | ||||
-rw-r--r-- | Plugins/CCF.py | 2 | ||||
-rw-r--r-- | Plugins/MyvideoDe.py | 14 | ||||
-rw-r--r-- | Plugins/Plugin.py | 20 | ||||
-rw-r--r-- | Plugins/RSDF.py | 22 | ||||
-rw-r--r-- | Plugins/RapidshareCom.py | 26 | ||||
-rw-r--r-- | Plugins/ShragleCom.py | 2 | ||||
-rw-r--r-- | Plugins/UploadedTo.py | 16 | ||||
-rw-r--r-- | Plugins/XupIn.py | 14 | ||||
-rw-r--r-- | Plugins/YoupornCom.py | 26 | ||||
-rw-r--r-- | Plugins/YoutubeCom.py | 16 | ||||
-rw-r--r-- | Plugins/ZippyshareCom.py | 14 | ||||
-rw-r--r-- | Plugins/ZshareNet.py | 14 | ||||
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | module/Py_Load_File.py | 5 | ||||
-rw-r--r-- | module/__init__.py | 1 | ||||
-rw-r--r-- | module/download_thread.py | 28 | ||||
-rw-r--r-- | module/network/Keepalive.py | 46 | ||||
-rw-r--r-- | module/network/MultipartPostHandler.py | 11 | ||||
-rwxr-xr-x | module/network/Request.py | 34 | ||||
-rw-r--r-- | module/network/sslfactory.py | 12 | ||||
-rw-r--r-- | module/remote/ClientSocket.py | 35 | ||||
-rw-r--r-- | module/remote/RequestHandler.py | 11 | ||||
-rw-r--r-- | module/remote/SocketServer.py | 6 | ||||
-rw-r--r-- | module/thread_list.py | 43 | ||||
-rw-r--r-- | pluginconfig | 2 | ||||
-rwxr-xr-x | pyMainGui.py | 30 | ||||
-rw-r--r-- | sockettest.py | 2 |
29 files changed, 243 insertions, 252 deletions
@@ -1,6 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- -# +# -*- coding: utf-8 -*- +# #Copyright (C) 2009 sp00b, sebnapi, RaNaN # #This program is free software; you can redistribute it and/or modify @@ -41,7 +41,7 @@ from module.remote.SocketServer import ServerThread from module.thread_list import Thread_List class Core(object): - """ pyLoad main + """ pyLoad main """ def __init__(self): self.config = {} @@ -52,7 +52,7 @@ class Core(object): self.read_config() - translation = gettext.translation("pyLoad", "locale", languages=[self.config['language']]) + translation = gettext.translation("pyLoad", "locale", languages=[self.config['language']]) translation.install(unicode=True) self.check_create(self.config['log_folder'], _("folder for logs")) @@ -63,7 +63,7 @@ class Core(object): self.init_logger(logging.DEBUG) # logging level self.check_update() - + self.logger.info(_("Downloadtime: %s") % self.is_dltime()) # debug only self.thread_list = Thread_List(self) @@ -72,7 +72,7 @@ class Core(object): self.create_plugin_index() self.init_server() - + def read_config(self): """ read config and sets preferences """ @@ -102,12 +102,12 @@ class Core(object): """ funktion nur zum testen ohne gui bzw. tui """ links = open(link_file, 'r').readlines() - self.extend_links(links) + self.extend_links(links) def append_link(self, link): if link not in self.thread_list.get_loaded_urls(): self.__new_py_load_file(link.replace("\n", "")) - + def extend_links(self, links): for link in links: self.append_link(link) @@ -134,22 +134,22 @@ class Core(object): except: print _("could not create %s") % legend exit() - + def __new_py_load_file(self, url): new_file = PyLoadFile(self, url) new_file.download_folder = self.config['download_folder'] self.thread_list.append_py_load_file(new_file) return True - + def init_logger(self, level): file_handler = logging.handlers.RotatingFileHandler(self.config['log_folder'] + sep + 'log.txt', maxBytes=102400, backupCount=int(self.config['log_count'])) #100 kib * 5 - console = logging.StreamHandler(stdout) + console = logging.StreamHandler(stdout) frm = logging.Formatter("%(asctime)s: %(levelname)-8s %(message)s", "%d.%m.%Y %H:%M:%S") file_handler.setFormatter(frm) console.setFormatter(frm) - + self.logger = logging.getLogger("log") # settable in config if self.config['file_log']: @@ -193,18 +193,18 @@ class Core(object): minutes, seconds = divmod(seconds, 60) return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) return _("%i seconds") % seconds - + def _test_print_status(self): if self.thread_list.py_downloading: - + for pyfile in self.thread_list.py_downloading: if pyfile.status.type == 'downloading': print pyfile.status.filename + ": speed is", int(pyfile.status.get_speed()), "kb/s" print pyfile.status.filename + ": finished in", self.format_time(pyfile.status.get_ETA()) elif pyfile.status.type == 'waiting': print pyfile.status.filename + ": wait", self.format_time(pyfile.status.waituntil - time.time()) - + def start(self): """ starts the machine """ @@ -230,6 +230,5 @@ class Core(object): self.server.start() if __name__ == "__main__": - - testLoader = Core() - testLoader.start() + testLoader = Core() + testLoader.start()
\ No newline at end of file diff --git a/Plugins/BluehostTo.py b/Plugins/BluehostTo.py index d7f9f1e81..c099d792f 100644 --- a/Plugins/BluehostTo.py +++ b/Plugins/BluehostTo.py @@ -20,7 +20,7 @@ class BluehostTo(Plugin): self.parent = parent self.html = None self.multi_dl = False - + def download_html(self): url = self.parent.url self.html = self.req.load(url) @@ -33,7 +33,7 @@ class BluehostTo(Plugin): """ if self.html == None: self.download_html() - + inputs = re.findall(r"(<(input|form)[^>]+)", self.html) for i in inputs: if re.search(r"name=\"BluehostVers2dl\"",i[0]): @@ -67,4 +67,4 @@ class BluehostTo(Plugin): return True def proceed(self, url, location): - self.req.download(url, location, {'BluehostVers2dl': self.BluehostVers2dl, 'DownloadV2Hash': self.DownloadV2Hash, 'PHPSESSID': self.PHPSESSID, 'access': self.access}) + self.req.download(url, location, {'BluehostVers2dl': self.BluehostVers2dl, 'DownloadV2Hash': self.DownloadV2Hash, 'PHPSESSID': self.PHPSESSID, 'access': self.access})
\ No newline at end of file diff --git a/Plugins/CCF.py b/Plugins/CCF.py index e583bfbb3..990e6a2ca 100644 --- a/Plugins/CCF.py +++ b/Plugins/CCF.py @@ -57,4 +57,4 @@ class CCF(Plugin): self.links.append(tempdlc_name) - return True + return True
\ No newline at end of file diff --git a/Plugins/MyvideoDe.py b/Plugins/MyvideoDe.py index 762cd77e0..b4427f0fc 100644 --- a/Plugins/MyvideoDe.py +++ b/Plugins/MyvideoDe.py @@ -4,7 +4,7 @@ import re from Plugin import Plugin class MyvideoDe(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -19,7 +19,7 @@ class MyvideoDe(Plugin): self.parent = parent self.html = None self.html_old = None #time() where loaded the HTML - self.time_plus_wait = None #time() + wait in seconds + self.time_plus_wait = None #time() + wait in seconds def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status @@ -29,11 +29,11 @@ class MyvideoDe(Plugin): self.parent.status.filename = self.get_file_name() self.parent.status.url = self.get_file_url() self.parent.status.wait = self.wait_until() - + def download_html(self): url = self.parent.url self.html = self.req.load(url) - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -46,15 +46,15 @@ class MyvideoDe(Plugin): print videoServer print file_url return file_url - + def get_file_name(self): if self.html == None: self.download_html() file_name_pattern = r"<h1 class='globalHd'>(.*)</h1>" return re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.flv' - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index c58976cd4..c1205e206 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -7,7 +7,7 @@ import re from module.network.Request import Request class Plugin(): - + def __init__(self, parent): self.parser = ConfigParser.SafeConfigParser() self.config = {} @@ -26,23 +26,23 @@ class Plugin(): self.time_plus_wait = 0 #time() + wait in seconds self.want_reconnect = False self.multi_dl = True - + def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status """ pass - + def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses - """ + """ html = "" self.html = html - + def file_exists(self): - """ returns True or False + """ returns True or False """ return True - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -50,12 +50,12 @@ class Plugin(): def get_file_name(self): return re.findall("([^\/=]+)", self.parent.url)[-1] - + def wait_until(self): if self.html != None: self.download_html() return self.time_plus_wait - + def proceed(self, url, location): self.req.download(url, location) @@ -75,4 +75,4 @@ class Plugin(): self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] def __call__(self): - return self.props['name'] + return self.props['name']
\ No newline at end of file diff --git a/Plugins/RSDF.py b/Plugins/RSDF.py index 74c07a007..d0ac3ec25 100644 --- a/Plugins/RSDF.py +++ b/Plugins/RSDF.py @@ -7,7 +7,7 @@ import binascii from Plugin import Plugin class RSDF(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -22,38 +22,38 @@ class RSDF(Plugin): self.parent = parent self.multi_dl = True self.links = [] - + def file_exists(self): - """ returns True or False + """ returns True or False """ return True def proceed(self, url, location): try: from Crypto.Cipher import AES - + infile = url.replace("\n", "") Key = binascii.unhexlify('8C35192D964DC3182C6F84F3252239EB4A320D2500000000') - + IV = binascii.unhexlify('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF') IV_Cipher = AES.new(Key, AES.MODE_ECB) IV = IV_Cipher.encrypt(IV) - + obj = AES.new(Key, AES.MODE_CFB, IV) - + rsdf = open(infile, 'r') - + data = rsdf.read() data = binascii.unhexlify(''.join(data.split())) data = data.splitlines() - + for link in data: link = base64.b64decode(link) link = obj.decrypt(link) decryptedUrl = link.replace('CCF: ', '') self.links.append(decryptedUrl) - + rsdf.close() - + except: print "Kein Crypto installiert, RSDF Plugin kann nicht genutzt werden" diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index 362c2cf73..f7b981e37 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -8,7 +8,7 @@ from time import time from Plugin import Plugin class RapidshareCom(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -41,10 +41,10 @@ class RapidshareCom(Plugin): self.parent.status.filename = self.get_file_name() self.parent.status.url = self.get_file_url() self.parent.status.waituntil = self.wait_until() - + def download_html(self): """ gets the url from self.parent.url saves html in self.html and parses - """ + """ url = self.parent.url html = self.req.load(url) self.html[0] = html @@ -59,7 +59,7 @@ class RapidshareCom(Plugin): self.download_html() if self.config['premium']: - return False + return False file_server_url = re.search(r"<form action=\"(.*?)\"", self.html[0]).group(1) #free user @@ -67,7 +67,7 @@ class RapidshareCom(Plugin): self.html[1] = self.req.load(file_server_url, None, {"dl.start": "Free"}) self.html_old = time() self.get_wait_time() - + def get_wait_time(self): if self.config['premium']: @@ -76,7 +76,7 @@ class RapidshareCom(Plugin): if self.html[1] == None: self.download_serverhtml(self) - + if re.search(r".*is already downloading.*", self.html[1]) != None: self.time_plus_wait = time() + 10 * 60 try: @@ -88,9 +88,9 @@ class RapidshareCom(Plugin): self.time_plus_wait = time() + 2 * 60 wait_seconds = re.search(r"var c=(.*);.*", self.html[1]).group(1) self.time_plus_wait = time() + int(wait_seconds) + 5 - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html[0] == None: self.download_html() @@ -98,8 +98,8 @@ class RapidshareCom(Plugin): re.search(r"(<p>This limit is reached.</p>)", self.html[0]) or \ re.search(r"(.*is momentarily not available.*)", self.html[0]) or \ re.search(r"(.*The uploader has removed this file from the server.*)", self.html[0]) or \ - re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]): - return False + re.search(r"(.*This file is suspected to contain illegal content.*)", self.html[0]): + return False else: return True @@ -120,17 +120,17 @@ class RapidshareCom(Plugin): return re.search(file_url_pattern, self.html[1]).group(1) else: return False - + def get_file_name(self): if self.html[0] == None: self.download_html() file_name_pattern = r"<p class=\"downloadlink\">.+/(.+)<font" return re.findall(file_name_pattern, self.html[0])[0] - + def proceed(self, url, location): if self.config['premium']: self.req.add_auth(self.config['username'], self.config['password']) - self.req.download(url, location) + self.req.download(url, location)
\ No newline at end of file diff --git a/Plugins/ShragleCom.py b/Plugins/ShragleCom.py index 45f416872..3cd093ce2 100644 --- a/Plugins/ShragleCom.py +++ b/Plugins/ShragleCom.py @@ -60,7 +60,7 @@ class ShragleCom(Plugin): """ if self.html == None: self.download_html() - + if re.search(r"html", self.html) == None: return False else: diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py index 67c8685fa..edb39ab45 100644 --- a/Plugins/UploadedTo.py +++ b/Plugins/UploadedTo.py @@ -5,7 +5,7 @@ from time import time from Plugin import Plugin class UploadedTo(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -23,7 +23,7 @@ class UploadedTo(Plugin): self.time_plus_wait = None #time() + wait in seconds self.want_reconnect = None self.multi_dl = False - + def download_html(self): url = self.parent.url self.html = self.req.load(url) @@ -34,18 +34,18 @@ class UploadedTo(Plugin): self.want_reconnect = True except: self.time_plus_wait = 0 - + def get_file_url(self): """ returns the absolute downloadable filepath """ if self.html == None: self.download_html() - if not self.want_reconnect: + if not self.want_reconnect: file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">" return re.search(file_url_pattern, self.html).group(1) else: return False - + def get_file_name(self): if self.html == None: self.download_html() @@ -56,9 +56,9 @@ class UploadedTo(Plugin): return file_name else: return self.parent.url - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() @@ -70,4 +70,4 @@ class UploadedTo(Plugin): def wait_until(self): if self.html == None: self.download_html() - return self.time_plus_wait + return self.time_plus_wait
\ No newline at end of file diff --git a/Plugins/XupIn.py b/Plugins/XupIn.py index 21bcd3434..0f5c9a8b8 100644 --- a/Plugins/XupIn.py +++ b/Plugins/XupIn.py @@ -4,7 +4,7 @@ import re from Plugin import Plugin class XupIn(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -23,24 +23,24 @@ class XupIn(Plugin): self.posts = {} self.want_reconnect = None self.multi_dl = False - + def download_html(self): url = self.parent.url self.html = self.req.load(url) self.posts["vid"] = re.search('"hidden" value="(.*)" name="vid"', self.html).group(1) self.posts["vtime"] = re.search('"hidden" value="(.*)" name="vtime"', self.html).group(1) - + def get_file_url(self): """ returns the absolute downloadable filepath """ if self.html == None: self.download_html() - if not self.want_reconnect: + if not self.want_reconnect: file_url_pattern = r".*<form action=\"(.*)\" method=\"post\">" return re.search(file_url_pattern, self.html).group(1) else: return False - + def get_file_name(self): if self.html == None: self.download_html() @@ -48,9 +48,9 @@ class XupIn(Plugin): return self.parent.url.split('/')[-2] else: return self.parent.url - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() diff --git a/Plugins/YoupornCom.py b/Plugins/YoupornCom.py index 08223bea5..20f8ed95c 100644 --- a/Plugins/YoupornCom.py +++ b/Plugins/YoupornCom.py @@ -4,13 +4,13 @@ import re from Plugin import Plugin class YoupornCom(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} props['name'] = "YoupornCom" props['type'] = "hoster" - props['pattern'] = r"http://(www\.)?youporn\.com/watch/.+" + props['pattern'] = r"http://(www\.)?youporn\.com/watch/.+" props['version'] = "0.1" props['description'] = """Youporn.com Video Download Plugin""" props['author_name'] = ("willnix") @@ -20,7 +20,7 @@ class YoupornCom(Plugin): self.html = None self.html_old = None #time() where loaded the HTML self.time_plus_wait = None #time() + wait in seconds - + def set_parent_status(self): """ sets all available Statusinfos about a File in self.parent.status """ @@ -29,11 +29,11 @@ class YoupornCom(Plugin): self.parent.status.filename = self.get_file_name() self.parent.status.url = self.get_file_url() self.parent.status.wait = self.wait_until() - + def download_html(self): url = self.parent.url self.html = self.req.load(url) - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -41,21 +41,21 @@ class YoupornCom(Plugin): self.download_html() file_url = re.search(r'(http://download.youporn.com/download/\d*/.*\?download=1&ll=1&t=dd)">', self.html).group(1) - print file_url - return file_url - + print file_url + return file_url + def get_file_name(self): if self.html == None: self.download_html() - file_name_pattern = r".*<title>(.*) - Free Porn Videos - YouPorn.com Lite \(BETA\)</title>.*" - return re.search(file_name_pattern, self.html).group(1) + '.flv' - + file_name_pattern = r".*<title>(.*) - Free Porn Videos - YouPorn.com Lite \(BETA\)</title>.*" + return re.search(file_name_pattern, self.html).group(1) + '.flv' + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() if re.search(r"(.*invalid video_id.*)", self.html) != None: return False else: - return True + return True
\ No newline at end of file diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py index 2d8567a28..2a8315ad5 100644 --- a/Plugins/YoutubeCom.py +++ b/Plugins/YoutubeCom.py @@ -4,7 +4,7 @@ import re from Plugin import Plugin class YoutubeCom(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -19,11 +19,11 @@ class YoutubeCom(Plugin): self.parent = parent self.html = None self.read_config() - + def download_html(self): url = self.parent.url self.html = self.req.load(url) - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -37,23 +37,23 @@ class YoutubeCom(Plugin): quality = "&fmt=18" file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + quality return file_url - + def get_file_name(self): if self.html == None: self.download_html() - + file_name_pattern = r"<title>YouTube - (.*)</title>" file_suffix = ".flv" if self.config['high_quality']: file_suffix = ".mp4" return re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() if re.search(r"(.*eine fehlerhafte Video-ID\.)", self.html) != None: return False else: - return True + return True
\ No newline at end of file diff --git a/Plugins/ZippyshareCom.py b/Plugins/ZippyshareCom.py index 59bce0623..d0f27fd53 100644 --- a/Plugins/ZippyshareCom.py +++ b/Plugins/ZippyshareCom.py @@ -6,7 +6,7 @@ from time import time from Plugin import Plugin class ZippyshareCom(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -22,12 +22,12 @@ class ZippyshareCom(Plugin): self.html = None self.want_reconnect = False self.multi_dl = False - + def download_html(self): url = self.parent.url self.html = self.req.load(url) self.time_plus_wait = time() + 12 - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -38,7 +38,7 @@ class ZippyshareCom(Plugin): return file_url else: return False - + def get_file_name(self): if self.html == None: self.download_html() @@ -48,13 +48,13 @@ class ZippyshareCom(Plugin): return file_name else: return self.parent.url - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html == None: self.download_html() if re.search(r"HTTP Status 404", self.html) != None: return False else: - return True + return True
\ No newline at end of file diff --git a/Plugins/ZshareNet.py b/Plugins/ZshareNet.py index 0979e88c7..1701387ce 100644 --- a/Plugins/ZshareNet.py +++ b/Plugins/ZshareNet.py @@ -4,7 +4,7 @@ import re from Plugin import Plugin class ZshareNet(Plugin): - + def __init__(self, parent): Plugin.__init__(self, parent) props = {} @@ -23,7 +23,7 @@ class ZshareNet(Plugin): self.posts = {} self.want_reconnect = False self.multi_dl = False - + def download_html(self): url = self.parent.url self.html[0] = self.req.load(url) @@ -34,7 +34,7 @@ class ZshareNet(Plugin): elif "/image/" in url: url = url.replace("/image/", "/download/") self.html[1] = self.req.load(url, None, {"download": "1"}) - + def get_file_url(self): """ returns the absolute downloadable filepath """ @@ -45,7 +45,7 @@ class ZshareNet(Plugin): return file_url else: return False - + def get_file_name(self): if self.html[0] == None: self.download_html() @@ -54,9 +54,9 @@ class ZshareNet(Plugin): return file_name else: return self.parent.url - + def file_exists(self): - """ returns True or False + """ returns True or False """ if self.html[0] == None: self.download_html() @@ -68,4 +68,4 @@ class ZshareNet(Plugin): def wait_until(self): if self.html[0] == None: self.download_html() - return self.time_plus_wait + return self.time_plus_wait
\ No newline at end of file @@ -21,4 +21,4 @@ Add your links to the links.txt file and start pyload with: python pyLoad.py For more information, see -http://pyload.org/ +http://pyload.org/
\ No newline at end of file diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index d0a4c4591..8779a18fd 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -24,7 +24,7 @@ class PyLoadFile: return plugin return "Plugin" - + def prepareDownload(self): if self.parent.config['useproxy']: @@ -36,5 +36,4 @@ class PyLoadFile: self.status.filename = self.plugin.get_file_name() self.status.waituntil = self.plugin.time_plus_wait self.status.url = self.plugin.get_file_url() - self.status.want_reconnect = self.plugin.want_reconnect - + self.status.want_reconnect = self.plugin.want_reconnect
\ No newline at end of file diff --git a/module/__init__.py b/module/__init__.py index 8d1c8b69c..e69de29bb 100644 --- a/module/__init__.py +++ b/module/__init__.py @@ -1 +0,0 @@ - diff --git a/module/download_thread.py b/module/download_thread.py index 5313a7d34..3ad2ba85d 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- -# +# -*- coding: utf-8 -*- +# #Copyright (C) 2009 sp00b, sebnapi # #This program is free software; you can redistribute it and/or modify @@ -34,15 +34,15 @@ class Status(object): self.exists = False self.waituntil = None self.want_reconnect = False - + def get_ETA(self): return self.pyfile.plugin.req.get_ETA() def get_speed(self): return self.pyfile.plugin.req.get_speed() def kB_left(self): return self.pyfile.plugins.req.kB_left() - - + + class Download_Thread(threading.Thread): def __init__(self, parent): threading.Thread.__init__(self) @@ -50,9 +50,9 @@ class Download_Thread(threading.Thread): self.parent = parent self.setDaemon(True) self.loadedPyFile = None - + self.start() - + def run(self): while (not self.shutdown): if self.parent.py_load_files: @@ -76,24 +76,24 @@ class Download_Thread(threading.Thread): if not status.exists: raise "FileDontExists" #i know its deprecated, who cares^^ - - status.type = "waiting" + + status.type = "waiting" while (time() < status.waituntil): if self.parent.init_reconnect() or self.parent.reconnecting: status.type = "reconnected" - status.want_reconnect = False + status.want_reconnect = False return False sleep(1) status.want_reconnect = False - + status.type = "downloading" - + pyfile.plugin.proceed(status.url, pyfile.download_folder + "/" + status.filename) status.type = "finished" #startet downloader - #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status) - #self.shutdown = True + #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status) + #self.shutdown = True
\ No newline at end of file diff --git a/module/network/Keepalive.py b/module/network/Keepalive.py index 68abe087d..dbf4d94cb 100644 --- a/module/network/Keepalive.py +++ b/module/network/Keepalive.py @@ -9,9 +9,9 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA # This file is part of urlgrabber, a high-level cross-protocol url-grabber @@ -24,7 +24,7 @@ >>> keepalive_handler = HTTPHandler() >>> opener = urllib2.build_opener(keepalive_handler) >>> urllib2.install_opener(opener) ->>> +>>> >>> fo = urllib2.urlopen('http://www.python.org') If a connection to a given host is requested, and all of the existing @@ -113,7 +113,7 @@ import sslfactory import sys if sys.version_info < (2, 4): HANDLE_ERRORS = 1 else: HANDLE_ERRORS = 0 - + class ConnectionManager: """ The connection manager must be able to: @@ -153,7 +153,7 @@ class ConnectionManager: def set_ready(self, connection, ready): try: self._readymap[connection] = ready except KeyError: pass - + def get_ready_conn(self, host): conn = None self._lock.acquire() @@ -177,7 +177,7 @@ class ConnectionManager: class KeepAliveHandler: def __init__(self): self._cm = ConnectionManager() - + #### Connection Management def open_connections(self): """return a list of connected hosts and the number of connections @@ -191,14 +191,14 @@ class KeepAliveHandler: for h in self._cm.get_all(host): self._cm.remove(h) h.close() - + def close_all(self): """close all open connections""" for host, conns in self._cm.get_all().items(): for h in conns: self._cm.remove(h) h.close() - + def _request_closed(self, request, host, connection): """tells us that this request is now closed and the the connection is ready for another request""" @@ -207,7 +207,7 @@ class KeepAliveHandler: def _remove_connection(self, host, connection, close=0): if close: connection.close() self._cm.remove(connection) - + #### Transaction Execution def do_open(self, req): host = req.get_host() @@ -238,7 +238,7 @@ class KeepAliveHandler: r = h.getresponse() except (socket.error, httplib.HTTPException), err: raise urllib2.URLError(err) - + # if not a persistent connection, don't try to reuse it if r.will_close: self._cm.remove(h) @@ -250,7 +250,7 @@ class KeepAliveHandler: r.code = r.status r.headers = r.msg r.msg = r.reason - + if r.status == 200 or not HANDLE_ERRORS: return r else: @@ -286,7 +286,7 @@ class KeepAliveHandler: self._cm.remove(h) h.close() raise - + if r is None or r.version == 9: # httplib falls back to assuming HTTP 0.9 if it gets a # bad header back. This is most likely to happen if @@ -342,7 +342,7 @@ class HTTPSHandler(KeepAliveHandler, urllib2.HTTPSHandler): if not ssl_factory: ssl_factory = sslfactory.get_factory() self._ssl_factory = ssl_factory - + def https_open(self, req): return self.do_open(req) @@ -367,7 +367,7 @@ class HTTPResponse(httplib.HTTPResponse): # although read() never adds to the buffer. # Both readline and readlines have been stolen with almost no # modification from socket.py - + def __init__(self, sock, debuglevel=0, strict=0, method=None): if method: # the httplib in python 2.3 uses the method arg @@ -396,7 +396,7 @@ class HTTPResponse(httplib.HTTPResponse): def close_connection(self): self._handler._remove_connection(self._host, self._connection, close=1) self.close() - + def info(self): return self.headers @@ -453,7 +453,7 @@ class HTTPConnection(httplib.HTTPConnection): class HTTPSConnection(httplib.HTTPSConnection): response_class = HTTPResponse - + ######################################################################### ##### TEST FUNCTIONS ######################################################################### @@ -487,7 +487,7 @@ def error_handler(url): def continuity(url): import md5 format = '%25s: %s' - + # first fetch the file with the normal http handler opener = urllib2.build_opener() urllib2.install_opener(opener) @@ -534,7 +534,7 @@ def comp(N, url): t2 = fetch(N, url) print ' TIME: %.3f s' % t2 print ' improvement factor: %.2f' % (t1/t2, ) - + def fetch(N, url, delay=0): import time lens = [] @@ -566,7 +566,7 @@ def test_timeout(url): fo = urllib2.urlopen(url) data1 = fo.read() fo.close() - + i = 20 print " waiting %i seconds for the server to close the connection" % i while i > 0: @@ -588,7 +588,7 @@ def test_timeout(url): DEBUG = dbbackup - + def test(url, N=10): print "checking error hander (do this on a non-200)" try: error_handler(url) @@ -604,7 +604,7 @@ def test(url, N=10): print print "performing dropped-connection check" test_timeout(url) - + if __name__ == '__main__': import time import sys @@ -614,4 +614,4 @@ if __name__ == '__main__': except: print "%s <integer> <url>" % sys.argv[0] else: - test(url, N) + test(url, N)
\ No newline at end of file diff --git a/module/network/MultipartPostHandler.py b/module/network/MultipartPostHandler.py index f25c6fa1b..b6980ae18 100644 --- a/module/network/MultipartPostHandler.py +++ b/module/network/MultipartPostHandler.py @@ -2,18 +2,18 @@ #### # 02/2006 Will Holcomb <wholcomb@gmail.com> -# +# # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. -# +# # This library 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 # Lesser General Public License for more details. # -# 7/26/07 Slightly modified by Brian Schneider +# 7/26/07 Slightly modified by Brian Schneider # in order to support unicode files ( multipart_encode function ) """ Usage: @@ -84,7 +84,7 @@ class MultipartPostHandler(urllib2.BaseHandler): request.add_unredirected_header('Content-Type', contenttype) request.add_data(data) - + return request def multipart_encode(vars, files, boundary = None, buf = None): @@ -135,5 +135,4 @@ def main(): validateFile("http://www.google.com") if __name__=="__main__": - main() - + main()
\ No newline at end of file diff --git a/module/network/Request.py b/module/network/Request.py index de9000ab3..2a0199fb8 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -20,7 +20,7 @@ from cStringIO import StringIO additionaly you can firstly pass the get and secondly the post data in form of a dictonary when the last argument is true the handler simulate a http referer with the last called url. retrieveUrl returns response as string - + """ class Request: def __init__(self): @@ -38,13 +38,13 @@ class Request: self.opener = urllib2.build_opener(handler, urllib2.HTTPCookieProcessor(self.cj)) self.downloader = urllib2.build_opener() #self.opener.add_handler() - + self.opener.addheaders = [ ("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", "gzip,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"), + ("Connection", "keep-alive"), ("Keep-Alive", "300")] self.downloader.addheaders = [ @@ -52,20 +52,20 @@ class Request: ("Accept-Encoding", "gzip,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")] - - + + def load(self, url, get={}, post={}, ref=True, cookies=False): - + if post: post = urllib.urlencode(post) else: post = None - + if get: get = urllib.urlencode(get) else: get = "" - + url = url + get req = urllib2.Request(url, data=post) @@ -85,13 +85,13 @@ class Request: self.cookies.append(cookie) output = rep.read() - + if rep.headers.has_key("content-encoding"): if rep.headers["content-encoding"] == "gzip": output = GzipFile('', 'r', 0, StringIO(output)).read() - + self.lastURL = url - + return output def add_auth(self, user, pw): @@ -111,12 +111,12 @@ class Request: self.downloader.add_handler(handler) def download(self, url, filename, post={}): - + if post: post = urllib.urlencode(post) else: post = None - + if not self.dl: self.dl = True file = open(filename, 'wb') @@ -128,14 +128,14 @@ class Request: self.dl_size = 0 self.dl_arrived = 0 self.dl_time = time.time() - for chunk in conn: + for chunk in conn: self.dl_arrived += len(chunk) file.write(chunk) file.close() self.dl = False self.dl_finished = time.time() return True - + def get_speed(self): try: return (self.dl_arrived / ((time.time() if self.dl else self.dl_finished) - self.dl_time)) / 1024 @@ -144,7 +144,7 @@ class Request: def get_ETA(self): try: - return (self.dl_size - self.dl_arrived) / (self.dl_arrived / (time.time() - self.dl_time)) + return (self.dl_size - self.dl_arrived) / (self.dl_arrived / (time.time() - self.dl_time)) except: return 0 @@ -153,4 +153,4 @@ class Request: if __name__ == "__main__": import doctest - doctest.testmod() + doctest.testmod()
\ No newline at end of file diff --git a/module/network/sslfactory.py b/module/network/sslfactory.py index f7e6d3d7e..14903cd2a 100644 --- a/module/network/sslfactory.py +++ b/module/network/sslfactory.py @@ -9,9 +9,9 @@ # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the -# Free Software Foundation, Inc., -# 59 Temple Place, Suite 330, +# License along with this library; if not, write to the +# Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, # Boston, MA 02111-1307 USA # This file is part of urlgrabber, a high-level cross-protocol url-grabber @@ -31,7 +31,7 @@ except ImportError: DEBUG = None if have_m2crypto: - + class M2SSLFactory: def __init__(self, ssl_ca_cert, ssl_context): @@ -74,7 +74,7 @@ class SSLFactory: def create_opener(self, *handlers): return urllib2.build_opener(*handlers) - + def get_factory(ssl_ca_cert = None, ssl_context = None): """ Return an SSLFactory, based on if M2Crypto is available. """ @@ -86,4 +86,4 @@ def get_factory(ssl_ca_cert = None, ssl_context = None): if DEBUG: DEBUG.warning("SSL arguments supplied, but M2Crypto is not available. " "Using Python SSL.") - return SSLFactory() + return SSLFactory()
\ No newline at end of file diff --git a/module/remote/ClientSocket.py b/module/remote/ClientSocket.py index 4efeaf3ab..ee0d03e82 100644 --- a/module/remote/ClientSocket.py +++ b/module/remote/ClientSocket.py @@ -16,29 +16,29 @@ from RequestObject import RequestObject class SocketThread(threading.Thread): def __init__(self, adress, port, pw, client): - threading.Thread.__init__(self) - self.setDaemon(True) - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.connect((adress, port)) - self.socket = ClientSocket(sock, pw, client) - self.start() + threading.Thread.__init__(self) + self.setDaemon(True) + sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + sock.connect((adress, port)) + self.socket = ClientSocket(sock, pw, client) + self.start() def run(self): - asyncore.loop() - print "loop closed" + asyncore.loop() + print "loop closed" def push_exec(self, function, args=[]): - obj = RequestObject() - obj.command = "exec" - obj.function = function - obj.args = args - self.push(obj) + obj = RequestObject() + obj.command = "exec" + obj.function = function + obj.args = args + self.push(obj) def push(self, obj): - self.socket.push_obj(obj) + self.socket.push_obj(obj) -class ClientSocket(asynchat.async_chat): +class ClientSocket(asynchat.async_chat): def __init__(self, sock, pw, client): asynchat.async_chat.__init__(self, sock) self.data = "" @@ -58,6 +58,5 @@ class ClientSocket(asynchat.async_chat): self.data = "" def push_obj(self, obj): - string = self.handler.encrypt(obj) - self.push(string) - + string = self.handler.encrypt(obj) + self.push(string)
\ No newline at end of file diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py index 2f6f248bd..9ded5d02e 100644 --- a/module/remote/RequestHandler.py +++ b/module/remote/RequestHandler.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ authored by: RaNaN @@ -31,7 +31,7 @@ class RequestHandler: obj.response = func( * obj.args) else: obj.response = "error happend" - + return self.encrypt(obj) @@ -39,7 +39,7 @@ class RequestHandler: try: dec_str = base64.standard_b64decode(dec_str) dec_str = self.bf.decrypt(dec_str) - + dec_str = dec_str[:-(int(dec_str[-1], 16) + 1)] obj = cPickle.loads(dec_str) except: @@ -60,7 +60,4 @@ class RequestHandler: enc_str = self.bf.encrypt(enc_str) enc_str = base64.standard_b64encode(enc_str) - return enc_str + "\n" - - - + return enc_str + "\n"
\ No newline at end of file diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py index e5932bb6e..c683c6672 100644 --- a/module/remote/SocketServer.py +++ b/module/remote/SocketServer.py @@ -19,7 +19,7 @@ class ServerThread(threading.Thread): threading.Thread.__init__(self) self.setDaemon(True) self.server = MainServerSocket(int(pycore.config['port']), pycore) - + def run(self): asyncore.loop() print "loop closed" @@ -52,8 +52,8 @@ class MainServerSocket(asyncore.dispatcher): print "Connected from", address SecondaryServerSocket(newSocket, self.pycore) def handle_close(self): - print "going to close" - self.close() + print "going to close" + self.close() class SecondaryServerSocket(asynchat.async_chat): diff --git a/module/thread_list.py b/module/thread_list.py index 9f60ca5f5..f7be6f000 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- -# +# -*- coding: utf-8 -*- +# #Copyright (C) 2009 sp00b, sebnapi # #This program is free software; you can redistribute it and/or modify @@ -48,16 +48,16 @@ class Thread_List(object): thread = Download_Thread(self) self.threads.append(thread) return True - + def get_loaded_urls(self): loaded_urls = [] for file in self.py_load_files: loaded_urls.append(file.url) return loaded_urls - + def remove_thread(self, thread): self.threads.remove(thread) - + def get_job(self): """return job if suitable, otherwise send thread idle""" @@ -67,7 +67,7 @@ class Thread_List(object): if self.pause: return None - + if self.reconnecting: return None @@ -80,24 +80,24 @@ class Thread_List(object): if not self.py_load_files[i].modul.__name__ in self.occ_plugins: pyfile = self.py_load_files.pop(i) break - + if pyfile: - self.py_downloading.append(pyfile) + self.py_downloading.append(pyfile) if not pyfile.plugin.multi_dl: self.occ_plugins.append(pyfile.modul.__name__) self.parent.logger.info('Download starts: ' + pyfile.url) - + self.lock.release() return pyfile - - + + def job_finished(self, pyfile): self.lock.acquire() - + if not pyfile.plugin.multi_dl: self.occ_plugins.remove(pyfile.modul.__name__) - - self.py_downloading.remove(pyfile) + + self.py_downloading.remove(pyfile) if pyfile.status.type == "finished": self.parent.logger.info('Download finished: ' + pyfile.url + ' @' + str(pyfile.status.get_speed()) + 'kb/s') @@ -132,13 +132,13 @@ class Thread_List(object): def extend_py_load_files(self): pass - + def select_thread(self): """ select a thread """ if len(self.threads) < self.max_threads: self.create_thread() - + def append_py_load_file(self, py_load_file): py_load_file.id = len(self.py_load_files) self.py_load_files.append(py_load_file) @@ -152,7 +152,7 @@ class Thread_List(object): if self.reconnecting: return False - + self.lock.acquire() if self.check_reconnect(): @@ -163,13 +163,13 @@ class Thread_List(object): self.reconnecting = False self.lock.release() return True - + self.lock.release() return False - + def check_reconnect(self): """checks if all files want reconnect""" - + if not self.py_downloading: return False @@ -190,5 +190,4 @@ class Thread_List(object): while ip == "": #solange versuch bis neue ip ausgelesen ip = re.match(".*Current IP Address: (.*)</body>.*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) time.sleep(1) - self.parent.logger.info("Reconnected, new IP: " + ip) - + self.parent.logger.info("Reconnected, new IP: " + ip)
\ No newline at end of file diff --git a/pluginconfig b/pluginconfig index a4ebc74cc..b79127a5a 100644 --- a/pluginconfig +++ b/pluginconfig @@ -6,4 +6,4 @@ password = pass high_quality = True [YoutubeChannel] #type False for no limitation -max_videos = False +max_videos = False
\ No newline at end of file diff --git a/pyMainGui.py b/pyMainGui.py index ebacef0b8..d382dc231 100755 --- a/pyMainGui.py +++ b/pyMainGui.py @@ -1,6 +1,6 @@ #!/usr/bin/python -# -*- coding: utf-8 -*- -# +# -*- coding: utf-8 -*- +# #Copyright (C) 2009 KingZero # #This program is free software; you can redistribute it and/or modify @@ -36,7 +36,7 @@ class _Download_Dialog(sized_control.SizedDialog): def __init__(self, parent, id): sized_control.SizedDialog.__init__(self, parent, id, "Downloads hinzufügen", style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER) - + pane = self.GetContentsPane() self.links = wx.TextCtrl(pane, -1, style=wx.TE_MULTILINE, size=(500, 200)) @@ -77,26 +77,26 @@ class _Lower_Panel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx.BLACK) - - + + class Pyload_Main_Gui(wx.Frame): def __init__(self, parent, id, title="pyLoad"): - + wx.Frame.__init__(self, parent, id, title, size=(910, 500)) - + app_path = dirname(abspath(__file__)) + sep # socket self.thread = SocketThread("localhost", 7272, "pwhere", self) - + # Menubar menubar = wx.MenuBar() menu_file = wx.Menu() submenu_exit = menu_file.Append(-1, 'Schliessen', 'pyLoad beenden') menubar.Append(menu_file, '&Datei') self.SetMenuBar(menubar) - + # Toolbar toolbar = self.CreateToolBar() toolbar.SetToolBitmapSize((32, 32)) @@ -109,7 +109,7 @@ class Pyload_Main_Gui(wx.Frame): down = toolbar.AddLabelTool(8, '', wx.Bitmap(app_path + '/icons/down.png')) config = toolbar.AddLabelTool(9, '', wx.Bitmap(app_path + '/icons/setup.png')) toolbar.Realize() - + splitter = wx.SplitterWindow(self) panel_up = _Upper_Panel(splitter) panel_down = _Lower_Panel(splitter) @@ -118,15 +118,15 @@ class Pyload_Main_Gui(wx.Frame): # Binds self.Bind(wx.EVT_MENU, self.exit_button_clicked, submenu_exit) self.Bind(wx.EVT_TOOL, self.add_button_clicked, add) - self.Bind(EVT_DATA_ARRIVED, self.onUpdate) + self.Bind(EVT_DATA_ARRIVED, self.onUpdate) self.Centre() self.Show(True) - + def exit_button_clicked(self, event): self.Close() - + def add_button_clicked(self, event): #test #self.thread.push_exec("get_downloads") @@ -150,7 +150,7 @@ class Pyload_Main_Gui(wx.Frame): if evt.obj.command == "update": self.show_links(evt.obj.data) - + app = wx.App() Pyload_Main_Gui(None, -1) -app.MainLoop() +app.MainLoop()
\ No newline at end of file diff --git a/sockettest.py b/sockettest.py index 5cfebe581..ee0053b11 100644 --- a/sockettest.py +++ b/sockettest.py @@ -76,4 +76,4 @@ th.socket.push(data + "\n") #print "Received:", handler.decrypt(response).response #sock.close() while True: - sleep(10000) + sleep(10000)
\ No newline at end of file |