summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-16 17:29:36 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-08-16 17:29:36 +0200
commitcbe4d60d401e4f2cedc38efb375ae38b40fb0c89 (patch)
treefb8cb7befb09b55d738ab483025f627eb3f0059d
parentfixed little bugs (diff)
downloadpyload-cbe4d60d401e4f2cedc38efb375ae38b40fb0c89.tar.xz
reconnect-, uploaded.to fix
-rw-r--r--Plugins/UploadedTo.py3
-rwxr-xr-xmodule/network/Request.py21
-rw-r--r--module/thread_list.py8
-rwxr-xr-xpyLoadCli.py30
4 files changed, 42 insertions, 20 deletions
diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py
index bbfeb7f19..e65be789c 100644
--- a/Plugins/UploadedTo.py
+++ b/Plugins/UploadedTo.py
@@ -61,7 +61,8 @@ class UploadedTo(Plugin):
self.html = self.req.load(url)
try:
- wait_minutes = re.search(r"Or wait (\d+) minutes", self.html).group(1)
+ wait_minutes = re.search(r"Or wait ([\d\-]+) minutes", self.html).group(1)
+ if int(wait_minutes) < 0: wait_minutes = 1
self.time_plus_wait = time() + 60 * int(wait_minutes)
self.want_reconnect = True
except:
diff --git a/module/network/Request.py b/module/network/Request.py
index ccf12e756..0427bbe25 100755
--- a/module/network/Request.py
+++ b/module/network/Request.py
@@ -163,9 +163,12 @@ class Request:
def add_auth(self, user, pw):
- # @TODO: pycurl auth
-
- self.downloader.addheaders.append(['Authorization', 'Basic ' + base64.encodestring(user + ':' + pw)[:-1]])
+ if self.curl:
+ self.pycurl.setopt(pycurl.USERNAME, user)
+ self.pycurl.setopt(pycurl.PASSWORD, pw)
+ self.pycurl.setopt(pycurl.HTTPAUTH, pycurl.HTTPAUTH_ANY)
+ else:
+ self.downloader.addheaders.append(['Authorization', 'Basic ' + base64.encodestring(user + ':' + pw)[:-1]])
def add_cookies(self, req):
cookie_head = ""
@@ -182,9 +185,15 @@ class Request:
del self.cookies[:]
def add_proxy(self, protocol, adress):
- handler = urllib2.ProxyHandler({protocol: adress})
- self.opener.add_handler(handler)
- self.downloader.add_handler(handler)
+
+ # @TODO: pycurl proxy protocoll selection
+ if self.curl:
+ self.pycurl.setopt(pycurl.PROXY, adress.split(":")[0])
+ self.pycurl.setopt(pycurl.PROXYPORT, adress.split(":")[1])
+ else:
+ handler = urllib2.ProxyHandler({protocol: adress})
+ self.opener.add_handler(handler)
+ self.downloader.add_handler(handler)
def download(self, url, filename, get={}, post={}, ref=True, cookies=False):
diff --git a/module/thread_list.py b/module/thread_list.py
index 3691c9f5e..778e2587d 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -108,6 +108,7 @@ class Thread_List(object):
elif pyfile.status.type == "reconnected":#put it back in queque
+ pyfile.plugin.req.init_curl()
self.list.files.insert(0, pyfile)
elif pyfile.status.type == "failed":
@@ -169,8 +170,11 @@ class Thread_List(object):
reconn = subprocess.Popen(self.parent.config['reconnect_method'])
reconn.wait()
time.sleep(1)
- ip = re.match(".*Current IP Address: (.*)</body>.*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) #versuchen neue ip aus zu lesen
+ ip = ""
while ip == "": #solange versuch bis neue ip ausgelesen
- ip = re.match(".*Current IP Address: (.*)</body>.*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1)
+ try:
+ ip = re.match(".*Current IP Address: (.*)</body>.*", urllib2.urlopen("http://checkip.dyndns.org/").read()).group(1) #versuchen neue ip aus zu lesen
+ except:
+ ip = ""
time.sleep(1)
self.parent.logger.info("Reconnected, new IP: " + ip)
diff --git a/pyLoadCli.py b/pyLoadCli.py
index 5f030f927..07ac55e5e 100755
--- a/pyLoadCli.py
+++ b/pyLoadCli.py
@@ -103,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") + " Size: "+ green(self.format_size(download['size'])) + " 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"]))
@@ -315,21 +315,29 @@ def white(string):
if __name__ == "__main__":
- if len(sys.argv) == 2 and sys.argv[1] == "-local":
- config = ConfigParser.SafeConfigParser()
- config.read(os.path.abspath(__file__).replace("pyLoadCli.py","")+'config')
+ if len(sys.argv) == 2:
+
+ shortOptions = 'l'
+ longOptions = ['local']
+
+ opts, extraparams = __import__("getopt").getopt(sys.argv[1:], shortOptions, longOptions)
+ for option, params in opts:
+ if option in ("-l", "--local"):
+ config = ConfigParser.SafeConfigParser()
+ config.read(os.path.abspath(__file__).replace("pyLoadCli.py", "") + 'config')
+
+ address = "127.0.0.1"
+ port = config.get("remote", "port")
+ password = config.get("remote", "remotepassword")
- 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:")
- cli = pyLoadCli(address, port, password)
else:
- cli = pyLoadCli(* sys.argv[1:])
+ address, port, password = sys.argv[1:4]
+
+
+ cli = pyLoadCli(address, port, password)