Selaa lähdekoodia

Merge branch 'beta' of https://github.com/MediaBrowser/Emby into beta

Luke Pulverenti 9 vuotta sitten
vanhempi
sitoutus
8fe7315afa

+ 11 - 16
MediaBrowser.Api/ItemUpdateService.cs

@@ -70,26 +70,21 @@ namespace MediaBrowser.Api
                 Cultures = _localizationManager.GetCultures().ToList()
                 Cultures = _localizationManager.GetCultures().ToList()
             };
             };
 
 
-            var locationType = item.LocationType;
-            if (locationType == LocationType.FileSystem ||
-                locationType == LocationType.Offline)
+            if (!item.IsVirtualItem && !(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
             {
             {
-                if (!(item is ICollectionFolder) && !(item is UserView) && !(item is AggregateFolder) && !(item is LiveTvChannel) && !(item is IItemByName))
+                var inheritedContentType = _libraryManager.GetInheritedContentType(item);
+                var configuredContentType = _libraryManager.GetConfiguredContentType(item);
+
+                if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
                 {
                 {
-                    var inheritedContentType = _libraryManager.GetInheritedContentType(item);
-                    var configuredContentType = _libraryManager.GetConfiguredContentType(item);
+                    info.ContentTypeOptions = GetContentTypeOptions(true);
+                    info.ContentType = configuredContentType;
 
 
-                    if (string.IsNullOrWhiteSpace(inheritedContentType) || string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(configuredContentType))
+                    if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
                     {
                     {
-                        info.ContentTypeOptions = GetContentTypeOptions(true);
-                        info.ContentType = configuredContentType;
-
-                        if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
-                        {
-                            info.ContentTypeOptions = info.ContentTypeOptions
-                                .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
-                                .ToList();
-                        }
+                        info.ContentTypeOptions = info.ContentTypeOptions
+                            .Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
+                            .ToList();
                     }
                     }
                 }
                 }
             }
             }

+ 1 - 1
MediaBrowser.Providers/Manager/ImageSaver.cs

@@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.Manager
         /// <returns>IEnumerable{System.String}.</returns>
         /// <returns>IEnumerable{System.String}.</returns>
         private string[] GetSavePaths(IHasImages item, ImageType type, int? imageIndex, string mimeType, bool saveLocally)
         private string[] GetSavePaths(IHasImages item, ImageType type, int? imageIndex, string mimeType, bool saveLocally)
         {
         {
-            if (!saveLocally)
+            if (!saveLocally || (_config.Configuration.ImageSavingConvention == ImageSavingConvention.Legacy))
             {
             {
                 return new[] { GetStandardSavePath(item, type, imageIndex, mimeType, saveLocally) };
                 return new[] { GetStandardSavePath(item, type, imageIndex, mimeType, saveLocally) };
             }
             }

+ 25 - 0
MediaBrowser.Server.Implementations/Library/LibraryManager.cs

@@ -2791,6 +2791,31 @@ namespace MediaBrowser.Server.Implementations.Library
             }
             }
 
 
             _fileSystem.CreateShortcut(lnk, path);
             _fileSystem.CreateShortcut(lnk, path);
+
+            RemoveContentTypeOverrides(path);
+        }
+
+        private void RemoveContentTypeOverrides(string path)
+        {
+            var removeList = new List<NameValuePair>();
+
+            foreach (var contentType in ConfigurationManager.Configuration.ContentTypes)
+            {
+                if (string.Equals(path, contentType.Name, StringComparison.OrdinalIgnoreCase)
+                    || _fileSystem.ContainsSubPath(path, contentType.Name))
+                {
+                    removeList.Add(contentType);
+                }
+            }
+
+            if (removeList.Count > 0)
+            {
+                ConfigurationManager.Configuration.ContentTypes = ConfigurationManager.Configuration.ContentTypes
+                    .Except(removeList)
+                        .ToArray();
+
+                ConfigurationManager.SaveConfiguration();
+            }
         }
         }
 
 
         public void RemoveMediaPath(string virtualFolderName, string mediaPath)
         public void RemoveMediaPath(string virtualFolderName, string mediaPath)

+ 41 - 45
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs

@@ -979,67 +979,57 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
 
 
             var recordPath = GetRecordingPath(timer, info);
             var recordPath = GetRecordingPath(timer, info);
             var recordingStatus = RecordingStatus.New;
             var recordingStatus = RecordingStatus.New;
