summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Plugins/RapidshareCom.py2
-rw-r--r--module/file_list.py30
-rw-r--r--module/remote/RequestHandler.py6
-rw-r--r--module/remote/RequestObject.py1
-rw-r--r--pyLoadCli.py41
-rw-r--r--pyLoadCore.py8
6 files changed, 72 insertions, 16 deletions
diff --git a/Plugins/RapidshareCom.py b/Plugins/RapidshareCom.py
index 20423197b..4eb7bf93d 100644
--- a/Plugins/RapidshareCom.py
+++ b/Plugins/RapidshareCom.py
@@ -130,7 +130,7 @@ class RapidshareCom(Plugin):
file_url_pattern = r".*name=\"dlf\" action=\"(.*)\" method=.*"
return re.search(file_url_pattern, self.html[1]).group(1)
else:
- return False
+ raise Exception, "Error when retrieving download url"
def get_file_name(self):
if self.html[0] == None:
diff --git a/module/file_list.py b/module/file_list.py
index d2a634645..8f32ef474 100644
--- a/module/file_list.py
+++ b/module/file_list.py
@@ -18,7 +18,7 @@
#
###
-LIST_VERSION = 1
+LIST_VERSION = 2
import cPickle
from Py_Load_File import PyLoadFile
@@ -28,7 +28,7 @@ class File_List(object):
def __init__(self, core):
self.core = core
self.files = []
- self.data = {'version': LIST_VERSION}
+ self.data = {'version': LIST_VERSION, 'order': []}
self.load()
def new_pyfile(self, url):
@@ -46,6 +46,7 @@ class File_List(object):
new_file = self.new_pyfile(url)
self.files.append(new_file)
self.data[new_file.id] = Data(url)
+ self.data['order'].append(new_file.id)
def extend(self, urls):
for url in urls:
@@ -56,8 +57,24 @@ class File_List(object):
if pyfile in self.files:
self.files.remove(pyfile)
+ self.data['order'].remove(pyfile.id)
del self.data[pyfile.id]
+ def remove_id(self, pyid):
+ pyid = int(pyid)
+ found = False
+ for pyfile in self.files:
+ if pyfile.id == pyid:
+ self.files.remove(pyfile)
+ found = True
+ break
+
+ if not found:
+ return False
+
+ self.data['order'].remove(pyid)
+ del self.data[pyid]
+
def get_id(self):
"""return a free id"""
id = 1
@@ -77,14 +94,13 @@ class File_List(object):
pkl_file = open('links.pkl', 'rb')
obj = cPickle.load(pkl_file)
except:
- obj = {'version': LIST_VERSION}
+ obj = {'version': LIST_VERSION, 'order': []}
if obj['version'] < LIST_VERSION:
- obj = {'version': LIST_VERSION}
+ obj = {'version': LIST_VERSION, 'order': []}
- for key, value in obj.iteritems():
- if key != 'version':
- self.append(value.url)
+ for i in obj['order']:
+ self.append(obj[i].url)
self.core.logger.info("Links loaded: "+ str(int(len(obj) - 1)))
diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py
index 5d39623c3..7fa85abe1 100644
--- a/module/remote/RequestHandler.py
+++ b/module/remote/RequestHandler.py
@@ -29,9 +29,9 @@ class RequestHandler:
if obj.command == "exec":
func = getattr(self.core, obj.function)
- obj.response = func( * obj.args)
+ obj.data = func( * obj.args)
else:
- obj.response = "error happend"
+ obj.data = "error happend"
return self.encrypt(obj)
@@ -61,4 +61,4 @@ class RequestHandler:
enc_str = self.bf.encrypt(enc_str)
enc_str = base64.standard_b64encode(enc_str)
- return enc_str + "\n" \ No newline at end of file
+ return enc_str + "\n"
diff --git a/module/remote/RequestObject.py b/module/remote/RequestObject.py
index 0141b5e1d..54ea837a6 100644
--- a/module/remote/RequestObject.py
+++ b/module/remote/RequestObject.py
@@ -15,5 +15,4 @@ class RequestObject(object):
self.command = None
self.function = ""
self.args = []
- self.response = None
self.data = None
diff --git a/pyLoadCli.py b/pyLoadCli.py
index 759298409..f77fa19f0 100644
--- a/pyLoadCli.py
+++ b/pyLoadCli.py
@@ -28,7 +28,7 @@ class pyLoadCli:
self.thread = SocketThread(adress, int(port), pw, self)
self.getch = _Getch()
self.input = ""
- self.pos = [0]
+ self.pos = [0,0]
self.inputline = 0
self.menuline = 0
@@ -38,6 +38,9 @@ class pyLoadCli:
self.println(1, blue("py") + yellow("Load") + white(" Command Line Interface"))
self.println(2, "")
+ self.file_list = {}
+ self.thread.push_exec("get_links")
+
self.start()
def start(self):
@@ -73,6 +76,9 @@ class pyLoadCli:
def print_input(self):
self.println(self.inputline, white(" Input: ") + self.input)
self.println(self.inputline+1, "")
+ self.println(self.inputline+2, "")
+ self.println(self.inputline+3, "")
+ self.println(self.inputline+4, "")
def data_arrived(self, obj):
"""Handle incoming data"""
@@ -106,6 +112,8 @@ class pyLoadCli:
self.menuline = line
self.build_menu()
+ elif obj.command == "file_list" or obj.function == "get_links":
+ self.file_list = obj.data
def build_menu(self):
line = self.menuline
@@ -126,6 +134,7 @@ class pyLoadCli:
line += 1
self.println(line, "")
line += 1
+ self.println(line, "")
elif self.pos[0] == 1:#add links
self.println(line, "Parse the links you want to add.")
line += 1
@@ -141,17 +150,33 @@ class pyLoadCli:
line += 1
self.println(line, mag("0.") + " back to main menu")
line += 1
+ self.println(line, "")
elif self.pos[0] == 2:#remove links
- pass
+ self.println(line, "Type the number of the link you want to delete.")
+ line += 1
+ i = 0
+ for id in range(self.pos[1],self.pos[1]+5):
+ if id < 0 or id >= len(self.file_list['order']):
+ continue
+ item = self.file_list['order'][id]
+ self.println(line, mag(str(item)) + ": " + self.file_list[item].url)
+ line += 1
+ i += 1
+ for x in range(5-i):
+ self.println(line,"")
+ line += 1
- self.println(line, "")
+ self.println(line, mag("p") +" - previous" + " | " + mag("n") + " - next")
+ line += 1
+ self.println(line, mag("0.") + " back to main menu")
+
self.inputline = line + 1
self.print_input()
def handle_input(self):
inp = self.input
if inp == "0":
- self.pos = [0]
+ self.pos = [0,0]
self.build_menu()
return True
@@ -161,6 +186,7 @@ class pyLoadCli:
self.pos[0] = 1
elif inp == "2":
self.pos[0] = 2
+ self.pos[1] = 0
elif inp == "3":
self.pos[0] = 3
elif inp == "4":
@@ -172,6 +198,13 @@ class pyLoadCli:
if inp[:7] == "http://":
self.thread.push_exec("add_links", [(inp, None)])
self.links_added += 1
+ elif self.pos[0] == 2:
+ if inp == "p":
+ self.pos[1] -= 5
+ elif inp == "n":
+ self.pos[1] += 5
+ else:
+ self.thread.push_exec("remove_links", [[inp]])
self.build_menu()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 3a46aea21..a9364d98a 100644
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -250,6 +250,14 @@ class Core(object):
self.file_list.extend(links)
self.file_list.save()
+ def remove_links(self, ids):
+ for id in ids:
+ self.file_list.remove_id(id)
+ self.file_list.save()
+
+ def get_links(self):
+ return self.file_list.data
+
if __name__ == "__main__":
testLoader = Core()
testLoader.start()