From f1cfd3cffb6ba6af91badb717ee204dce682d793 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 8 Feb 2017 22:58:04 -0500 Subject: add schedules direct error handling --- .../LiveTv/Listings/SchedulesDirect.cs | 34 +++++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'Emby.Server.Implementations') diff --git a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs index 1b7a1c8c62..0d7a26553a 100644 --- a/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs +++ b/Emby.Server.Implementations/LiveTv/Listings/SchedulesDirect.cs @@ -152,7 +152,11 @@ namespace Emby.Server.Implementations.LiveTv.Listings responseString); var programDict = programDetails.ToDictionary(p => p.programID, y => y); - var images = await GetImageForPrograms(info, programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID).ToList(), cancellationToken); + var programIdsWithImages = + programDetails.Where(p => p.hasImageArtwork).Select(p => p.programID) + .ToList(); + + var images = await GetImageForPrograms(info, programIdsWithImages, cancellationToken); var schedules = dailySchedules.SelectMany(d => d.programs); foreach (ScheduleDirect.Program schedule in schedules) @@ -439,13 +443,20 @@ namespace Emby.Server.Implementations.LiveTv.Listings List programIds, CancellationToken cancellationToken) { + if (programIds.Count == 0) + { + return new List(); + } + var imageIdString = "["; foreach (var i in programIds) { - if (!imageIdString.Contains(i.Substring(0, 10))) + var imageId = i.Substring(0, 10); + + if (!imageIdString.Contains(imageId)) { - imageIdString += "\"" + i.Substring(0, 10) + "\","; + imageIdString += "\"" + imageId + "\","; } } @@ -461,14 +472,21 @@ namespace Emby.Server.Implementations.LiveTv.Listings // The data can be large so give it some extra time TimeoutMs = 60000 }; - List images; - using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false)) + + try { - images = _jsonSerializer.DeserializeFromStream>( - innerResponse2.Content); + using (var innerResponse2 = await Post(httpOptions, true, info).ConfigureAwait(false)) + { + return _jsonSerializer.DeserializeFromStream>( + innerResponse2.Content); + } } + catch (Exception ex) + { + _logger.ErrorException("Error getting image info from schedules direct", ex); - return images; + return new List(); + } } public async Task> GetHeadends(ListingsProviderInfo info, string country, string location, CancellationToken cancellationToken) -- cgit v1.2.3