+            var isResourceOpen = false;
+            SemaphoreSlim semaphore = null;
 
 
             try
             try
             {
             {
                 var result = await GetChannelStreamInternal(timer.ChannelId, null, CancellationToken.None).ConfigureAwait(false);
                 var result = await GetChannelStreamInternal(timer.ChannelId, null, CancellationToken.None).ConfigureAwait(false);
+                isResourceOpen = true;
+                semaphore = result.Item3;
                 var mediaStreamInfo = result.Item1;
                 var mediaStreamInfo = result.Item1;
-                var isResourceOpen = true;
 
 
-                // Unfortunately due to the semaphore we have to have a nested try/finally
-                try
-                {
-                    // HDHR doesn't seem to release the tuner right away after first probing with ffmpeg
-                    //await Task.Delay(3000, cancellationToken).ConfigureAwait(false);
-
-                    var recorder = await GetRecorder().ConfigureAwait(false);
+                // HDHR doesn't seem to release the tuner right away after first probing with ffmpeg
+                //await Task.Delay(3000, cancellationToken).ConfigureAwait(false);
 
 
-                    recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath);
-                    recordPath = EnsureFileUnique(recordPath, timer.Id);
+                var recorder = await GetRecorder().ConfigureAwait(false);
 
 
-                    _libraryMonitor.ReportFileSystemChangeBeginning(recordPath);
-                    _fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
-                    activeRecordingInfo.Path = recordPath;
+                recordPath = recorder.GetOutputPath(mediaStreamInfo, recordPath);
+                recordPath = EnsureFileUnique(recordPath, timer.Id);
 
 
-                    var duration = recordingEndDate - DateTime.UtcNow;
+                _libraryMonitor.ReportFileSystemChangeBeginning(recordPath);
+                _fileSystem.CreateDirectory(Path.GetDirectoryName(recordPath));
+                activeRecordingInfo.Path = recordPath;
 
 
-                    _logger.Info("Beginning recording. Will record for {0} minutes.", duration.TotalMinutes.ToString(CultureInfo.InvariantCulture));
+                var duration = recordingEndDate - DateTime.UtcNow;
 
 
-                    _logger.Info("Writing file to path: " + recordPath);
-                    _logger.Info("Opening recording stream from tuner provider");
+                _logger.Info("Beginning recording. Will record for {0} minutes.", duration.TotalMinutes.ToString(CultureInfo.InvariantCulture));
 
 
-                    Action onStarted = () =>
-                    {
-                        timer.Status = RecordingStatus.InProgress;
-                        _timerProvider.AddOrUpdate(timer, false);
-
-                        result.Item3.Release();
-                        isResourceOpen = false;
-                    };
+                _logger.Info("Writing file to path: " + recordPath);
+                _logger.Info("Opening recording stream from tuner provider");
 
 
-                    var pathWithDuration = result.Item2.ApplyDuration(mediaStreamInfo.Path, duration);
+                Action onStarted = () =>
+                {
+                    timer.Status = RecordingStatus.InProgress;
+                    _timerProvider.AddOrUpdate(timer, false);
 
 
-                    // If it supports supplying duration via url
-                    if (!string.Equals(pathWithDuration, mediaStreamInfo.Path, StringComparison.OrdinalIgnoreCase))
-                    {
-                        mediaStreamInfo.Path = pathWithDuration;
-                        mediaStreamInfo.RunTimeTicks = duration.Ticks;
-                    }
+                    result.Item3.Release();
+                    isResourceOpen = false;
+                };
 
 
-                    await recorder.Record(mediaStreamInfo, recordPath, duration, onStarted, cancellationToken).ConfigureAwait(false);
+                var pathWithDuration = result.Item2.ApplyDuration(mediaStreamInfo.Path, duration);
 
 
-                    recordingStatus = RecordingStatus.Completed;
-                    _logger.Info("Recording completed: {0}", recordPath);
-                }
-                finally
+                // If it supports supplying duration via url
+                if (!string.Equals(pathWithDuration, mediaStreamInfo.Path, StringComparison.OrdinalIgnoreCase))
                 {
                 {
-                    if (isResourceOpen)
-                    {
-                        result.Item3.Release();
-                    }
-
-                    _libraryMonitor.ReportFileSystemChangeComplete(recordPath, true);
+                    mediaStreamInfo.Path = pathWithDuration;
+                    mediaStreamInfo.RunTimeTicks = duration.Ticks;
                 }
                 }
+
+                await recorder.Record(mediaStreamInfo, recordPath, duration, onStarted, cancellationToken).ConfigureAwait(false);
+
+                recordingStatus = RecordingStatus.Completed;
+                _logger.Info("Recording completed: {0}", recordPath);
             }
             }
             catch (OperationCanceledException)
             catch (OperationCanceledException)
             {
             {
@@ -1053,6 +1043,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             }
             }
             finally
             finally
             {
             {
+                if (isResourceOpen && semaphore != null)
+                {
+                    semaphore.Release();
+                }
+
+                _libraryMonitor.ReportFileSystemChangeComplete(recordPath, true);
+
                 ActiveRecordingInfo removed;
                 ActiveRecordingInfo removed;
                 _activeRecordings.TryRemove(timer.Id, out removed);
                 _activeRecordings.TryRemove(timer.Id, out removed);
             }
             }
