public virtual IEnumerable <QueueItem> GetQueue() { var command = new JsonRequest { Method = "listgroups", Params = null }; var response = PostCommand(command.ToJson()); CheckForError(response); var itmes = Json.Deserialize <NzbGetQueue>(response).QueueItems; foreach (var nzbGetQueueItem in itmes) { var queueItem = new QueueItem(); queueItem.Id = nzbGetQueueItem.NzbId.ToString(); queueItem.Title = nzbGetQueueItem.NzbName; queueItem.Size = nzbGetQueueItem.FileSizeMb; queueItem.SizeLeft = nzbGetQueueItem.RemainingSizeMb; yield return(queueItem); } }
public virtual IEnumerable<QueueItem> GetQueue() { var command = new JsonRequest { Method = "listgroups", Params = null }; var response = PostCommand(command.ToJson()); CheckForError(response); var itmes = Json.Deserialize<NzbGetQueue>(response).QueueItems; foreach (var nzbGetQueueItem in itmes) { var queueItem = new QueueItem(); queueItem.Id = nzbGetQueueItem.NzbId.ToString(); queueItem.Title = nzbGetQueueItem.NzbName; queueItem.Size = nzbGetQueueItem.FileSizeMb; queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb; var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title); if (parsedEpisodeInfo == null) continue; var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0); if (remoteEpisode.Series == null) continue; queueItem.RemoteEpisode = remoteEpisode; yield return queueItem; } }
public void should_add_item_to_queue() { var command = new JsonRequest { Method = "appendurl", Params = new object[] { "30.Rock.S01E01.Pilot.720p.hdtv.nzb", "TV", 50, false, "http://www.nzbdrone.com" } }; Mocker.GetMock<IHttpProvider>() .Setup(s => s.PostCommand("192.168.5.55:6789", "nzbget", "pass", It.Is<String>(c => c.Equals(command.ToJson())))) .Returns("{\"version\": \"1.1\",\"result\": true}"); Mocker.Resolve<NzbgetClient>().DownloadNzb(_remoteEpisode); }
public virtual IEnumerable <QueueItem> GetQueue() { var command = new JsonRequest { Method = "listgroups", Params = null }; var response = PostCommand(command.ToJson()); CheckForError(response); var itmes = Json.Deserialize <NzbGetQueue>(response).QueueItems; foreach (var nzbGetQueueItem in itmes) { var queueItem = new QueueItem(); queueItem.Id = nzbGetQueueItem.NzbId.ToString(); queueItem.Title = nzbGetQueueItem.NzbName; queueItem.Size = nzbGetQueueItem.FileSizeMb; queueItem.Sizeleft = nzbGetQueueItem.RemainingSizeMb; var parsedEpisodeInfo = Parser.Parser.ParseTitle(queueItem.Title); if (parsedEpisodeInfo == null) { continue; } var remoteEpisode = _parsingService.Map(parsedEpisodeInfo, 0); if (remoteEpisode.Series == null) { continue; } queueItem.RemoteEpisode = remoteEpisode; yield return(queueItem); } }
public void DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title + ".nzb"; string cat = _configService.NzbgetTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority; 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(command.ToJson()); CheckForError(response); var success = Json.Deserialize <EnqueueResponse>(response).Result; _logger.Debug("Queue Response: [{0}]", success); }
public void DownloadNzb(RemoteEpisode remoteEpisode) { var url = remoteEpisode.Release.DownloadUrl; var title = remoteEpisode.Release.Title + ".nzb"; string cat = _configService.NzbgetTvCategory; int priority = remoteEpisode.IsRecentEpisode() ? (int)_configService.NzbgetRecentTvPriority : (int)_configService.NzbgetOlderTvPriority; 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(command.ToJson()); CheckForError(response); var success = Json.Deserialize<EnqueueResponse>(response).Result; _logger.Debug("Queue Response: [{0}]", success); }
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 = _configService.NzbgetHost; } if (port == 0) { port = _configService.NzbgetPort; } if (username == null) { username = _configService.NzbgetUsername; } if (password == null) { password = _configService.NzbgetPassword; } var command = new JsonRequest { Method = "version", Params = null }; var address = String.Format(@"{0}:{1}", host, port); var response = _httpProvider.PostCommand(address, username, password, command.ToJson()); CheckForError(response); return(Json.Deserialize <VersionModel>(response)); }
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 = _configService.NzbgetHost; if (port == 0) port = _configService.NzbgetPort; if (username == null) username = _configService.NzbgetUsername; if (password == null) password = _configService.NzbgetPassword; var command = new JsonRequest { Method = "version", Params = null }; var address = String.Format(@"{0}:{1}", host, port); var response = _httpProvider.PostCommand(address, username, password, command.ToJson()); CheckForError(response); return Json.Deserialize<VersionModel>(response); }