summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-18 21:28:39 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2010-10-18 21:28:39 +0200
commitf34aec9d70f48200c0e46db476dff9ee06357707 (patch)
tree1b272c8dd71df1a6297a4882324f266b23ed65ff
parentclosed #158 (diff)
downloadpyload-f34aec9d70f48200c0e46db476dff9ee06357707.tar.xz
new ip retrieve
-rw-r--r--module/ThreadManager.py28
-rw-r--r--module/plugins/accounts/NetloadIn.py2
2 files changed, 21 insertions, 9 deletions
diff --git a/module/ThreadManager.py b/module/ThreadManager.py
index f46f816e4..eba23f28c 100644
--- a/module/ThreadManager.py
+++ b/module/ThreadManager.py
@@ -24,6 +24,7 @@ from subprocess import Popen
from threading import Event
from time import sleep
from traceback import print_exc
+from random import choice
import pycurl
import PluginThread
@@ -126,7 +127,7 @@ class ThreadManager:
while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0:
sleep(0.25)
- ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1)
+ ip = self.getIP()
self.core.hookManager.beforeReconnecting(ip)
@@ -144,19 +145,30 @@ class ThreadManager:
reconn.wait()
sleep(1)
- ip = ""
- while ip == "":
- try:
- ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) #get new ip
- except:
- ip = ""
- sleep(1)
+ ip = self.getIP()
self.core.hookManager.afterReconnecting(ip)
self.log.info(_("Reconnected, new IP: %s") % ip)
self.reconnecting.clear()
+ def getIP(self):
+ """retrieve current ip"""
+ services = [("http://www.whatismyip.com/automation/n09230945.asp", "(\S+)"),
+ ("http://checkip.dyndns.org/",".*Current IP Address: (\S+)</body>.*")]
+
+ ip = ""
+ while not ip:
+ try:
+ sv = choice(services)
+ ip = getURL(sv[0])
+ ip = re.match(sv[1], ip).group(1)
+ except:
+ ip = ""
+ sleep(1)
+
+ return ip
+
#----------------------------------------------------------------------
def checkThreadCount(self):
"""checks if there are need for increasing or reducing thread count"""
diff --git a/module/plugins/accounts/NetloadIn.py b/module/plugins/accounts/NetloadIn.py
index 957435b46..4f5b08689 100644
--- a/module/plugins/accounts/NetloadIn.py
+++ b/module/plugins/accounts/NetloadIn.py
@@ -36,7 +36,7 @@ class NetloadIn(Account):
validuntil = time() + int(left.group(1)) * 24 * 60 * 60 + int(left.group(2)) * 60 * 60
return {"validuntil": validuntil, "trafficleft": -1}
- def login(self, user, req):
+ def login(self, user, data,req):
page = req.load("http://netload.in/index.php", None, { "txtuser" : user, "txtpass" : data['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True)
if "password or it might be invalid!" in page:
self.wrongPassword()