Add api for file types
This commit is contained in:
1 parent
84eccbf9cf
commit
5bda44d419
1 file changed
+28
@@ -2,6 +2,7 @@ from couchpotato import get_session
|
|||||||
from couchpotato.api import addApiView
|
from couchpotato.api import addApiView
|
||||||
from couchpotato.core.event import addEvent
|
from couchpotato.core.event import addEvent
|
||||||
from couchpotato.core.helpers.encoding import toUnicode
|
from couchpotato.core.helpers.encoding import toUnicode
|
||||||
|
from couchpotato.core.helpers.request import jsonified
|
||||||
from couchpotato.core.helpers.variable import md5, getExt
|
from couchpotato.core.helpers.variable import md5, getExt
|
||||||
from couchpotato.core.logger import CPLog
|
from couchpotato.core.logger import CPLog
|
||||||
from couchpotato.core.plugins.base import Plugin
|
from couchpotato.core.plugins.base import Plugin
|
||||||
@@ -30,6 +31,27 @@ class FileManager(Plugin):
|
|||||||
'return': {'type': 'file'}
|
'return': {'type': 'file'}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
addApiView('file.types', self.getTypesView, docs = {
|
||||||
|
'desc': 'Return a list of all the file types and their ids.',
|
||||||
|
'return': {'type': 'object', 'example': """{
|
||||||
|
'types': [
|
||||||
|
{
|
||||||
|
"identifier": "poster_original",
|
||||||
|
"type": "image",
|
||||||
|
"id": 1,
|
||||||
|
"name": "Poster_original"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identifier": "poster",
|
||||||
|
"type": "image",
|
||||||
|
"id": 2,
|
||||||
|
"name": "Poster"
|
||||||
|
},
|
||||||
|
etc
|
||||||
|
]
|
||||||
|
}"""}
|
||||||
|
})
|
||||||
|
|
||||||
addEvent('app.load', self.cleanup)
|
addEvent('app.load', self.cleanup)
|
||||||
addEvent('app.load', self.init)
|
addEvent('app.load', self.init)
|
||||||
|
|
||||||
@@ -129,3 +151,9 @@ class FileManager(Plugin):
|
|||||||
types.append(type_object.to_dict())
|
types.append(type_object.to_dict())
|
||||||
|
|
||||||
return types
|
return types
|
||||||
|
|
||||||
|
def getTypesView(self):
|
||||||
|
|
||||||
|
return jsonified({
|
||||||
|
'types': self.getTypes()
|
||||||
|
})
|
||||||
Reference in new issue
Block a user