Private GIT

Skip to content
Snippets Groups Projects
Commit 5bda44d4 authored by Ruud's avatar Ruud
Browse files

Add api for file types

parent 84eccbf9
Branches
Tags
No related merge requests found
......@@ -2,6 +2,7 @@ from couchpotato import get_session
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
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.logger import CPLog
from couchpotato.core.plugins.base import Plugin
......@@ -30,6 +31,27 @@ class FileManager(Plugin):
'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.init)
......@@ -129,3 +151,9 @@ class FileManager(Plugin):
types.append(type_object.to_dict())
return types
def getTypesView(self):
return jsonified({
'types': self.getTypes()
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment