'handles the stuff from the handler'

def _api_run(self, *args, **kwargs):

    result = {}
    logger.debug((u'PlexPy    APIv2    ::    API    called    with    kwargs:    %s' % kwargs))
    self._api_validate(**kwargs)
    if (self._api_cmd and self._api_authenticated):
        call = getattr(self, self._api_cmd)
        if self._api_profileme:
            from profilehooks import profile
            call = profile(call, immediate=True)
        try:
            result = call(**self._api_kwargs)
        except Exception as e:
            logger.error((u'PlexPy    APIv2    ::    Failed    to    run    %s    with    %s:    %s' % (self._api_cmd, self._api_kwargs, e)))
            if self._api_debug:
                cherrypy.request.show_tracebacks = True
                raise
            self._api_msg = 'Check    the    logs'
    ret = None
    try:
        if isinstance(result, (dict, list)):
            ret = result
        else:
            raise
    except:
        try:
            ret = json.loads(result)
        except (ValueError, TypeError):
            try:
                ret = xmltodict.parse(result, attr_prefix='')
            except:
                pass
    if (ret is None):
        ret = result
    if (ret or (self._api_result_type == 'success')):
        self._api_result_type = 'success'
    else:
        self._api_result_type = 'error'
    if isinstance(ret, dict):
        if ret.get('message'):
            self._api_msg = ret.get('message', {})
            ret = {}
        if ret.get('result'):
            self._api_result_type = ret.get('result')
    return self._api_out_as(self._api_responds(result_type=self._api_result_type, msg=self._api_msg, data=ret))