@@ -1060,10 +1057,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             if (recordingStatus == RecordingStatus.Completed)
             if (recordingStatus == RecordingStatus.Completed)
             {
             {
                 timer.Status = RecordingStatus.Completed;
                 timer.Status = RecordingStatus.Completed;
-                _timerProvider.AddOrUpdate(timer, false);
+                _timerProvider.Delete(timer);
 
 
                 OnSuccessfulRecording(info.IsSeries, recordPath);
                 OnSuccessfulRecording(info.IsSeries, recordPath);
-                _timerProvider.Delete(timer);
             }
             }
             else if (DateTime.UtcNow < timer.EndDate)
             else if (DateTime.UtcNow < timer.EndDate)
             {
             {

+ 8 - 1
MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs

@@ -62,7 +62,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
             }
             }
             finally
             finally
             {
             {
-                File.Delete(tempfile);
+                try
+                {
+                    File.Delete(tempfile);
+                }
+                catch (Exception ex)
+                {
+                    _logger.ErrorException("Error deleting recording temp file", ex);
+                }
             }
             }
         }
         }
 
 

+ 12 - 2
MediaBrowser.Server.Implementations/LiveTv/Listings/XmlTvListingsProvider.cs

@@ -11,6 +11,7 @@ using System.Text;
 using System.Threading;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 using Emby.XmlTv.Classes;
 using Emby.XmlTv.Classes;
+using Emby.XmlTv.Entities;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Extensions;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Common.Net;
 using MediaBrowser.Controller.Configuration;
 using MediaBrowser.Controller.Configuration;
@@ -109,12 +110,12 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
             return results.Select(p => new ProgramInfo()
             return results.Select(p => new ProgramInfo()
             {
             {
                 ChannelId = p.ChannelId,
                 ChannelId = p.ChannelId,
-                EndDate = p.EndDate,
+                EndDate = GetDate(p.EndDate),
                 EpisodeNumber = p.Episode == null ? null : p.Episode.Episode,
                 EpisodeNumber = p.Episode == null ? null : p.Episode.Episode,
                 EpisodeTitle = p.Episode == null ? null : p.Episode.Title,
                 EpisodeTitle = p.Episode == null ? null : p.Episode.Title,
                 Genres = p.Categories,
                 Genres = p.Categories,
                 Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate), // Construct an id from the channel and start date,
                 Id = String.Format("{0}_{1:O}", p.ChannelId, p.StartDate), // Construct an id from the channel and start date,
-                StartDate = p.StartDate,
+                StartDate = GetDate(p.StartDate),
                 Name = p.Title,
                 Name = p.Title,
                 Overview = p.Description,
                 Overview = p.Description,
                 ShortOverview = p.Description,
                 ShortOverview = p.Description,
@@ -135,6 +136,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
             });
             });
         }
         }
 
 
