Repository navigation
Expand file tree
/
Copy pathUserInteractionApi.py
More file actions
61 lines (46 loc) · 1.87 KB
/
Copy pathUserInteractionApi.py
File metadata and controls
61 lines (46 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pyload.Api import Api, RequirePerm, Permission, Interaction
from ApiComponent import ApiComponent
class UserInteractionApi(ApiComponent):
""" Everything needed for user interaction """
@RequirePerm(Permission.Interaction)
def isInteractionWaiting(self, mode):
""" Check if task is waiting.
:param mode: binary or'ed output type
:return: boolean
"""
return self.core.interactionManager.isTaskWaiting(self.primaryUID, mode)
@RequirePerm(Permission.Interaction)
def getInteractionTasks(self, mode):
"""Retrieve task for specific mode.
:param mode: binary or'ed interaction types which should be retrieved
:rtype list of :class:`InteractionTask`
"""
tasks = self.core.interactionManager.getTasks(self.primaryUID, mode)
# retrieved tasks count as seen
for t in tasks:
t.seen = True
if t.type == Interaction.Notification:
t.setWaiting(self.core.interactionManager.CLIENT_THRESHOLD)
return tasks
@RequirePerm(Permission.Interaction)
def setInteractionResult(self, iid, result):
"""Set Result for a interaction task. It will be immediately removed from task queue afterwards
:param iid: interaction id
:param result: result as json string
"""
task = self.core.interactionManager.getTaskByID(iid)
if task and self.primaryUID == task.owner:
task.setResult(result)
@RequirePerm(Permission.Interaction)
def getAddonHandler(self):
pass
@RequirePerm(Permission.Interaction)
def callAddonHandler(self, plugin, func, pid_or_fid):
pass
@RequirePerm(Permission.Download)
def generateDownloadLink(self, fid, timeout):
pass
if Api.extend(UserInteractionApi):
del UserInteractionApi