diff options
| author | 2010-01-22 19:21:59 +0100 | |
|---|---|---|
| committer | 2010-01-22 19:21:59 +0100 | |
| commit | f0914124436b8f66d296ef0d3d0e0f289f5a1aa6 (patch) | |
| tree | c9d9243e06cb5bdb685b7c6338ccaf4e82ec9104 /module | |
| parent | some new CLi functions (diff) | |
| download | pyload-f0914124436b8f66d296ef0d3d0e0f289f5a1aa6.tar.xz | |
some final tweaks
Diffstat (limited to 'module')
| -rw-r--r-- | module/file_list.py | 68 | ||||
| -rw-r--r-- | module/thread_list.py | 11 | 
2 files changed, 27 insertions, 52 deletions
| diff --git a/module/file_list.py b/module/file_list.py index 2785afdb2..e87fec3dd 100644 --- a/module/file_list.py +++ b/module/file_list.py @@ -28,6 +28,7 @@ from download_thread import Status  import cPickle  import re  import module.Plugin +from operator import concat  from os import sep  from time import sleep @@ -95,24 +96,10 @@ class File_List(object):              "packages": [],              "collector": []          } -        packages = [] -        queue = [] -        collector = [] -        for p in self.data["packages"]: -            pd = PyLoadPackageData() -            pd.set(p) -            packages.append(pd) -        for p in self.data["queue"]: -            pd = PyLoadPackageData() -            pd.set(p) -            queue.append(pd) -        for f in self.data["collector"]: -            fd = PyLoadFileData() -            fd.set(f) -            collector.append(fd) -        pdata["packages"] = packages -        pdata["queue"] = queue -        pdata["collector"] = collector + +        pdata["packages"] = map(PyLoadPackageData().set, self.data["packages"]) +        pdata["queue"] = map(PyLoadPackageData().set, self.data["queue"]) +        pdata["collector"] = map(PyLoadFileData().set, self.data["collector"])          output = open('module' + sep + 'links.pkl', 'wb')          cPickle.dump(pdata, output, -1) @@ -122,37 +109,26 @@ class File_List(object):      def queueEmpty(self):          return (self.data["queue"] == []) -    def getDownloadList(self): +    def getDownloadList(self, occ):          """ -            for thread_list only +            for thread_list only, returns all elements that are suitable for downloadthread          """          files = [] -        for pypack in self.data["queue"]: -            for pyfile in pypack.files: -                if pyfile.status.type == None and pyfile.plugin.props['type'] == "container" and not pyfile.active: -                    files.append(pyfile) -        for pypack in self.data["packages"]: -            for pyfile in pypack.files: -                if pyfile.status.type == None and pyfile.plugin.props['type'] == "container" and pyfile.plugin.decryptNow and not pyfile.active: -                    files.append(pyfile) -        for pypack in self.data["queue"]: -            for pyfile in pypack.files: -                if pyfile in files: -                    continue -                if (pyfile.status.type == "reconnected" or pyfile.status.type == None) and not pyfile.active: -                    files.append(pyfile) -        return files +        files += [[x for x in p.files if x.status.type == None and x.plugin.props['type'] == "container" and not x.active] for p in self.data["queue"] + self.data["packages"]] +        files += [[x for x in p.files if (x.status.type == None or x.status.type == "reconnected") and not x.active and not x.modul.__name__ in occ] for p in self.data["queue"]] + +        return reduce(concat, files, [])      def getAllFiles(self):          files = []          for pypack in self.data["queue"] + self.data["packages"]: -            for pyfile in pypack.files: -                files.append(pyfile) +            files += pypack.files          return files      def countDownloads(self): -        return len(self.getDownloadList()) +        """ simply return len of all files in all packages(which have no type) in queue and collector""" +        return len(reduce(concat, [[x for x in p.files if x.status.type == None] for p in self.data["queue"] + self.data["packages"]], []))      def getFileInfo(self, id):          try: @@ -465,7 +441,7 @@ class PyLoadFileData():          self.filename = None          self.status_type = None          self.status_url = None -     +      def set(self, pyfile):          self.id = pyfile.id          self.url = pyfile.url @@ -476,7 +452,9 @@ class PyLoadFileData():          self.status_url = pyfile.status.url          self.status_filename = pyfile.status.filename          self.status_error = pyfile.status.error -     + +        return self +      def get(self, pyfile):          pyfile.id = self.id          pyfile.url = self.url @@ -495,14 +473,12 @@ class PyLoadPackageData():      def __init__(self):          self.data = None          self.files = [] -     +      def set(self, pypack):          self.data = pypack.data -        for pyfile in pypack.files: -            fdata = PyLoadFileData() -            fdata.set(pyfile) -            self.files.append(fdata) -     +        self.files = map(PyLoadFileData().set, pypack.files) +        return self +              def get(self, pypack, fl):          pypack.data = self.data          for fdata in self.files: diff --git a/module/thread_list.py b/module/thread_list.py index c8580fece..9211c7c2e 100644 --- a/module/thread_list.py +++ b/module/thread_list.py @@ -40,7 +40,8 @@ class Thread_List(object):          self.reconnecting = False          self.select_thread() -        self.speedManager = self.SpeedManager(self) +        if self.parent.config['general']['download_speed_limit'] != 0: +            self.speedManager = self.SpeedManager(self)      def create_thread(self):          """ creates thread for Py_Load_File and append thread to self.threads @@ -69,12 +70,10 @@ class Thread_List(object):          self.lock.acquire()          pyfile = None -        for f in self.list.getDownloadList(): -            if not f.modul.__name__ in self.occ_plugins: -                pyfile = f -                break +        pyfiles = self.list.getDownloadList(self.occ_plugins) -        if pyfile: +        if pyfiles: +            pyfile = pyfiles[0]              self.py_downloading.append(pyfile)              self.parent.hookManager.downloadStarts(pyfile)              if not pyfile.plugin.multi_dl: | 
