diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-07 13:23:52 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-08-07 13:23:52 +0200 |
commit | d59f4d94c6b627b83269c643703824afb7faab14 (patch) | |
tree | c3e9756164daf58dfdfff69be8624d18d1d50934 | |
parent | ... (diff) | |
download | pyload-d59f4d94c6b627b83269c643703824afb7faab14.tar.xz |
Rs fix, timed reconnect, Cli local option + displaying size
-rw-r--r-- | Plugins/HoerbuchIn.py | 1 | ||||
-rw-r--r-- | Plugins/MegauploadCom.py | 2 | ||||
-rw-r--r-- | Plugins/Plugin.py | 4 | ||||
-rw-r--r-- | Plugins/RapidshareCom.py | 6 | ||||
-rw-r--r-- | Plugins/YoutubeCom.py | 5 | ||||
-rw-r--r-- | captcha/captcha.py | 2 | ||||
-rw-r--r-- | config | 9 | ||||
-rw-r--r-- | module/remote/RequestHandler.py | 2 | ||||
-rw-r--r-- | module/thread_list.py | 2 | ||||
-rw-r--r-- | pyLoadCli.py | 25 | ||||
-rw-r--r-- | pyLoadCore.py | 32 |
11 files changed, 63 insertions, 27 deletions
diff --git a/Plugins/HoerbuchIn.py b/Plugins/HoerbuchIn.py index bf6711461..d318f1927 100644 --- a/Plugins/HoerbuchIn.py +++ b/Plugins/HoerbuchIn.py @@ -34,7 +34,6 @@ class HoerbuchIn(Plugin): tmp = re.findall('<A HREF="(http://www.hoerbuch.in/cj/out.php\?pct=.*?)" TARGET="_blank">Part \d+</A>', download_content) for link in tmp: - i = 0 for i in range(5): link_html = self.req.load(link, cookies=True) link_name = link.split("/")[-1] diff --git a/Plugins/MegauploadCom.py b/Plugins/MegauploadCom.py index 6f5882458..63f033945 100644 --- a/Plugins/MegauploadCom.py +++ b/Plugins/MegauploadCom.py @@ -4,8 +4,6 @@ import os import re import tempfile -from time import time -from time import sleep from Plugin import Plugin diff --git a/Plugins/Plugin.py b/Plugins/Plugin.py index c0724c390..5d7fc8f45 100644 --- a/Plugins/Plugin.py +++ b/Plugins/Plugin.py @@ -18,6 +18,7 @@ # ### import ConfigParser +import logging import re from module.network.Request import Request @@ -43,6 +44,7 @@ class Plugin(): self.want_reconnect = False self.multi_dl = True self.ocr = None #captcha reader instance + self.logger = logging.getLogger("log") def prepare(self, thread): pyfile = self.parent @@ -113,7 +115,7 @@ class Plugin(): self.config[option] = False if self.config[option].lower() == 'false' else self.config[option] def init_ocr(self): - modul = __import__("captcha."+self.props['name'], fromlist=['captcha']) + modul = __import__("captcha." + self.props['name'], fromlist=['captcha']) captchaClass = getattr(modul, self.props['name']) self.ocr = captchaClass() diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py index b07ba31a4..52d731053 100644 --- a/Plugins/RapidshareCom.py +++ b/Plugins/RapidshareCom.py @@ -39,7 +39,7 @@ class RapidshareCom(Plugin): tries = 0 - while not self.start_dl: + while not self.start_dl or not pyfile.status.url: self.req.clear_cookies() @@ -148,8 +148,8 @@ class RapidshareCom(Plugin): self.start_dl = True return re.search(file_url_pattern, self.html[1]).group(1) except Exception, e: - print e, html[1] - return None + self.start_dl = False + return False #print self.html[1] #test print #raise Exception, "Error when retrieving download url" diff --git a/Plugins/YoutubeCom.py b/Plugins/YoutubeCom.py index c780345ee..7428f532d 100644 --- a/Plugins/YoutubeCom.py +++ b/Plugins/YoutubeCom.py @@ -47,7 +47,10 @@ class YoutubeCom(Plugin): file_suffix = ".flv" if self.config['high_quality']: file_suffix = ".mp4" - return re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix + name = re.search(file_name_pattern, self.html).group(1).replace("/", "") + file_suffix + + name = name.replace("&", "&") + return name def file_exists(self): """ returns True or False diff --git a/captcha/captcha.py b/captcha/captcha.py index 073637795..5fa8bfc45 100644 --- a/captcha/captcha.py +++ b/captcha/captcha.py @@ -1,4 +1,3 @@ -import thread #!/usr/bin/env python # -*- coding: utf-8 -*- # @@ -22,7 +21,6 @@ import subprocess import tempfile import Image -import ImageOps import threading class RunThread(threading.Thread): @@ -7,21 +7,30 @@ failed_file = failed_links.txt use_reconnect = False reconnect_method = reconnect_method max_downloads = 3 + [updates] search_updates = True install_updates = False + [log] file_log = True log_folder = Logs log_count = 5 #each log has 100kb + [downloadTime] #use HH:MM start = 0:00 end = 0:00 + +[reconnectTime] +startTime = 0:00 +endTime = 0:00 + [remote] port = 7272 remotePassword = pwhere + [proxy] useproxy = False proxyProtocol = http diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py index 7fa85abe1..415a8bba7 100644 --- a/module/remote/RequestHandler.py +++ b/module/remote/RequestHandler.py @@ -21,7 +21,7 @@ from RequestObject import RequestObject class RequestHandler: def __init__(self, core): self.core = core - key = hashlib.sha256("pwhere") #core.config['remotepassword'] + key = hashlib.sha256(core.config['remotepassword']) self.bf = Blowfish.new(key.hexdigest(), Blowfish.MODE_ECB) def proceed(self, data): diff --git a/module/thread_list.py b/module/thread_list.py index a359558d7..cf3df9f94 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -121,7 +121,7 @@ class Thread_List(object): def init_reconnect(self): """initialise a reonnect""" - if not self.parent.config['use_reconnect'] or self.reconnecting: + if not self.parent.config['use_reconnect'] or self.reconnecting or not self.parent.is_reconnect_time(): return False if not exists(self.parent.config['reconnect_method']): diff --git a/pyLoadCli.py b/pyLoadCli.py index 662188f7f..828ee38a3 100644 --- a/pyLoadCli.py +++ b/pyLoadCli.py @@ -1,8 +1,7 @@ -import os.path #!/usr/bin/env python # -*- coding: utf-8 -*- # -#Copyright (C) 2009 RaNaN, Willnix +#Copyright (C) 2009 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 @@ -18,7 +17,9 @@ import os.path # along with this program; if not, see <http://www.gnu.org/licenses/>. # ### +import ConfigParser import os +import os.path import sys import time @@ -71,6 +72,9 @@ class pyLoadCli: hours, seconds = divmod(seconds, 3600) minutes, seconds = divmod(seconds, 60) return "%.2i:%.2i:%.2i" % (hours, minutes, seconds) + + def format_size(self, size): + return str(size / 1024) + " MiB" def println(self, line, content): print "\033[" + str(line) + ";0H\033[2K" + str(content) + "\033[" + str((self.inputline if self.inputline > 0 else self.inputline + 1) - 1) + ";0H" @@ -99,7 +103,7 @@ class pyLoadCli: speed += download['speed'] self.println(line, cyan(download["name"])) line += 1 - self.println(line, blue("[") + yellow(z * "#" + (25-z) * " ") + blue("] ") + green(str(percent) + "%") + " Speed: " + green(str(int(download['speed'])) + " kb/s") + " Finished in: " + green(self.format_time(download['eta'])) + " ID: " + green(str(download['id']))) + self.println(line, blue("[") + yellow(z * "#" + (25-z) * " ") + blue("] ") + green(str(percent) + "%") + " Speed: " + green(str(int(download['speed'])) + " kb/s") + " Size: "+ green(self.format_size(download['size'])) + " Finished in: " + green(self.format_time(download['eta'])) + " ID: " + green(str(download['id']))) line += 1 if download["status"] == "waiting": self.println(line, cyan(download["name"])) @@ -288,9 +292,6 @@ class _GetchMacCarbon: (what, msg, when, where, mod) = Carbon.Evt.GetNextEvent(0x0008)[1] return chr(msg) - - - def blue(string): return "\033[1;34m" + string + "\033[0m" @@ -313,7 +314,17 @@ def white(string): return "\033[1;37m" + string + "\033[0m" if __name__ == "__main__": - if len(sys.argv) != 4: + + if len(sys.argv) == 2 and sys.argv[1] == "-local": + config = ConfigParser.SafeConfigParser() + config.read('config') + + address = "127.0.0.1" + port = config.get("remote", "port") + password = config.get("remote", "remotepassword") + cli = pyLoadCli(address, port, password) + + elif len(sys.argv) != 4: address = raw_input("Adress:") port = raw_input("Port:") password = raw_input("Password:") diff --git a/pyLoadCore.py b/pyLoadCore.py index 9be5fe2a9..079a40ec7 100644 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -22,15 +22,20 @@ print_test_status = False import ConfigParser import gettext +from glob import glob import logging import logging.handlers +from os import mkdir +from os import sep +from os.path import basename +from os.path import exists +from sys import argv +from sys import exit +from sys import path +from sys import stdout import time -import urllib2 -from glob import glob -from os import mkdir, sep -from os.path import exists, basename -from sys import exit, path, argv, stdout from time import sleep +import urllib2 from module.file_list import File_List from module.remote.RequestObject import RequestObject @@ -122,7 +127,7 @@ class Core(object): if not self.config['search_updates']: return False - newst_version = urllib2.urlopen("http://pyloadupdate.appspot.com/", "version="+CURRENT_VERSION).readline() + newst_version = urllib2.urlopen("http://pyloadupdate.appspot.com/", "version=" + CURRENT_VERSION).readline() if newst_version == "True": if not self.config['install_updates']: self.logger.info("New version available, please run Updater") @@ -165,6 +170,17 @@ class Core(object): start_h, start_m = self.config['start'].split(":") end_h, end_m = self.config['end'].split(":") + return self.compare_time(start_h, start_m, end_h, end_m) + + def is_reconnect_time(self): + + start_h, start_m = self.config['starttime'].split(":") + end_h, end_m = self.config['endtime'].split(":") + + return self.compare_time(start_h, start_m, end_h, end_m) + + def compare_time(self, start_h, start_m, end_h, end_m): + if (start_h, start_m) == (end_h, end_m): return True @@ -217,7 +233,7 @@ class Core(object): elif pyfile.status.type == 'waiting': print pyfile.status.filename + ": wait", self.format_time(pyfile.status.waituntil - time.time()) - def server_test(self): + def server_send_status(self): obj = RequestObject() obj.command = "update" obj.data = self.get_downloads() @@ -294,7 +310,7 @@ class Core(object): #self.thread_list.status() if print_test_status: self._test_print_status() - self.server_test() + self.server_send_status() sleep(2) if self.do_kill: self.logger.info("pyLoad quits") |