'Handles communication to KODI servers via HTTP API
Args:
command: Dictionary of field/data pairs, encoded via urllib and passed to the KODI API via HTTP
host: KODI webserver host:port
username: KODI webserver username
password: KODI webserver password
Returns:
Returns response.result for successful commands or False if there was an error'

def _send_to_kodi(self, command, host=None, username=None, password=None):

    if (not username):
        username = sickrage.srCore.srConfig.KODI_USERNAME
    if (not password):
        password = sickrage.srCore.srConfig.KODI_PASSWORD
    if (not host):
        sickrage.srCore.srLogger.warning(u'No    KODI    host    passed,    aborting    update')
        return False
    for key in command:
        if isinstance(command[key], unicode):
            command[key] = command[key].encode(u'utf-8')
    enc_command = urllib.urlencode(command)
    sickrage.srCore.srLogger.debug((u'KODI    encoded    API    command:    ' + enc_command))
    url = (u'http://%s/kodiCmds/kodiHttp/?%s' % (host, enc_command))
    try:
        req = urllib2.Request(url)
        if password:
            base64string = base64.encodestring((u'%s:%s' % (username, password)))[:(-1)]
            authheader = (u'Basic    %s' % base64string)
            req.add_header(u'Authorization', authheader)
            sickrage.srCore.srLogger.debug((u'Contacting    KODI    (with    auth    header)    via    url:    ' + url))
        else:
            sickrage.srCore.srLogger.debug((u'Contacting    KODI    via    url:    ' + url))
        try:
            response = urllib2.urlopen(req)
        except (httplib.BadStatusLine, urllib2.URLError) as e:
            sickrage.srCore.srLogger.debug((u"Couldn't    contact    KODI    HTTP    at    %r    :    %r" % (url, e)))
            return False
        result = response.read().decode(sickrage.SYS_ENCODING)
        response.close()
        sickrage.srCore.srLogger.debug((u'KODI    HTTP    response:    ' + result.replace(u'\n', u'')))
        return result
    except Exception as e:
        sickrage.srCore.srLogger.debug((u"Couldn't    contact    KODI    HTTP    at    %r    :    %r" % (url, e)))
        return False
