resolved issue with setting up mixed library

This commit is contained in:
Luke Pulverenti 2015-10-18 13:35:36 -04:00
parent 5ecf69503b
commit d74ded0fd6
4 changed files with 41 additions and 14 deletions

View File

@ -118,8 +118,18 @@ namespace MediaBrowser.Server.Implementations.Channels
if (query.SupportsLatestItems.HasValue) if (query.SupportsLatestItems.HasValue)
{ {
var val = query.SupportsLatestItems.Value; var val = query.SupportsLatestItems.Value;
channels = channels.Where(i => (GetChannelProvider(i) is ISupportsLatestMedia) == val) channels = channels.Where(i =>
.ToList(); {
try
{
return (GetChannelProvider(i) is ISupportsLatestMedia) == val;
}
catch
{
return false;
}
}).ToList();
} }
if (query.IsFavorite.HasValue) if (query.IsFavorite.HasValue)
{ {
@ -1292,7 +1302,14 @@ namespace MediaBrowser.Server.Implementations.Channels
internal IChannel GetChannelProvider(Channel channel) internal IChannel GetChannelProvider(Channel channel)
{ {
return GetAllChannels().First(i => string.Equals(i.Name.GetMD5().ToString("N"), channel.ChannelId, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase)); var result = GetAllChannels().FirstOrDefault(i => string.Equals(i.Name.GetMD5().ToString("N"), channel.ChannelId, StringComparison.OrdinalIgnoreCase) || string.Equals(i.Name, channel.Name, StringComparison.OrdinalIgnoreCase));
if (result == null)
{
throw new ResourceNotFoundException("No channel provider found for channel " + channel.Name);
}
return result;
} }
private IEnumerable<BaseItem> ApplyFilters(IEnumerable<BaseItem> items, IEnumerable<ItemFilter> filters, User user) private IEnumerable<BaseItem> ApplyFilters(IEnumerable<BaseItem> items, IEnumerable<ItemFilter> filters, User user)

View File

@ -74,12 +74,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<MusicVideo>(parent, files, directoryService, collectionType, false); return ResolveVideos<MusicVideo>(parent, files, directoryService, false);
} }
if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<Video>(parent, files, directoryService, collectionType, false); return ResolveVideos<Video>(parent, files, directoryService, false);
} }
if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
// Owned items should just use the plain video type // Owned items should just use the plain video type
if (parent == null) if (parent == null)
{ {
return ResolveVideos<Video>(parent, files, directoryService, collectionType, false); return ResolveVideos<Video>(parent, files, directoryService, false);
} }
if (parent is Series || parent.Parents.OfType<Series>().Any()) if (parent is Series || parent.Parents.OfType<Series>().Any())
@ -100,18 +100,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
return null; return null;
} }
return ResolveVideos<Movie>(parent, files, directoryService, collectionType, false); return ResolveVideos<Movie>(parent, files, directoryService, false);
} }
if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase)) if (string.Equals(collectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{ {
return ResolveVideos<Movie>(parent, files, directoryService, collectionType, true); return ResolveVideos<Movie>(parent, files, directoryService, true);
} }
return null; return null;
} }
private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, string collectionType, bool suppportMultiEditions) private MultiItemResolverResult ResolveVideos<T>(Folder parent, IEnumerable<FileSystemMetadata> fileSystemEntries, IDirectoryService directoryService, bool suppportMultiEditions)
where T : Video, new() where T : Video, new()
{ {
var files = new List<FileSystemMetadata>(); var files = new List<FileSystemMetadata>();
@ -396,7 +396,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
!string.Equals(collectionType, CollectionType.Photos) && !string.Equals(collectionType, CollectionType.Photos) &&
!string.Equals(collectionType, CollectionType.MusicVideos); !string.Equals(collectionType, CollectionType.MusicVideos);
var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, collectionType, supportsMultiVersion); var result = ResolveVideos<T>(parent, fileSystemEntries, directoryService, supportsMultiVersion);
if (result.Items.Count == 1) if (result.Items.Count == 1)
{ {
@ -506,7 +506,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
var validCollectionTypes = new[] var validCollectionTypes = new[]
{ {
string.Empty,
CollectionType.Movies, CollectionType.Movies,
CollectionType.HomeVideos, CollectionType.HomeVideos,
CollectionType.MusicVideos, CollectionType.MusicVideos,
@ -514,7 +513,12 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
CollectionType.Photos CollectionType.Photos
}; };
return !validCollectionTypes.Contains(collectionType ?? string.Empty, StringComparer.OrdinalIgnoreCase); if (string.IsNullOrWhiteSpace(collectionType))
{
return false;
}
return !validCollectionTypes.Contains(collectionType, StringComparer.OrdinalIgnoreCase);
} }
} }
} }

View File

@ -1215,6 +1215,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv
{ {
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (itemId == Guid.Empty)
{
// Somehow some invalid data got into the db. It probably predates the boundary checking
continue;
}
if (!currentIdList.Contains(itemId)) if (!currentIdList.Contains(itemId))
{ {
var item = _libraryManager.GetItemById(itemId); var item = _libraryManager.GetItemById(itemId);

View File

@ -1,4 +1,4 @@
using System.Reflection; using System.Reflection;
//[assembly: AssemblyVersion("3.0.*")] [assembly: AssemblyVersion("3.0.*")]
[assembly: AssemblyVersion("3.0.5768.2")] //[assembly: AssemblyVersion("3.0.5768.2")]