+        private DateTime GetDate(DateTime date)
+        {
+            if (date.Kind != DateTimeKind.Utc)
+            {
+                date = DateTime.SpecifyKind(date, DateTimeKind.Utc);
+            }
+            return date;
+        }
+
         public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
         public async Task AddMetadata(ListingsProviderInfo info, List<ChannelInfo> channels, CancellationToken cancellationToken)
         {
         {
             // Add the channel image url
             // Add the channel image url

+ 13 - 1
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -656,7 +656,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             item.Audio = info.Audio;
             item.Audio = info.Audio;
             item.ChannelId = channel.Id.ToString("N");
             item.ChannelId = channel.Id.ToString("N");
             item.CommunityRating = item.CommunityRating ?? info.CommunityRating;
             item.CommunityRating = item.CommunityRating ?? info.CommunityRating;
-            item.EndDate = info.EndDate;
+
             item.EpisodeTitle = info.EpisodeTitle;
             item.EpisodeTitle = info.EpisodeTitle;
             item.ExternalId = info.Id;
             item.ExternalId = info.Id;
             item.Genres = info.Genres;
             item.Genres = info.Genres;
@@ -673,7 +673,19 @@ namespace MediaBrowser.Server.Implementations.LiveTv
             item.OfficialRating = item.OfficialRating ?? info.OfficialRating;
             item.OfficialRating = item.OfficialRating ?? info.OfficialRating;
             item.Overview = item.Overview ?? info.Overview;
             item.Overview = item.Overview ?? info.Overview;
             item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
             item.RunTimeTicks = (info.EndDate - info.StartDate).Ticks;
+
+            if (item.StartDate != info.StartDate)
+            {
+                forceUpdate = true;
+            }
             item.StartDate = info.StartDate;
             item.StartDate = info.StartDate;
+
+            if (item.EndDate != info.EndDate)
+            {
+                forceUpdate = true;
+            }
+            item.EndDate = info.EndDate;
+
             item.HomePageUrl = info.HomePageUrl;
             item.HomePageUrl = info.HomePageUrl;
 
 
             item.ProductionYear = info.ProductionYear;
             item.ProductionYear = info.ProductionYear;

+ 51 - 36
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -160,8 +160,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
                                 "create table if not exists UserDataKeys (ItemId GUID, UserDataKey TEXT Priority INT, PRIMARY KEY (ItemId, UserDataKey))",
                                 "create table if not exists UserDataKeys (ItemId GUID, UserDataKey TEXT Priority INT, PRIMARY KEY (ItemId, UserDataKey))",
 
 
                                 "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
                                 "create table if not exists ItemValues (ItemId GUID, Type INT, Value TEXT, CleanValue TEXT)",
-                                //"create index if not exists idx_ItemValues on ItemValues(ItemId)",
-                                "create index if not exists idx_ItemValues2 on ItemValues(ItemId,Type)",
 
 
                                 "create table if not exists ProviderIds (ItemId GUID, Name TEXT, Value TEXT, PRIMARY KEY (ItemId, Name))",
                                 "create table if not exists ProviderIds (ItemId GUID, Name TEXT, Value TEXT, PRIMARY KEY (ItemId, Name))",
                                 // covering index
                                 // covering index
@@ -321,6 +319,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
 
 
                 // items by name
                 // items by name
                 "create index if not exists idx_ItemValues6 on ItemValues(ItemId,Type,CleanValue)",
                 "create index if not exists idx_ItemValues6 on ItemValues(ItemId,Type,CleanValue)",
+                "create index if not exists idx_ItemValues7 on ItemValues(Type,CleanValue,ItemId)",
 
 
                 // covering index
                 // covering index
                 "create index if not exists idx_UserDataKeys3 on UserDataKeys(ItemId,Priority,UserDataKey)"
                 "create index if not exists idx_UserDataKeys3 on UserDataKeys(ItemId,Priority,UserDataKey)"
@@ -1776,9 +1775,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
             return string.Empty;
             return string.Empty;
         }
         }
 
 
-        private string GetFromText()
+        private string GetFromText(string alias = "A")
         {
         {
-            return " from TypedBaseItems A";
+            return " from TypedBaseItems " + alias;
         }
         }
 
 
         public List<BaseItem> GetItemList(InternalItemsQuery query)
         public List<BaseItem> GetItemList(InternalItemsQuery query)
@@ -3661,19 +3660,14 @@ namespace MediaBrowser.Server.Implementations.Persistence
 
 
                 var typesToCount = query.IncludeItemTypes.ToList();
                 var typesToCount = query.IncludeItemTypes.ToList();
 
 
