protected override void ProcessRecord() { if (this.MyInvocation.BoundParameters.ContainsKey("JobId")) { for (int i = 0; i < this.JobId.Length; i++) { string ep = string.Format(EP_ID, this.JobId[i]); string jsonRes = base.TryGetSonarrResult(ep); if (!string.IsNullOrEmpty(jsonRes)) { CommandResult output = SonarrHttp.ConvertToSonarrResult <CommandResult>(jsonRes); base.WriteObject(output); } } } else { string jsonRes = base.TryGetSonarrResult(EP); if (!string.IsNullOrEmpty(jsonRes)) { List <CommandResult> jobs = SonarrHttp.ConvertToSonarrResults <CommandResult>(jsonRes, out bool iso); base.WriteObject(jobs, true); } } }
protected override void ProcessRecord() { if (this.ParameterSetName == "ByRemotePathName") { string jsonRes = base.TryGetSonarrResult(EP); if (!string.IsNullOrEmpty(jsonRes)) { List <RemotePathMapping> mappings = SonarrHttp.ConvertToSonarrResults <RemotePathMapping>(jsonRes); if (this.MyInvocation.BoundParameters.ContainsKey("RemotePath")) { var wcp = new WildcardPattern(this.RemotePath); base.WriteObject(mappings.FindAll(x => wcp.IsMatch(x.RemotePath)), true); } else { base.WriteObject(mappings, true); } } } else if (this.MyInvocation.BoundParameters.ContainsKey("MappingId")) { for (int i = 0; i < this.MappingId.Length; i++) { string jsonRes = base.TryGetSonarrResult(string.Format(EP_WITH_ID, this.MappingId[i])); if (!string.IsNullOrEmpty(jsonRes)) { RemotePathMapping mapping = SonarrHttp.ConvertToSonarrResult <RemotePathMapping>(jsonRes); base.WriteObject(mapping); } } } }
protected override void ProcessRecord() { if (this.MyInvocation.BoundParameters.ContainsKey("Id")) { for (int i = 0; i < this.Id.Length; i++) { string ep = string.Format(EP_ID, this.Id[i]); string jsonRes = base.TryGetSonarrResult(ep); if (!string.IsNullOrEmpty(jsonRes)) { QueueItem oneRes = SonarrHttp.ConvertToSonarrResult <QueueItem>(jsonRes); base.WriteObject(oneRes); } } } else { string jsonRes = base.TryGetSonarrResult(EP); if (!string.IsNullOrEmpty(jsonRes)) { List <QueueItem> resses = SonarrHttp.ConvertToSonarrResults <QueueItem>(jsonRes, out bool iso); base.WriteObject(resses, true); } } }
protected override void ProcessRecord() { string start = this.DateToString(this.StartDate); string end = this.DateToString(this.EndDate); string full = string.Format(EP_WITH_DATE, start, end); string jsonRes = base.TryGetSonarrResult(full); if (!string.IsNullOrEmpty(jsonRes)) { List <CalendarEntry> entries = SonarrHttp.ConvertToSonarrResults <CalendarEntry>(jsonRes, out bool iso); if (this.ParameterSetName == "ByDayOfWeek") { base.WriteObject(entries.FindAll(x => x.DayOfWeek.HasValue && this.DayOfWeek.Contains(x.DayOfWeek.Value)), true); } else if (this.ParameterSetName == "BySeriesTitle") { var wcp = new WildcardPattern(this.SeriesTitle, WildcardOptions.IgnoreCase); base.WriteObject(entries.FindAll(x => wcp.IsMatch(x.Series)), true); } else { base.WriteObject(entries, true); } } }
private List <Restriction> GetAllRestrictions() { string jsonRes = base.TryGetSonarrResult(EP); return(!string.IsNullOrEmpty(jsonRes) ? SonarrHttp.ConvertToSonarrResults <Restriction>(jsonRes) : null); }
private List <DownloadClient> GetAllDownloadClients() { string jsonRes = base.TryGetSonarrResult(EP); return(!string.IsNullOrEmpty(jsonRes) ? SonarrHttp.ConvertToSonarrResults <DownloadClient>(jsonRes, out bool iso) : null); }
// BETA - for New-QualityDefinition protected override void EndProcessing() { string qStr = base.TryGetSonarrResult("/qualitydefinition"); if (!string.IsNullOrEmpty(qStr)) { Context.Qualities = SonarrHttp.ConvertToSonarrResults <QualityDefinition>(qStr, out bool iso); } }
protected override void ProcessRecord() { string strRes = base.TryGetSonarrResult("/diskspace"); if (!string.IsNullOrWhiteSpace(strRes)) { List <SonarrDiskspaceResult> sdr = SonarrHttp.ConvertToSonarrResults <SonarrDiskspaceResult>(strRes, out bool iso); base.WriteObject(sdr, true); } }
protected override void ProcessRecord() { string full = this.ParameterSetName != "ByEpisodeId" ? string.Format(EP_BY_SERIES, this.SeriesId) : string.Format(EP_BY_EP, this.EpisodeId); string jsonStr = base.TryGetSonarrResult(full); if (!string.IsNullOrEmpty(jsonStr)) { List <EpisodeResult> result = SonarrHttp.ConvertToSonarrResults <EpisodeResult>(jsonStr, out bool iso); foreach (EpisodeResult er in result) { if (er.AirDateUtc.HasValue) { er.AirDateUtc = er.AirDateUtc.Value.ToUniversalTime(); } } if (this.MyInvocation.BoundParameters.ContainsKey("AbsoluteEpisodeNumber")) { IEnumerable <EpisodeResult> results = result.Where(x => x.AbsoluteEpisodeNumber.HasValue && this.AbsoluteEpisodeNumber.Contains(x.AbsoluteEpisodeNumber.Value)); base.WriteObject(results, true); } else if (this.MyInvocation.BoundParameters.ContainsKey("EpisodeIdentifier")) { var list = new List <EpisodeResult>(result.Count); for (int i = 0; i < this.EpisodeIdentifier.Length; i++) { EpisodeIdentifier epid = this.EpisodeIdentifier[i]; for (int e = 0; e < result.Count; e++) { EpisodeResult er = result[e]; if (er.SeasonNumber == epid.Season) { if (!epid.Episode.HasValue || (epid.Episode.HasValue && er.EpisodeNumber == epid.Episode.Value)) { list.Add(er); } } } } list.Sort(new EpisodeComparer()); var ieq = new EpisodeEquality(); base.WriteObject(list.Distinct(ieq), true); } else { base.WriteObject(result, true); } } }
protected override void ProcessRecord() { string full = this.ParameterSetName == "BySeriesId" ? string.Format(EP_BY_SERIES, this.Series.SeriesId) : this.ParameterSetName == "ByEpisodeFileId" ? string.Format(EP_BY_EP, this.EpisodeFileId) : string.Format(EP_BY_EP, this.EpisodeFile.EpisodeFileId); string jsonStr = base.TryGetSonarrResult(full); if (!string.IsNullOrEmpty(jsonStr)) { List <EpisodeFile> result = SonarrHttp.ConvertToSonarrResults <EpisodeFile>(jsonStr, out bool iso); base.WriteObject(result, true); } }
protected override void ProcessRecord() { if (this.ParameterSetName == "ByTagLabel") { string allRes = base.TryGetSonarrResult(EP); List <Tag> tags = null; if (!string.IsNullOrEmpty(allRes)) { tags = SonarrHttp.ConvertToSonarrResults <Tag>(allRes, out bool iso); } if (tags.Count > 0) { if (this.MyInvocation.BoundParameters.ContainsKey("Label")) { for (int i = 0; i < this.Label.Length; i++) { var wcp = new WildcardPattern(this.Label[i], WildcardOptions.IgnoreCase); for (int t = 0; t < tags.Count; t++) { Tag oneTag = tags[t]; if (wcp.IsMatch(oneTag.Label)) { base.WriteObject(oneTag); } } } } else { base.WriteObject(tags, true); } } } else { for (int i = 0; i < this.Id.Length; i++) { string ep = string.Format(EP_ID, this.Id[i]); string jsonRes = base.TryGetSonarrResult(ep); if (!string.IsNullOrEmpty(jsonRes)) { base.WriteObject(SonarrHttp.ConvertToSonarrResult <Tag>(jsonRes)); } } } }
protected override void ProcessRecord() { if (this.ParameterSetName == "ByProfileName") { List <QualityProfile> profs = null; string jsonStr = base.TryGetSonarrResult("/profile"); if (!string.IsNullOrEmpty(jsonStr)) { profs = SonarrHttp.ConvertToSonarrResults <QualityProfile>(jsonStr, out bool iso); } if (profs != null && profs.Count > 0) { if (this.Name != null && this.Name.Length > 0) { for (int n = 0; n < this.Name.Length; n++) { string name = this.Name[n]; var wcp = new WildcardPattern(name, WildcardOptions.IgnoreCase); for (int p = 0; p < profs.Count; p++) { QualityProfile qp = profs[p]; if (wcp.IsMatch(qp.Name)) { base.WriteObject(qp); } } } } else { base.WriteObject(profs, true); } } } else { string full = string.Format("/profile/{0}", this.Id); string oneProf = base.TryGetSonarrResult(full); if (!string.IsNullOrEmpty(oneProf)) { QualityProfile qp = SonarrHttp.ConvertToSonarrResult <QualityProfile>(oneProf); base.WriteObject(qp); } } }
protected override void ProcessRecord() { string jsonStr = base.TryGetSonarrResult("/system/backup"); if (!string.IsNullOrWhiteSpace(jsonStr)) { List <SonarrBackupResult> backups = SonarrHttp.ConvertToSonarrResults <SonarrBackupResult>(jsonStr, out bool iso); if (this.Type != null && this.Type.Length > 0) { base.WriteObject(backups.Where(x => this.Type.Contains(x.Type)), true); } else { base.WriteObject(backups, true); } } }
protected override void ProcessRecord() { string jsonRes = base.TryGetSonarrResult(EP); if (!string.IsNullOrEmpty(jsonRes)) { List <LogFile> logFiles = SonarrHttp.ConvertToSonarrResults <LogFile>(jsonRes); logFiles.Sort(ClassFactory.GenerateLogFileComparer()); if (this.MyInvocation.BoundParameters.ContainsKey("LogFileId")) { base.WriteObject(logFiles.FindAll(x => this.LogFileId.Contains(x.LogFileId)), true); } else if (this.MyInvocation.BoundParameters.ContainsKey("Name")) { IEqualityComparer <string> ig = ClassFactory.NewIgnoreCase(); List <LogFile> list = logFiles.FindAll(x => this.Name.Contains(x.FileName, ig)); base.WriteObject(list, true); } else { base.WriteObject(logFiles, true); } } }