diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-18 17:01:17 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-08-18 17:01:17 +0200 |
commit | 9a6ea22616cf3cc67e292c908521b79764400faf (patch) | |
tree | 1924843f28d992490d867d0557da90dfb1da6404 /pyload/remote | |
parent | fixed login (diff) | |
download | pyload-9a6ea22616cf3cc67e292c908521b79764400faf.tar.xz |
new linkgrabber
Diffstat (limited to 'pyload/remote')
-rw-r--r-- | pyload/remote/apitypes.py | 27 | ||||
-rw-r--r-- | pyload/remote/apitypes_debug.py | 17 | ||||
-rw-r--r-- | pyload/remote/pyload.thrift | 29 | ||||
-rw-r--r-- | pyload/remote/wsbackend/AsyncHandler.py | 13 |
4 files changed, 30 insertions, 56 deletions
diff --git a/pyload/remote/apitypes.py b/pyload/remote/apitypes.py index 385f4ca07..d186717d4 100644 --- a/pyload/remote/apitypes.py +++ b/pyload/remote/apitypes.py @@ -241,15 +241,14 @@ class InvalidConfigSection(ExceptionObject): self.section = section class LinkStatus(BaseObject): - __slots__ = ['url', 'name', 'plugin', 'size', 'status', 'packagename'] + __slots__ = ['url', 'name', 'plugin', 'size', 'status'] - def __init__(self, url=None, name=None, plugin=None, size=None, status=None, packagename=None): + def __init__(self, url=None, name=None, plugin=None, size=None, status=None): self.url = url self.name = name self.plugin = plugin self.size = size self.status = status - self.packagename = packagename class OnlineCheck(BaseObject): __slots__ = ['rid', 'data'] @@ -368,8 +367,6 @@ class UserDoesNotExists(ExceptionObject): self.user = user class Iface(object): - def addFromCollector(self, name, paused): - pass def addLinks(self, pid, links): pass def addLocalFile(self, pid, name, path): @@ -380,26 +377,20 @@ class Iface(object): pass def addPackageP(self, name, links, password, paused): pass - def addToCollector(self, links): - pass def addUser(self, username, password): pass def callAddon(self, plugin, func, arguments): pass def callAddonHandler(self, plugin, func, pid_or_fid): pass - def checkOnlineStatus(self, urls): + def checkContainer(self, filename, data): pass - def checkOnlineStatusContainer(self, urls, filename, data): + def checkHTML(self, html, url): pass - def checkURLs(self, urls): + def checkLinks(self, links): pass def createPackage(self, name, folder, root, password, site, comment, paused): pass - def deleteCollLink(self, url): - pass - def deleteCollPack(self, name): - pass def deleteConfig(self, plugin): pass def deleteFiles(self, fids): @@ -412,8 +403,6 @@ class Iface(object): pass def freeSpace(self): pass - def generateAndAddPackages(self, links, paused): - pass def generateDownloadLink(self, fid, timeout): pass def generatePackages(self, links): @@ -432,8 +421,6 @@ class Iface(object): pass def getAvailablePlugins(self): pass - def getCollector(self): - pass def getConfig(self): pass def getConfigValue(self, section, option): @@ -484,7 +471,7 @@ class Iface(object): pass def orderPackage(self, pids, position): pass - def parseURLs(self, html, url): + def parseLinks(self, links): pass def pauseServer(self): pass @@ -498,8 +485,6 @@ class Iface(object): pass def removeUser(self, uid): pass - def renameCollPack(self, name, new_name): - pass def restart(self): pass def restartFailed(self): diff --git a/pyload/remote/apitypes_debug.py b/pyload/remote/apitypes_debug.py index 177029054..1c34b702e 100644 --- a/pyload/remote/apitypes_debug.py +++ b/pyload/remote/apitypes_debug.py @@ -32,7 +32,7 @@ classes = { 'Input' : [int, (None, basestring), (None, basestring)], 'InteractionTask' : [int, int, Input, basestring, basestring, basestring], 'InvalidConfigSection' : [basestring], - 'LinkStatus' : [basestring, basestring, basestring, int, int, basestring], + 'LinkStatus' : [basestring, basestring, basestring, int, int], 'OnlineCheck' : [int, (dict, basestring, LinkStatus)], 'PackageDoesNotExists' : [int], 'PackageInfo' : [int, basestring, basestring, int, int, basestring, basestring, basestring, int, (list, basestring), int, bool, int, PackageStats, (list, int), (list, int)], @@ -47,29 +47,24 @@ classes = { } methods = { - 'addFromCollector': int, 'addLinks': None, 'addLocalFile': None, 'addPackage': int, 'addPackageChild': int, 'addPackageP': int, - 'addToCollector': None, 'addUser': UserData, 'callAddon': None, 'callAddonHandler': None, - 'checkOnlineStatus': OnlineCheck, - 'checkOnlineStatusContainer': OnlineCheck, - 'checkURLs': (dict, basestring, list), + 'checkContainer': OnlineCheck, + 'checkHTML': OnlineCheck, + 'checkLinks': OnlineCheck, 'createPackage': int, - 'deleteCollLink': None, - 'deleteCollPack': None, 'deleteConfig': None, 'deleteFiles': None, 'deletePackages': None, 'findFiles': TreeCollection, 'findPackages': TreeCollection, 'freeSpace': int, - 'generateAndAddPackages': (list, int), 'generateDownloadLink': basestring, 'generatePackages': (dict, basestring, list), 'getAccountInfo': AccountInfo, @@ -79,7 +74,6 @@ methods = { 'getAllFiles': TreeCollection, 'getAllUserData': (dict, int, UserData), 'getAvailablePlugins': (list, ConfigInfo), - 'getCollector': (list, LinkStatus), 'getConfig': (dict, basestring, ConfigHolder), 'getConfigValue': basestring, 'getCoreConfig': (list, ConfigInfo), @@ -105,14 +99,13 @@ methods = { 'movePackage': bool, 'orderFiles': None, 'orderPackage': None, - 'parseURLs': (dict, basestring, list), + 'parseLinks': (dict, basestring, list), 'pauseServer': None, 'pollResults': OnlineCheck, 'quit': None, 'recheckPackage': None, 'removeAccount': None, 'removeUser': None, - 'renameCollPack': None, 'restart': None, 'restartFailed': None, 'restartFile': None, diff --git a/pyload/remote/pyload.thrift b/pyload/remote/pyload.thrift index 702bd9b94..d41b6d10b 100644 --- a/pyload/remote/pyload.thrift +++ b/pyload/remote/pyload.thrift @@ -193,14 +193,13 @@ struct TreeCollection { 3: map<PackageID, PackageInfo> packages } -// general info about link, used for collector and online results +// general info about link, used for online results struct LinkStatus { 1: string url, 2: string name, 3: PluginName plugin, 4: ByteCount size, // size <= 0 : unknown 5: DownloadStatus status, - 6: string packagename, } struct ServerStatus { @@ -299,7 +298,7 @@ struct AccountInfo { struct OnlineCheck { 1: ResultID rid, // -1 -> nothing more to get - 2: map<string, LinkStatus> data, // url to result + 2: map<string, LinkStatus> data, // package name to result } // exceptions @@ -383,12 +382,12 @@ service Pyload { // Download Preparing /////////////////////// - map<PluginName, LinkList> checkURLs(1: LinkList urls), - map<PluginName, LinkList> parseURLs(1: string html, 2: string url), + map<PluginName, LinkList> parseLinks(1: LinkList links), // parses results and generates packages - OnlineCheck checkOnlineStatus(1: LinkList urls), - OnlineCheck checkOnlineStatusContainer(1: LinkList urls, 2: string filename, 3: binary data) + OnlineCheck checkLinks(1: LinkList links), + OnlineCheck checkContainer(1: string filename, 2: binary data), + OnlineCheck checkHTML(1: string html, 2: string url), // poll results from previously started online check OnlineCheck pollResults(1: ResultID rid), @@ -400,8 +399,6 @@ service Pyload { // Download /////////////////////// - list<PackageID> generateAndAddPackages(1: LinkList links, 2: bool paused), - PackageID createPackage(1: string name, 2: string folder, 3: PackageID root, 4: string password, 5: string site, 6: string comment, 7: bool paused), @@ -426,22 +423,10 @@ service Pyload { void restartPackage(1: PackageID pid), void restartFile(1: FileID fid), void recheckPackage(1: PackageID pid), - void restartFailed(), + void restartFailed() void stopDownloads(1: list<FileID> fids), void stopAllDownloads(), - /////////////////////// - // Collector - /////////////////////// - - list<LinkStatus> getCollector(), - - void addToCollector(1: LinkList links), - PackageID addFromCollector(1: string name, 2: bool paused), - void renameCollPack(1: string name, 2: string new_name), - void deleteCollPack(1: string name), - void deleteCollLink(1: string url), - //////////////////////////// // File Information retrieval //////////////////////////// diff --git a/pyload/remote/wsbackend/AsyncHandler.py b/pyload/remote/wsbackend/AsyncHandler.py index 7eee40707..d53d6bcea 100644 --- a/pyload/remote/wsbackend/AsyncHandler.py +++ b/pyload/remote/wsbackend/AsyncHandler.py @@ -75,10 +75,18 @@ class AsyncHandler(AbstractHandler): pass @lock - def add_event(self, event, *args): + def add_event(self, event, *args, **kwargs): # Convert arguments to json suited instance event = EventInfo(event, [x.toInfoData() if hasattr(x, 'toInfoData') else x for x in args]) + # use the user kwarg argument to determine access + user = None + if 'user' in kwargs: + user = kwargs['user'] + del kwargs['user'] + if hasattr(user, 'uid'): + user = user.uid + for req in self.clients: # Not logged in yet if not req.api: continue @@ -87,6 +95,9 @@ class AsyncHandler(AbstractHandler): # TODO: events are security critical, this should be revised later # TODO: permissions? interaction etc if not req.api.user.isAdmin(): + if user is not None and req.api.primaryUID != user: + break + skip = False for arg in args: if hasattr(arg, 'owner') and arg.owner != req.api.primaryUID: |