-                if (typesToCount.Count == 0)
-                {
-                    //typesToCount.Add("Item");
-                }
-
-                foreach (var type in typesToCount)
+                if (typesToCount.Count > 0)
                 {
                 {
-                    var itemCountColumnQuery = "Select Count(CleanValue) from ItemValues where ItemValues.CleanValue=CleanName AND Type=@ItemValueType AND ItemId in (";
-                    itemCountColumnQuery += "select guid" + GetFromText();
+                    var itemCountColumnQuery = "select group_concat(type, '|')" + GetFromText("B");
 
 
                     var typeSubQuery = new InternalItemsQuery(query.User)
                     var typeSubQuery = new InternalItemsQuery(query.User)
                     {
                     {
                         ExcludeItemTypes = query.ExcludeItemTypes,
                         ExcludeItemTypes = query.ExcludeItemTypes,
+                        IncludeItemTypes = query.IncludeItemTypes,
                         MediaTypes = query.MediaTypes,
                         MediaTypes = query.MediaTypes,
                         AncestorIds = query.AncestorIds,
                         AncestorIds = query.AncestorIds,
                         ExcludeItemIds = query.ExcludeItemIds,
                         ExcludeItemIds = query.ExcludeItemIds,
@@ -3682,15 +3676,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
                         ParentId = query.ParentId,
                         ParentId = query.ParentId,
                         IsPlayed = query.IsPlayed
                         IsPlayed = query.IsPlayed
                     };
                     };
-                    if (string.Equals(type, "Item", StringComparison.OrdinalIgnoreCase))
-                    {
-                        typeSubQuery.IncludeItemTypes = query.IncludeItemTypes;
-                    }
-                    else
-                    {
-                        typeSubQuery.IncludeItemTypes = new[] { type };
-                    }
-                    var whereClauses = GetWhereClauses(typeSubQuery, cmd, type);
+                    var whereClauses = GetWhereClauses(typeSubQuery, cmd, "itemTypes");
+
+                    whereClauses.Add("guid in (select ItemId from ItemValues where ItemValues.CleanValue=A.CleanName AND Type=@ItemValueType)");
 
 
                     var typeWhereText = whereClauses.Count == 0 ?
                     var typeWhereText = whereClauses.Count == 0 ?
                         string.Empty :
                         string.Empty :
@@ -3698,11 +3686,9 @@ namespace MediaBrowser.Server.Implementations.Persistence
 
 
                     itemCountColumnQuery += typeWhereText;
                     itemCountColumnQuery += typeWhereText;
 
 
-                    itemCountColumnQuery += ")";
+                    //itemCountColumnQuery += ")";
 
 
-                    var columnName = type + "Count";
-
-                    itemCountColumns.Add(new Tuple<string, string>(columnName, "(" + itemCountColumnQuery + ") as " + columnName));
+                    itemCountColumns.Add(new Tuple<string, string>("itemTypes", "(" + itemCountColumnQuery + ") as itemTypes"));
                 }
                 }
 
 
                 var columns = _retriveItemColumns.ToList();
                 var columns = _retriveItemColumns.ToList();
@@ -3731,7 +3717,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
                     " where " + string.Join(" AND ", innerWhereClauses.ToArray());
                     " where " + string.Join(" AND ", innerWhereClauses.ToArray());
 
 
                 var whereText = " where Type=@SelectType";
                 var whereText = " where Type=@SelectType";
