diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-17 10:39:54 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-06-17 10:39:54 +0200 |
commit | 34a1ada97b5a7e5e353491ba0663bb6e27d3c57a (patch) | |
tree | 9d18e056fd22cbc1f3912a019dc3e20b80b398ec /module/file_list.py | |
parent | new file list modul (diff) | |
download | pyload-34a1ada97b5a7e5e353491ba0663bb6e27d3c57a.tar.xz |
file_list saves links, links.txt only for link dumping
Diffstat (limited to 'module/file_list.py')
-rw-r--r-- | module/file_list.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/module/file_list.py b/module/file_list.py index c9a96635f..fe4080807 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -22,31 +22,47 @@ LIST_VERSION = 1 import cPickle from Py_Load_File import PyLoadFile - + class File_List(object): def __init__(self, core): self.core = core self.files = [] self.data = {'version': LIST_VERSION} - self.id = 0 - #self.load() + self.load() def new_pyfile(self, url): url = url.replace("\n", "") pyfile = PyLoadFile(self.core, url) pyfile.download_folder = self.core.config['download_folder'] - pyfile.id = self.id - self.id += 1 + pyfile.id = self.get_id() return pyfile def append(self, url): - self.files.append(self.new_pyfile(url)) + new_file = self.new_pyfile(url) + self.files.append(new_file) + self.data[new_file.id] = Data(url) def extend(self, urls): for url in urls: self.append(url) + def remove(self, pyfile): + + if pyfile in self.files: + self.files.remove(pyfile) + + del self.data[pyfile.id] + + def get_id(self): + """return a free id""" + id = 1 + while id in self.data.keys(): + id += 1 + + return id + + def save(self): output = open('links.pkl', 'wb') cPickle.dump(self.data, output, -1) @@ -61,6 +77,13 @@ class File_List(object): if obj['version'] < LIST_VERSION: obj = {'version': LIST_VERSION} - self.data = obj + for key, value in obj.iteritems(): + if key != 'version': + self.append(value.url) - + self.core.logger.info("Links loaded: "+ str(int(len(obj) - 1))) + + +class Data(): + def __init__(self, url): + self.url = url
\ No newline at end of file |