public int GetGuide() { int count; DateTime time = new DateTime(0x7b2, 1, 1, 0, 0, 0, 0); string requestUri = string.Format("http://{0}/http_replay_guide-get_snapshot?guide_file_name=0&serial_no=RTV4080K0000000000", this.theDevice.ip, (long)(((ulong)(DateTime.UtcNow.Ticks - time.Ticks)) / 0x989680)); try { byte[] haystack = HTTPClient.Get(requestUri); int offset = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_START#####")) + 0x1d; count = ReplayHelper.FindInByteArray(haystack, this.encoding.GetBytes("#####ATTACHED_FILE_END#####")) - offset; try { if (count > 0) { FileStream stream = File.Create(this.guideFile); stream.Write(haystack, offset, count); stream.Close(); } } catch (Exception) { ReplayLogger.DebugLog(string.Concat(new object[] { "Unable to create guide file: ", this.guideFile, " of ", count, " bytes." })); } } catch (Exception) { ReplayLogger.DebugLog(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip)); throw new ApplicationException(string.Format("Unable to contact ReplayTV {0} at {1}", this.theDevice.friendlyName, this.theDevice.ip)); } return(count); }
public long GetFileSize(string file) { string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.HTTPFSEncrypt("name=" + file)).ToLower(); byte[] bytes = HTTPClient.Get(string.Format("http://{0}/httpfs-fstat?__Q_={1}", this.theDevice.ip, text2), httpfsHeaders); if (bytes == null) { throw new ApplicationException(string.Format("Send failed! No response from {0} ReplayTV. Is it connected to the network?", this.theDevice.friendlyName)); } if (bytes.GetLength(0) == 0) { throw new ApplicationException("Send failed! Show size -1MB error caught. Unable to determine a valid clock offset. Check your computer's clock."); } string text4 = Encoding.Default.GetString(bytes); char[] separator = new char[] { '\n' }; string[] textArray = text4.Split(separator); if (text4.StartsWith("80820005")) { throw new ApplicationException(string.Format("Send failed! Show not found on {0} ReplayTV. Refresh your listings.", this.theDevice.friendlyName)); } long num = -1; string[] textArray2 = textArray; int length = textArray2.Length; for (int i = 0; i < length; i++) { string text5 = textArray2[i]; if (text5.StartsWith("size=")) { num = Convert.ToInt64(text5.Substring(5).Trim()); } } if (num == -1) { throw new ApplicationException("Send failed! Show size -1MB error caught. Check your computer's clock."); } return(num); }
public ReplayDevice RDDNSLookup(string isn, bool final, string rddnsip) { string requestUri; string text2 = ReplayHelper.ByteArrayToHexString(ReplayCrypt.RDDNSEncrypt("isn=" + isn)).ToLower(); if (rddnsip.Length > 0) { requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsip, text2); } else { requestUri = string.Format("http://{0}/rd/servlet/gu?q={1}", rddnsServer, text2); } byte[] responseContent = HTTPClient.Get(requestUri); ReplayDevice device = this.ParseRDDNSResponse(responseContent); if ((!final && this.erRespType.Equals("SERVER")) && this.erRespId.Equals("-1")) { device = this.RDDNSLookup(isn, true, rddnsip); } return(device); }