public bool Command(string cmd, string parameter) { HttpWebRequest request; var returnContent = false; var uri = @"http://" + _parent.ClientIPAddress + ":32433/playback/" + cmd + "?commandID=720276921&type=video"; if (!String.IsNullOrEmpty(parameter)) { uri += "&" + parameter; } try { request = (HttpWebRequest)WebRequest.Create(new Uri(uri)); request.Headers.Add("X-Plex-Token", _parent.PlexAuthToken); request.Headers.Add("X-Plex-Client-Identifier", "Plex Media Player"); // request.Headers.Add("X-Plex-Product","Yatse 3 Socket"); // request.Headers.Add("X-Plex-Version", "0.1.0"); request.Headers.Add("commandID", "1"); request.Method = "GET"; request.Timeout = 1000; _parent.Log("Plex COMMAND via MPC : " + cmd); _parent.Trace(uri); using (var response = (HttpWebResponse)request.GetResponse()) { using (var stream = response.GetResponseStream()) { if (stream != null) { using (var reader = new StreamReader(stream, Encoding.UTF8)) { var reqContent = reader.ReadToEnd(); _parent.Trace(reqContent); returnContent = true; } } } } } catch (WebException e) { _parent.Log("ERROR - PLEX via MPC Command : " + cmd + " - " + e.Message); if (e.Status == WebExceptionStatus.Timeout) { // _parent.MpcLoaded = false; } } return(returnContent); }
public bool DownloadImages(ApiImageDownloadInfo apiImageDownloadInfo) { try { if (apiImageDownloadInfo == null) { return(false); } bool res = false; if (apiImageDownloadInfo.Source.Contains(_parent.IP)) { _parent.Trace("----------DOWNLOAD IMAGES OKAY checking for presence of Server IP Address in source to select DOwnload Method - Server IP Found"); res = DownloadRemoteImageFile(apiImageDownloadInfo.Source, apiImageDownloadInfo.Destination); } else { res = Download(apiImageDownloadInfo.Source, apiImageDownloadInfo.Destination); } if (res) { if (apiImageDownloadInfo.ToThumb) { _parent.GenerateThumb(apiImageDownloadInfo.Destination, apiImageDownloadInfo.Destination, apiImageDownloadInfo.MaxHeight); } } return(res); } catch (System.Exception ex) { _parent.Log("Exception in Download Images Caught Should continue " + ex); return(false); ; } }