Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'jsonp' of https://github.com/kobowi/Sick-Beard into dev…

…elopment
  • Loading branch information...
commit 6ac4ce9189f09851d3b034f64c0556326294a2b9 2 parents 1cd1e06 + 8b409fd
@midgetspy authored
Showing with 4 additions and 0 deletions.
  1. +4 −0 sickbeard/webapi.py
View
4 sickbeard/webapi.py
@@ -160,9 +160,13 @@ def titler(x):
def _out_as_json(self, dict):
""" set cherrypy response to json """
response = cherrypy.response
+ request = cherrypy.request
response.headers['Content-Type'] = 'application/json;charset=UTF-8'
try:
out = json.dumps(dict, indent=self.intent, sort_keys=True)
+ callback = request.params.get('callback') or request.params.get('jsonp')
+ if callback != None:
+ out = callback + '(' + out + ');' # wrap with JSONP call if requested
except Exception, e: # if we fail to generate the output fake a error
logger.log(u"API :: " + traceback.format_exc(), logger.DEBUG)
out = '{"result":"' + result_type_map[RESULT_ERROR] + '", "message": "error while composing output: "' + ex(e) + '"}'
Please sign in to comment.
Something went wrong with that request. Please try again.