Browse Source

Add api for file types

pull/992/merge
Ruud 13 years ago
parent
commit
5bda44d419
  1. 28
      couchpotato/core/plugins/file/main.py

28
couchpotato/core/plugins/file/main.py

@ -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()
})

Loading…
Cancel
Save