'Handles communication to Plex hosts via HTTP API
Args:
command: Dictionary of field/data pairs, encoded via urllib and passed to the legacy xbmcCmds HTTP API
host: Plex host:port
username: Plex API username
password: Plex API password
Returns:
Returns \'OK\' for successful commands or False if there was an error'

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

    if (not username):
        username = sickrage.srCore.srConfig.PLEX_CLIENT_USERNAME
    if (not password):
        password = sickrage.srCore.srConfig.PLEX_CLIENT_PASSWORD
    if (not host):
        sickrage.srCore.srLogger.warning(u'PLEX:    No    host    specified,    check    your    settings')
        return False
    for key in command:
        if (type(command[key]) == unicode):
            command[key] = command[key].encode(u'utf-8')
    enc_command = urllib.urlencode(command)
    sickrage.srCore.srLogger.debug((u'PLEX:    Encoded    API    command:    ' + enc_command))
    url = (u'http://%s/xbmcCmds/xbmcHttp/?%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'PLEX:    Contacting    (with    auth    header)    via    url:    ' + url))
        else:
            sickrage.srCore.srLogger.debug((u'PLEX:    Contacting    via    url:    ' + url))
        response = urllib2.urlopen(req)
        result = response.read().decode(sickrage.SYS_ENCODING)
        response.close()
        sickrage.srCore.srLogger.debug((u'PLEX:    HTTP    response:    ' + result.replace(u'\n', u'')))
        return u'OK'
    except (urllib2.URLError, IOError) as e:
        sickrage.srCore.srLogger.warning((((u"PLEX:    Warning:    Couldn't    contact    Plex    at    " + url) + u'    ') + e))
        return False
