public virtual bool DownloadNzb(string url, string title, bool recentlyAired) { try { string cat = _configProvider.NzbgetTvCategory; int priority = recentlyAired ? (int)_configProvider.NzbgetRecentTvPriority : (int)_configProvider.NzbgetBacklogTvPriority; var command = new JsonRequest { Method = "appendurl", Params = new object[]{ title, cat, priority, false, url } }; logger.Info("Adding report [{0}] to the queue.", title); var response = PostCommand(JsonConvert.SerializeObject(command)); CheckForError(response); var success = JsonConvert.DeserializeObject<EnqueueResponse>(response).Result; logger.Debug("Queue Response: [{0}]", success); return true; } catch (WebException ex) { logger.Error("Error communicating with Nzbget: " + ex.Message); } return false; }
public virtual List<QueueItem> GetQueue() { var command = new JsonRequest { Method = "listgroups", Params = null }; var response = PostCommand(JsonConvert.SerializeObject(command)); CheckForError(response); return JsonConvert.DeserializeObject<Queue>(response).QueueItems; }
public virtual VersionModel GetVersion(string host = null, int port = 0, string username = null, string password = null) { //Get saved values if any of these are defaults if (host == null) host = _configProvider.NzbgetHost; if (port == 0) port = _configProvider.NzbgetPort; if (username == null) username = _configProvider.NzbgetUsername; if (password == null) password = _configProvider.NzbgetPassword; var command = new JsonRequest { Method = "version", Params = null }; var address = String.Format(@"{0}:{1}", host, port); var response = _httpProvider.PostCommand(address, username, password, JsonConvert.SerializeObject(command)); CheckForError(response); return JsonConvert.DeserializeObject<VersionModel>(response); }