diff options
Diffstat (limited to 'pyload/api')
-rw-r--r-- | pyload/api/DownloadApi.py | 6 | ||||
-rw-r--r-- | pyload/api/FileApi.py | 22 |
2 files changed, 22 insertions, 6 deletions
diff --git a/pyload/api/DownloadApi.py b/pyload/api/DownloadApi.py index d855dd882..a0b7c9f96 100644 --- a/pyload/api/DownloadApi.py +++ b/pyload/api/DownloadApi.py @@ -37,12 +37,12 @@ class DownloadApi(ApiComponent): @RequirePerm(Permission.Add) - def addPackage(self, name, links, password=""): + def addPackage(self, name, links, password="", paused=False): """Convenient method to add a package to the top-level and for adding links. :return: package id """ - return self.addPackageChild(name, links, password, -1, False) + return self.addPackageChild(name, links, password, -1, paused) @RequirePerm(Permission.Add) def addPackageP(self, name, links, password, paused): @@ -61,7 +61,7 @@ class DownloadApi(ApiComponent): else: folder = "" - pid = self.createPackage(name, folder, root, password) + pid = self.createPackage(name, folder, root, password, paused=paused) self.addLinks(pid, links) return pid diff --git a/pyload/api/FileApi.py b/pyload/api/FileApi.py index 5bb8e21e7..d8ee26ac2 100644 --- a/pyload/api/FileApi.py +++ b/pyload/api/FileApi.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -from pyload.Api import Api, RequirePerm, Permission, DownloadState, PackageDoesNotExist, FileDoesNotExist +from pyload.Api import Api, RequirePerm, Permission, DownloadState, PackageStatus as PS, PackageDoesNotExist, FileDoesNotExist from pyload.utils import uniqify from ApiComponent import ApiComponent @@ -114,8 +114,24 @@ class FileApi(ApiComponent): self.core.files.save() @RequirePerm(Permission.Modify) - def setPackageFolder(self, pid, path): - pass + def setPackagePaused(self, pid, paused): + """ Sets the paused state of a package if possible. + + :param pid: package id + :param paused: desired paused state of the package + :return the new package status + """ + p = self.core.files.getPackage(pid) + if not p: raise PackageDoesNotExist(pid) + + if p.status == PS.Ok and paused: + p.status = PS.Paused + elif p.status == PS.Paused and not paused: + p.status = PS.Ok + + p.sync() + + return p.status @RequirePerm(Permission.Modify) def movePackage(self, pid, root): |