public IEnumerable <DownloadPackageQuery> QueryLinks(JdDevice device) { dynamic obj = new ExpandoObject(); obj.bytesTotal = true; obj.comment = true; obj.status = true; obj.enabled = true; obj.packageUUIDs = null; obj.host = true; obj.url = true; obj.finished = true; obj.running = true; string json = JsonConvert.SerializeObject(obj); var param = new[] { json }; string result = CallAction(device, "/downloadsV2/queryLinks", param); dynamic jsonObject = JObject.Parse(result); dynamic links = jsonObject.data.ToObject <List <DownloadPackageQuery> >(); if (string.IsNullOrEmpty(result)) { return(null); } return(links); }
public void RestartJd(JdDevice device) { string response = CallAction(device, "/system/restartJD", null); if (!string.IsNullOrEmpty(response)) { dynamic jsonContent = JObject.Parse(response); string data = jsonContent.data; } }
public bool Start(JdDevice device) { string result = CallAction(device, "/downloadcontroller/start", null); if (string.IsNullOrEmpty(result)) { return(false); } return(true); }
public string PackageCount(JdDevice device) { string response = CallAction(device, "/downloadsV2/packageCount", null); if (!string.IsNullOrEmpty(response)) { dynamic jsonContent = JObject.Parse(response); return(jsonContent.data); } return(""); }
public string GetSpeedInBps(JdDevice device) { string response = CallAction(device, "/downloadcontroller/getSpeedInBps", null); if (!string.IsNullOrEmpty(response)) { dynamic jsonContent = JObject.Parse(response); return(jsonContent.data); } return(""); }
private string CallAction(JdDevice device, string action, dynamic param) { if (Devices == null || Devices.Count == 0) { Debug.WriteLine("No device or not enumerate device list yet"); return(null); } if (!Devices.Contains(device)) { Debug.WriteLine("No device with the given name"); return(null); } if (string.IsNullOrEmpty(device.Id)) { Debug.WriteLine("Device is found with empty id"); return(null); } string query = "/t_" + HttpUtility.UrlEncode(_sessiontoken) + "_" + HttpUtility.UrlEncode(device.Id) + action; dynamic p = new ExpandoObject(); p.url = action; if (param != null) { p.@params = param; } p.rid = GetUniqueRid(); p.ApiVer = ApiVer; string json = Newtonsoft.Json.JsonConvert.SerializeObject(p); File.WriteAllText("json.txt", json); json = Encrypt(json, _deviceEncryptionToken); string url = ApiUrl + query; string response = PostQuery(url, json, _deviceEncryptionToken); if (string.IsNullOrEmpty(response)) { return(null); } dynamic jsonContent = JObject.Parse(response); int jsonContentRid = jsonContent.rid; if (!jsonContentRid.Equals(_ridCounter) && jsonContentRid > 0) { Debug.WriteLine("error: rid mismatch!\n"); return(null); } Debug.WriteLine("url=" + url); Debug.WriteLine("response=" + response); return(response); }
public bool AddLink(JdDevice device, string link, string package) { dynamic obj = new ExpandoObject(); obj.priority = "DEFAULT"; obj.links = link; obj.autostart = true; obj.packageName = package; string json = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var param = new[] { json }; string result = CallAction(device, "/linkgrabberv2/addLinks", param); if (string.IsNullOrEmpty(result)) return false; return true; }
public bool AddLink(JdDevice device, string link, string package) { dynamic obj = new ExpandoObject(); obj.priority = "DEFAULT"; obj.links = link; obj.autostart = true; obj.packageName = package; string json = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var param = new[] { json }; string result = CallAction(device, "/linkgrabberv2/addLinks", param); if (string.IsNullOrEmpty(result)) { return(false); } return(true); }
private string CallAction(JdDevice device, string action, dynamic param) { if (Devices == null || Devices.Count == 0) { Debug.WriteLine("No device or not enumerate device list yet"); return null; } if (!Devices.Contains(device)) { Debug.WriteLine("No device with the given name"); return null; } if (string.IsNullOrEmpty(device.Id)) { Debug.WriteLine("Device is found with empty id"); return null; } string query = "/t_" + HttpUtility.UrlEncode(_sessiontoken) + "_" + HttpUtility.UrlEncode(device.Id) + action; dynamic p = new ExpandoObject(); p.url = action; if (param != null) { p.@params = param; } p.rid = GetUniqueRid(); p.ApiVer = ApiVer; string json = Newtonsoft.Json.JsonConvert.SerializeObject(p); File.WriteAllText("json.txt", json); json = Encrypt(json, _deviceEncryptionToken); string url = ApiUrl + query; string response = PostQuery(url, json, _deviceEncryptionToken); if (string.IsNullOrEmpty(response)) return null; dynamic jsonContent = JObject.Parse(response); int jsonContentRid = jsonContent.rid; if (!jsonContentRid.Equals(_ridCounter) && jsonContentRid > 0) { Debug.WriteLine("error: rid mismatch!\n"); return null; } Debug.WriteLine("url=" + url); Debug.WriteLine("response=" + response); return response; }
public bool Stop(JdDevice device) { string result = CallAction(device, "/downloadcontroller/stop", null); if (string.IsNullOrEmpty(result)) { return false; } return true; }
public IEnumerable<DownloadPackageQuery> QueryLinks(JdDevice device) { dynamic obj = new ExpandoObject(); obj.bytesTotal = true; obj.comment = true; obj.status = true; obj.enabled = true; obj.packageUUIDs = null; obj.host = true; obj.url = true; obj.finished = true; obj.running = true; string json = JsonConvert.SerializeObject(obj); var param = new[] { json }; string result = CallAction(device, "/downloadsV2/queryLinks", param); dynamic jsonObject = JObject.Parse(result); dynamic links = jsonObject.data.ToObject<List<DownloadPackageQuery>>(); if (string.IsNullOrEmpty(result)) return null; return links; }
public string PackageCount(JdDevice device) { string response = CallAction(device, "/downloadsV2/packageCount", null); if (!string.IsNullOrEmpty(response)) { dynamic jsonContent = JObject.Parse(response); return jsonContent.data; } return ""; }
public string GetSpeedInBps(JdDevice device) { string response = CallAction(device, "/downloadcontroller/getSpeedInBps", null); if (!string.IsNullOrEmpty(response)) { dynamic jsonContent = JObject.Parse(response); return jsonContent.data; } return ""; }