summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar spoob <spoob@gmx.de> 2009-06-14 23:38:15 +0200
committerGravatar spoob <spoob@gmx.de> 2009-06-14 23:38:15 +0200
commitf01b73235fb54fd5a26aaddca8bf35be740eef0f (patch)
tree554b9a819b0fe080d2c426dca4eaf681c594df59
parentMerge with 80e6af340ebfdd0c054e6d2016802698a4730b1d (diff)
downloadpyload-f01b73235fb54fd5a26aaddca8bf35be740eef0f.tar.xz
many little changes
-rw-r--r--Plugins/UploadedTo.py9
-rw-r--r--module/download_thread.py9
-rw-r--r--pyLoadCli.py34
-rw-r--r--pyLoadCore.py2
4 files changed, 41 insertions, 13 deletions
diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py
index 8df8db110..f1e7d8ae3 100644
--- a/Plugins/UploadedTo.py
+++ b/Plugins/UploadedTo.py
@@ -51,10 +51,11 @@ class UploadedTo(Plugin):
if self.html == None:
self.download_html()
if not self.want_reconnect:
- file_name = re.search(r"<td><b>\s+(.+)\s", self.html).group(1) + re.search(r"</td><td>(\..+)</td></tr>", self.html).group(1)
-
- #file_name_pattern = r"<title>\s*(.*?)\s+\.\.\."
- return file_name
+ file_name = re.search(r"<td><b>\s+(.+)\s", self.html).group(1)
+ file_suffix = re.search(r"</td><td>(\..+)</td></tr>", self.html)
+ if not file_suffix:
+ return file_name
+ return file_name + file_suffix.group(1)
else:
return self.parent.url
diff --git a/module/download_thread.py b/module/download_thread.py
index bb32030a7..a2318038a 100644
--- a/module/download_thread.py
+++ b/module/download_thread.py
@@ -32,7 +32,7 @@ class Status(object):
self.filename = None
self.url = None
self.exists = False
- self.waituntil = None
+ self.waituntil = 0
self.want_reconnect = False
def get_ETA(self):
@@ -43,7 +43,10 @@ class Status(object):
return self.pyfile.plugin.req.kB_left()
def size(self):
return self.pyfile.plugin.req.dl_size / 1024
-
+ def percent(self):
+ if not self.kB_left() == 0 and not self.size() == 0:
+ return ((self.size()-self.kB_left())*100)/self.size()
+ return 0
class Download_Thread(threading.Thread):
def __init__(self, parent):
@@ -98,4 +101,4 @@ class Download_Thread(threading.Thread):
#startet downloader
#urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status)
- #self.shutdown = True \ No newline at end of file
+ #self.shutdown = True
diff --git a/pyLoadCli.py b/pyLoadCli.py
index d5c2d9f60..0a68cfc45 100644
--- a/pyLoadCli.py
+++ b/pyLoadCli.py
@@ -33,19 +33,41 @@ class pyLoadCli:
inp = raw_input()
print inp[-1]
+ def format_time(self, seconds):
+ seconds = int(seconds)
+ if seconds > 60:
+ hours, seconds = divmod(seconds, 3600)
+ minutes, seconds = divmod(seconds, 60)
+ return "%.2i:%.2i:%.2i" % (hours, minutes, seconds)
+ return _("%i seconds") % seconds
+
def data_arrived(self, obj):
"""Handle incoming data"""
if obj.command == "update":
- print str(obj.data)
-
+ #print obj.data
+ print "\033[2;0H%s Downloads" % (len(obj.data))
+ line = 2
+ for download in obj.data:
+ if download["status"] == "downloading":
+ percent = download["percent"]
+ z = percent/2
+ print "\033["+str(line)+";0H[" + z*"#" + (50-z)*" " + "] " + str(percent) + "% of " + download["name"]
+ line += 1
+ line += 2
+ print("\033[" + str(line) + ";0HMeldungen:")
+ for download in obj.data:
+ if download["status"] == "waiting":
+ print "\033["+str(line)+";0HWarte %s auf Downlod Ticket für %s" % (self.format_time(download["wait_until"]), download["name"])
+ line += 1
if __name__ == "__main__":
if len(sys.argv) != 4:
address = raw_input("Adress:")
port = raw_input("Port:")
- pw = raw_input("Password:")
- cli = pyLoadCli(adress,port,pw)
+ password = raw_input("Password:")
+ #address = "localhost"
+ #port = "7272"
+ #password = "pwhere"
+ cli = pyLoadCli(address,port,password)
else:
cli = pyLoadCli(*sys.argv[1:])
-
-
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 0ae1fb938..d44f58d52 100644
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -183,7 +183,9 @@ class Core(object):
download['eta'] = pyfile.status.get_ETA()
download['kbleft'] = pyfile.status.kB_left()
download['size'] = pyfile.status.size()
+ download['percent'] = pyfile.status.percent()
download['status'] = pyfile.status.type
+ download['wait_until'] = pyfile.status.waituntil - time.time()
list.append(download)
return list