diff options
| author | 2009-06-15 20:49:48 +0200 | |
|---|---|---|
| committer | 2009-06-15 20:49:48 +0200 | |
| commit | 2d4fa507b41979a3c741170871720f5038a5b883 (patch) | |
| tree | 7d4007449a167e979d250e118fd7bc2f487c04bd | |
| parent | Added Stealth.to Container Plugin (diff) | |
| download | pyload-2d4fa507b41979a3c741170871720f5038a5b883.tar.xz | |
new file list class
| -rw-r--r-- | module/Py_Load_File.py | 3 | ||||
| -rw-r--r-- | module/file_list.py | 63 | ||||
| -rw-r--r-- | module/thread_list.py | 14 | ||||
| -rw-r--r-- | pyLoadCore.py | 5 | 
4 files changed, 76 insertions, 9 deletions
| diff --git a/module/Py_Load_File.py b/module/Py_Load_File.py index cbbc5ab6b..2bc6d4965 100644 --- a/module/Py_Load_File.py +++ b/module/Py_Load_File.py @@ -33,10 +33,11 @@ class PyLoadFile:          if self.parent.config['useproxy']:              self.plugin.req.add_proxy(self.parent.config['proxyprotocol'], self.parent.config['proxyadress']) +        self.plugin.want_reconnect = False          self.status.exists = self.plugin.file_exists()          if self.status.exists:              self.status.filename = self.plugin.get_file_name()              self.status.waituntil = self.plugin.time_plus_wait              self.status.url = self.plugin.get_file_url() -            self.status.want_reconnect = self.plugin.want_reconnect
\ No newline at end of file +            self.status.want_reconnect = self.plugin.want_reconnect diff --git a/module/file_list.py b/module/file_list.py new file mode 100644 index 000000000..932fb0b13 --- /dev/null +++ b/module/file_list.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +#Copyright (C) 2009 RaNaN +# +#This program is free software; you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation; either version 3 of the License, +#or (at your option) any later version. +# +#This program is distributed in the hope that it will be useful, +#but WITHOUT ANY WARRANTY; without even the implied warranty of +#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +#See the GNU General Public License for more details. +# +#You should have received a copy of the GNU General Public License +# along with this program; if not, see <http://www.gnu.org/licenses/>. +# +### + +LIST_VERSION = 1 + +import cPickle +from Py_Load_File import PyLoadFile + +class File_List(object): +    def __init__(self): +        self.version = LIST_VERSION +        self.files = [] +        self.id = 0 + +    def set_core(self, core): +        self.core = core + +    def new_pyfile(self) +        pyfile = PyLoadFile(self, url) +        pyfile.download_folder = self.core.config['download_folder'] +        pyfile.id = self.id +        self.id += 1 + +        return pyfile + +    def append(self, url): +        self.links.append(url) + +    def save(self): +        output = open('links.pkl', 'wb') +        cPickle.dump(self, output, -1) + + +def load(core): +    try: +        pkl_file = open('links.pkl', 'rb') +        obj = cPickle.load(pkl_file) +    except: +        obj = File_List() + +    if obj.version < LIST_VERSION: +        obj = File_List() + +    obj.set_core(core) + +    return obj diff --git a/module/thread_list.py b/module/thread_list.py index 615c39243..a7e92b77d 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -1,7 +1,7 @@  #!/usr/bin/env python  # -*- coding: utf-8 -*-  # -#Copyright (C) 2009 sp00b, sebnapi +#Copyright (C) 2009 sp00b, sebnapi, RaNaN  #  #This program is free software; you can redistribute it and/or modify  #it under the terms of the GNU General Public License as published by @@ -41,13 +41,14 @@ class Thread_List(object):          self.pause = False          self.reconnecting = False +        self.select_thread() +      def create_thread(self):          """ creates thread for Py_Load_File and append thread to self.threads          """ -        if self.py_load_files: -            thread = Download_Thread(self) -            self.threads.append(thread) -            return True +        thread = Download_Thread(self) +        self.threads.append(thread) +        return True      def get_loaded_urls(self):          loaded_urls = [] @@ -130,9 +131,6 @@ class Thread_List(object):          self.lock.release()          return True -    def extend_py_load_files(self): -        pass -      def select_thread(self):          """ select a thread          """ diff --git a/pyLoadCore.py b/pyLoadCore.py index d44f58d52..f85f5b447 100644 --- a/pyLoadCore.py +++ b/pyLoadCore.py @@ -39,6 +39,8 @@ from module.Py_Load_File import PyLoadFile  from module.remote.RequestObject import RequestObject  from module.remote.SocketServer import ServerThread  from module.thread_list import Thread_List +from module.file_list import File_List +from module import file_list  class Core(object):      """ pyLoad main @@ -66,6 +68,8 @@ class Core(object):          self.thread_list = Thread_List(self) +        self.file_list = file_list.load() +            path.append(self.config['plugin_folder'])          self.create_plugin_index() @@ -232,6 +236,7 @@ class Core(object):          print _("Server Mode")          self.server = ServerThread(self)          self.server.start() +          if __name__ == "__main__":      testLoader = Core() | 