-                whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
+
+                if (typesToCount.Count == 0)
+                {
+                    whereText += " And CleanName In (Select CleanValue from ItemValues where Type=@ItemValueType AND ItemId in (select guid from TypedBaseItems" + innerWhereText + "))";
+                }
+                else
+                {
+                    whereText += " And itemTypes not null";
+                }
 
 
                 var outerQuery = new InternalItemsQuery(query.User)
                 var outerQuery = new InternalItemsQuery(query.User)
                 {
                 {
@@ -3812,6 +3806,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
                     ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
                     ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
                     : CommandBehavior.SequentialAccess;
                     : CommandBehavior.SequentialAccess;
 
 
+                //Logger.Debug("GetItemValues: " + cmd.CommandText);
+
                 using (var reader = cmd.ExecuteReader(commandBehavior))
                 using (var reader = cmd.ExecuteReader(commandBehavior))
                 {
                 {
                     LogQueryTime("GetItemValues", cmd, now);
                     LogQueryTime("GetItemValues", cmd, now);
@@ -3830,7 +3826,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                             var item = GetItem(reader);
                             var item = GetItem(reader);
                             if (item != null)
                             if (item != null)
                             {
                             {
-                                var countStartColumn = columns.Count - typesToCount.Count;
+                                var countStartColumn = columns.Count - 1;
 
 
                                 list.Add(new Tuple<BaseItem, ItemCounts>(item, GetItemCounts(reader, countStartColumn, typesToCount)));
                                 list.Add(new Tuple<BaseItem, ItemCounts>(item, GetItemCounts(reader, countStartColumn, typesToCount)));
                             }
                             }
@@ -3861,35 +3857,54 @@ namespace MediaBrowser.Server.Implementations.Persistence
         {
         {
             var counts = new ItemCounts();
             var counts = new ItemCounts();
 
 
-            for (var i = 0; i < typesToCount.Count; i++)
+            if (typesToCount.Count == 0)
+            {
+                return counts;
+            }
+
+            var typeString = reader.IsDBNull(countStartColumn) ? null : reader.GetString(countStartColumn);
+
+            if (string.IsNullOrWhiteSpace(typeString))
             {
             {
-                var value = reader.GetInt32(countStartColumn + i);
+                return counts;
+            }
 
 
-                var type = typesToCount[i];
-                if (string.Equals(type, "Series", StringComparison.OrdinalIgnoreCase))
+            var allTypes = typeString.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries)
+                .ToLookup(i => i).ToList();
+
+            foreach (var type in allTypes)
+            {
+                var value = type.ToList().Count;
+                var typeName = type.Key;
+
+                if (string.Equals(typeName, typeof(Series).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.SeriesCount = value;
                     counts.SeriesCount = value;
                 }
                 }
-                else if (string.Equals(type, "Episode", StringComparison.OrdinalIgnoreCase))
+                else if (string.Equals(typeName, typeof(Episode).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.EpisodeCount = value;
                     counts.EpisodeCount = value;
                 }
                 }
-                else if (string.Equals(type, "Movie", StringComparison.OrdinalIgnoreCase))
+                else if (string.Equals(typeName, typeof(Movie).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.MovieCount = value;
                     counts.MovieCount = value;
                 }
                 }
-                else if (string.Equals(type, "MusicAlbum", StringComparison.OrdinalIgnoreCase))
+                else if (string.Equals(typeName, typeof(MusicAlbum).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.AlbumCount = value;
                     counts.AlbumCount = value;
                 }
                 }
-                else if (string.Equals(type, "Audio", StringComparison.OrdinalIgnoreCase))
+                else if (string.Equals(typeName, typeof(Audio).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.SongCount = value;
                     counts.SongCount = value;
                 }
                 }
-                else if (string.Equals(type, "Game", StringComparison.OrdinalIgnoreCase))
+                else if (string.Equals(typeName, typeof(Game).FullName, StringComparison.OrdinalIgnoreCase))
                 {
                 {
                     counts.GameCount = value;
                     counts.GameCount = value;
                 }
                 }
+                else if (string.Equals(typeName, typeof(Trailer).FullName, StringComparison.OrdinalIgnoreCase))
+                {
+                    counts.TrailerCount = value;
+                }
                 counts.ItemCount += value;
                 counts.ItemCount += value;
             }
             }
 
 

+ 0 - 9
MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj

@@ -353,9 +353,6 @@
     <Content Include="dashboard-ui\scripts\autoorganizesmart.js">
     <Content Include="dashboard-ui\scripts\autoorganizesmart.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>
-    <Content Include="dashboard-ui\scripts\searchmenu.js">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\scripts\searchpage.js">
     <Content Include="dashboard-ui\scripts\searchpage.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>
@@ -830,9 +827,6 @@
     <Content Include="dashboard-ui\css\librarybrowser.css">
     <Content Include="dashboard-ui\css\librarybrowser.css">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>
-    <Content Include="dashboard-ui\css\search.css">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\css\tileitem.css">
     <Content Include="dashboard-ui\css\tileitem.css">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>
@@ -1155,9 +1149,6 @@
     <Content Include="dashboard-ui\scripts\remotecontrol.js">
     <Content Include="dashboard-ui\scripts\remotecontrol.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>
-    <Content Include="dashboard-ui\scripts\search.js">
-      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
-    </Content>
     <Content Include="dashboard-ui\scripts\moviecollections.js">
     <Content Include="dashboard-ui\scripts\moviecollections.js">
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
       <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
     </Content>
     </Content>