diff options
| author | Luke <luke.pulverenti@gmail.com> | 2016-11-14 02:29:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-11-14 02:29:42 -0500 |
| commit | 54d3c2eed767b6d030961f9a75216c447f94abef (patch) | |
| tree | 1855731242b35ffbed16beb1c96de1e6442a797e /Emby.Server.Implementations/Channels | |
| parent | e8379b865c301cb8ab65eb5b883c44abdbedcf79 (diff) | |
| parent | 43c69713835afee3d27ced041e5f96ec36fa0ce3 (diff) | |
Merge pull request #2288 from MediaBrowser/dev
Dev
Diffstat (limited to 'Emby.Server.Implementations/Channels')
| -rw-r--r-- | Emby.Server.Implementations/Channels/ChannelManager.cs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/Emby.Server.Implementations/Channels/ChannelManager.cs b/Emby.Server.Implementations/Channels/ChannelManager.cs index 2ce880c93a..0df916ded3 100644 --- a/Emby.Server.Implementations/Channels/ChannelManager.cs +++ b/Emby.Server.Implementations/Channels/ChannelManager.cs @@ -326,7 +326,7 @@ namespace Emby.Server.Implementations.Channels if (requiresCallback != null) { - results = await GetChannelItemMediaSourcesInternal(requiresCallback, item.ExternalId, cancellationToken) + results = await GetChannelItemMediaSourcesInternal(requiresCallback, GetItemExternalId(item), cancellationToken) .ConfigureAwait(false); } else @@ -1075,6 +1075,18 @@ namespace Emby.Server.Implementations.Channels return result; } + private string GetItemExternalId(BaseItem item) + { + var externalId = item.ExternalId; + + if (string.IsNullOrWhiteSpace(externalId)) + { + externalId = item.GetProviderId("ProviderExternalId"); + } + + return externalId; + } + private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1); private async Task<ChannelItemResult> GetChannelItems(IChannel channel, User user, @@ -1096,7 +1108,11 @@ namespace Emby.Server.Implementations.Channels { if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) { - return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + if (cachedResult != null) + { + return cachedResult; + } } } } @@ -1119,7 +1135,11 @@ namespace Emby.Server.Implementations.Channels { if (_fileSystem.GetLastWriteTimeUtc(cachePath).Add(cacheLength) > DateTime.UtcNow) { - return _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + var cachedResult = _jsonSerializer.DeserializeFromFile<ChannelItemResult>(cachePath); + if (cachedResult != null) + { + return cachedResult; + } } } } @@ -1145,11 +1165,16 @@ namespace Emby.Server.Implementations.Channels { var categoryItem = _libraryManager.GetItemById(new Guid(folderId)); - query.FolderId = categoryItem.ExternalId; + query.FolderId = GetItemExternalId(categoryItem); } var result = await channel.GetChannelItems(query, cancellationToken).ConfigureAwait(false); + if (result == null) + { + throw new InvalidOperationException("Channel returned a null result from GetChannelItems"); + } + if (!startIndex.HasValue && !limit.HasValue) { CacheResponse(result, cachePath); |
