Avoid NullRef for missing filelist and tags fields

pull/2171/head
Bogdan 9 months ago
parent cb6bf49922
commit 1a89a79b74

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Text.Json.Serialization; using System.Text.Json.Serialization;
@ -230,7 +231,7 @@ namespace NzbDrone.Core.Indexers.Definitions
throw new IndexerException(indexerResponse, "Indexer API call returned an error [{0}]", jsonResponse.Error); throw new IndexerException(indexerResponse, "Indexer API call returned an error [{0}]", jsonResponse.Error);
} }
if (jsonResponse.Result.Items.Count == 0) if (jsonResponse.Result?.Items == null || jsonResponse.Result.Items.Count == 0)
{ {
return torrentInfos; return torrentInfos;
} }
@ -245,14 +246,13 @@ namespace NzbDrone.Core.Indexers.Definitions
var release = new TorrentInfo var release = new TorrentInfo
{ {
Title = title,
Guid = details, Guid = details,
InfoUrl = details, InfoUrl = details,
PosterUrl = row.Banner,
DownloadUrl = row.Download, DownloadUrl = row.Download,
Title = title.Trim(),
Categories = new List<IndexerCategory> { TvCategoryFromQualityParser.ParseTvShowQuality(row.ReleaseTitle) }, Categories = new List<IndexerCategory> { TvCategoryFromQualityParser.ParseTvShowQuality(row.ReleaseTitle) },
Size = ParseUtil.CoerceLong(row.Size), Size = ParseUtil.CoerceLong(row.Size),
Files = row.FileList.Length, Files = row.FileList.Count(),
PublishDate = DateTime.Parse(row.PublishDateUtc, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal), PublishDate = DateTime.Parse(row.PublishDateUtc, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal),
Grabs = ParseUtil.CoerceInt(row.Snatch), Grabs = ParseUtil.CoerceInt(row.Snatch),
Seeders = ParseUtil.CoerceInt(row.Seed), Seeders = ParseUtil.CoerceInt(row.Seed),
@ -261,7 +261,8 @@ namespace NzbDrone.Core.Indexers.Definitions
MinimumRatio = 0, // ratioless MinimumRatio = 0, // ratioless
MinimumSeedTime = row.Category.ToLower() == "season" ? 432000 : 86400, // 120 hours for seasons and 24 hours for episodes MinimumSeedTime = row.Category.ToLower() == "season" ? 432000 : 86400, // 120 hours for seasons and 24 hours for episodes
DownloadVolumeFactor = 0, // ratioless tracker DownloadVolumeFactor = 0, // ratioless tracker
UploadVolumeFactor = 1 UploadVolumeFactor = 1,
PosterUrl = row.Banner
}; };
if (row.TvMazeId.IsNotNullOrWhiteSpace()) if (row.TvMazeId.IsNotNullOrWhiteSpace())
@ -356,7 +357,7 @@ namespace NzbDrone.Core.Indexers.Definitions
public string Download { get; set; } public string Download { get; set; }
[JsonPropertyName("file_list")] [JsonPropertyName("file_list")]
public string[] FileList { get; set; } public IEnumerable<string> FileList { get; set; } = Array.Empty<string>();
[JsonPropertyName("group_name")] [JsonPropertyName("group_name")]
public string GroupName { get; set; } public string GroupName { get; set; }
@ -373,6 +374,6 @@ namespace NzbDrone.Core.Indexers.Definitions
[JsonPropertyName("rls_utc")] [JsonPropertyName("rls_utc")]
public string PublishDateUtc { get; set; } public string PublishDateUtc { get; set; }
public IEnumerable<string> Tags { get; set; } public IEnumerable<string> Tags { get; set; } = Array.Empty<string>();
} }
} }

Loading…
Cancel
Save