From 8aadbf35136874ac7a279f8bc0f3a4a02a131313 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 4 May 2014 20:46:52 -0400 Subject: [PATCH] support channel folders --- .../Channels/ChannelAudioItem.cs | 2 + .../Channels/ChannelCategoryItem.cs | 2 + .../Channels/ChannelInfo.cs | 30 +++++++++++ .../Channels/ChannelItemInfo.cs | 10 ++++ .../Channels/ChannelVideoItem.cs | 2 + MediaBrowser.Controller/Channels/IChannel.cs | 25 --------- .../Channels/IChannelItem.cs | 2 + .../MediaBrowser.Controller.csproj | 1 + .../MediaBrowser.Model.Portable.csproj | 6 +++ .../MediaBrowser.Model.net35.csproj | 6 +++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + MediaBrowser.Model/MediaInfo/Constants.cs | 24 +++++++++ .../Channels/ChannelManager.cs | 53 +++++++++++-------- .../Library/Resolvers/Movies/MovieResolver.cs | 4 +- .../MediaBrowser.WebDashboard.csproj | 3 ++ 15 files changed, 123 insertions(+), 48 deletions(-) create mode 100644 MediaBrowser.Controller/Channels/ChannelInfo.cs create mode 100644 MediaBrowser.Model/MediaInfo/Constants.cs diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index a0999593f5..72a996b193 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -8,6 +8,8 @@ namespace MediaBrowser.Controller.Channels { public string ExternalId { get; set; } + public string ChannelId { get; set; } + public ChannelItemType ChannelItemType { get; set; } public bool IsInfiniteStream { get; set; } diff --git a/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs b/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs index 67f0ec65f6..b20dcf6204 100644 --- a/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelCategoryItem.cs @@ -7,6 +7,8 @@ namespace MediaBrowser.Controller.Channels { public string ExternalId { get; set; } + public string ChannelId { get; set; } + public ChannelItemType ChannelItemType { get; set; } public string OriginalImageUrl { get; set; } diff --git a/MediaBrowser.Controller/Channels/ChannelInfo.cs b/MediaBrowser.Controller/Channels/ChannelInfo.cs new file mode 100644 index 0000000000..fd3a169a2d --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelInfo.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Channels +{ + public class ChannelInfo + { + /// + /// Gets the home page URL. + /// + /// The home page URL. + public string HomePageUrl { get; set; } + + /// + /// Gets or sets a value indicating whether this instance can search. + /// + /// true if this instance can search; otherwise, false. + public bool CanSearch { get; set; } + + public List MediaTypes { get; set; } + + public List ContentTypes { get; set; } + + public ChannelInfo() + { + MediaTypes = new List(); + ContentTypes = new List(); + } + } + +} diff --git a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs index 104204eb07..e4abea4fc7 100644 --- a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs @@ -88,6 +88,16 @@ namespace MediaBrowser.Controller.Channels public Dictionary RequiredHttpHeaders { get; set; } + public string Container { get; set; } + public string AudioCodec { get; set; } + public string VideoCodec { get; set; } + + public int? AudioBitrate { get; set; } + public int? VideoBitrate { get; set; } + public int? Width { get; set; } + public int? Height { get; set; } + public int? AudioChannels { get; set; } + public ChannelMediaInfo() { RequiredHttpHeaders = new Dictionary(); diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index 0bf05f9657..0d2bd933be 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -10,6 +10,8 @@ namespace MediaBrowser.Controller.Channels { public string ExternalId { get; set; } + public string ChannelId { get; set; } + public ChannelItemType ChannelItemType { get; set; } public bool IsInfiniteStream { get; set; } diff --git a/MediaBrowser.Controller/Channels/IChannel.cs b/MediaBrowser.Controller/Channels/IChannel.cs index ca4b7f551a..e19d083e28 100644 --- a/MediaBrowser.Controller/Channels/IChannel.cs +++ b/MediaBrowser.Controller/Channels/IChannel.cs @@ -66,31 +66,6 @@ namespace MediaBrowser.Controller.Channels IEnumerable GetChannels(); } - public class ChannelInfo - { - /// - /// Gets the home page URL. - /// - /// The home page URL. - public string HomePageUrl { get; set; } - - /// - /// Gets or sets a value indicating whether this instance can search. - /// - /// true if this instance can search; otherwise, false. - public bool CanSearch { get; set; } - - public List MediaTypes { get; set; } - - public List ContentTypes { get; set; } - - public ChannelInfo() - { - MediaTypes = new List(); - ContentTypes = new List(); - } - } - public class ChannelSearchInfo { public string SearchTerm { get; set; } diff --git a/MediaBrowser.Controller/Channels/IChannelItem.cs b/MediaBrowser.Controller/Channels/IChannelItem.cs index a05ef8e295..b653cead04 100644 --- a/MediaBrowser.Controller/Channels/IChannelItem.cs +++ b/MediaBrowser.Controller/Channels/IChannelItem.cs @@ -4,6 +4,8 @@ namespace MediaBrowser.Controller.Channels { public interface IChannelItem : IHasImages { + string ChannelId { get; set; } + string ExternalId { get; set; } ChannelItemType ChannelItemType { get; set; } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index b54ad2272b..830a4829f4 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -69,6 +69,7 @@ Properties\SharedVersion.cs + diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index f6c8f6135f..e8a802725a 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -215,6 +215,9 @@ Entities\ChapterInfo.cs + + Entities\CollectionType.cs + Entities\DisplayPreferences.cs @@ -350,6 +353,9 @@ MediaInfo\BlurayDiscInfo.cs + + MediaInfo\Constants.cs + MediaInfo\IBlurayExaminer.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 9845cb6b2a..5fb5fae748 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -202,6 +202,9 @@ Entities\ChapterInfo.cs + + Entities\CollectionType.cs + Entities\DisplayPreferences.cs @@ -337,6 +340,9 @@ MediaInfo\BlurayDiscInfo.cs + + MediaInfo\Constants.cs + MediaInfo\IBlurayExaminer.cs diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index 710e5f6b47..877eb54447 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -110,6 +110,7 @@ + diff --git a/MediaBrowser.Model/MediaInfo/Constants.cs b/MediaBrowser.Model/MediaInfo/Constants.cs new file mode 100644 index 0000000000..bada7bc799 --- /dev/null +++ b/MediaBrowser.Model/MediaInfo/Constants.cs @@ -0,0 +1,24 @@ + +namespace MediaBrowser.Model.MediaInfo +{ + public class Container + { + public string MP4 = "MP4"; + } + + public class AudioCodec + { + public string AAC = "AAC"; + public string MP3 = "MP3"; + } + + public class VideoCodec + { + public string H263 = "H263"; + public string H264 = "H264"; + public string H265 = "H265"; + public string MPEG4 = "MPEG4"; + public string MSMPEG4 = "MSMPEG4"; + public string VC1 = "VC1"; + } +} diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index 662bbdf3e5..f516c08780 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -220,14 +220,28 @@ namespace MediaBrowser.Server.Implementations.Channels ? null : _userManager.GetUserById(new Guid(query.UserId)); - var id = new Guid(query.ChannelId); - var channel = _channelEntities.First(i => i.Id == id); - var channelProvider = GetChannelProvider(channel); + var queryChannelId = query.ChannelId; + var channels = string.IsNullOrWhiteSpace(queryChannelId) + ? _channelEntities + : _channelEntities.Where(i => i.Id == new Guid(queryChannelId)); - var items = await GetChannelItems(channelProvider, user, query.CategoryId, cancellationToken) - .ConfigureAwait(false); + var itemTasks = channels.Select(async channel => + { + var channelProvider = GetChannelProvider(channel); + + var items = await GetChannelItems(channelProvider, user, query.CategoryId, cancellationToken) + .ConfigureAwait(false); + + var channelId = channel.Id.ToString("N"); + + var tasks = items.Select(i => GetChannelItemEntity(i, channelId, cancellationToken)); + + return await Task.WhenAll(tasks).ConfigureAwait(false); + }); - return await GetReturnItems(items, user, query, cancellationToken).ConfigureAwait(false); + var results = await Task.WhenAll(itemTasks).ConfigureAwait(false); + + return await GetReturnItems(results.SelectMany(i => i), user, query, cancellationToken).ConfigureAwait(false); } private readonly SemaphoreSlim _resourcePool = new SemaphoreSlim(1, 1); @@ -316,22 +330,13 @@ namespace MediaBrowser.Server.Implementations.Channels return Path.Combine(_config.ApplicationPaths.CachePath, channelId, categoryKey, user.Id.ToString("N") + ".json"); } - private async Task> GetReturnItems(IEnumerable items, User user, ChannelItemQuery query, CancellationToken cancellationToken) + private async Task> GetReturnItems(IEnumerable items, User user, ChannelItemQuery query, CancellationToken cancellationToken) { - // Get everything - var fields = Enum.GetNames(typeof(ItemFields)) - .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) - .ToList(); - - var tasks = items.Select(i => GetChannelItemEntity(i, cancellationToken)); - - IEnumerable entities = await Task.WhenAll(tasks).ConfigureAwait(false); + items = ApplyFilters(items, query.Filters, user); - entities = ApplyFilters(entities, query.Filters, user); + items = _libraryManager.Sort(items, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending); - entities = _libraryManager.Sort(entities, user, query.SortBy, query.SortOrder ?? SortOrder.Ascending); - - var all = entities.ToList(); + var all = items.ToList(); var totalCount = all.Count; if (query.StartIndex.HasValue) @@ -345,6 +350,11 @@ namespace MediaBrowser.Server.Implementations.Channels await RefreshIfNeeded(all, cancellationToken).ConfigureAwait(false); + // Get everything + var fields = Enum.GetNames(typeof(ItemFields)) + .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) + .ToList(); + var returnItemArray = all.Select(i => _dtoService.GetBaseItemDto(i, fields, user)) .ToArray(); @@ -358,10 +368,10 @@ namespace MediaBrowser.Server.Implementations.Channels private string GetIdToHash(string externalId) { // Increment this as needed to force new downloads - return externalId + "3"; + return externalId + "4"; } - private async Task GetChannelItemEntity(ChannelItemInfo info, CancellationToken cancellationToken) + private async Task GetChannelItemEntity(ChannelItemInfo info, string internalChannnelId, CancellationToken cancellationToken) { BaseItem item; Guid id; @@ -434,6 +444,7 @@ namespace MediaBrowser.Server.Implementations.Channels channelItem.OriginalImageUrl = info.ImageUrl; channelItem.ExternalId = info.Id; + channelItem.ChannelId = internalChannnelId; channelItem.ChannelItemType = info.Type; var channelMediaItem = item as IChannelMediaItem; diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index 558087a252..905e6e6769 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -381,7 +381,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { firstMovie.IsMultiPart = true; - _logger.Info("Multi-part video found: " + firstMovie.Path); + _logger.Debug("Multi-part video found: " + firstMovie.Path); return firstMovie; } @@ -411,7 +411,7 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies { firstMovie.HasLocalAlternateVersions = true; - _logger.Info("Multi-version video found: " + firstMovie.Path); + _logger.Debug("Multi-version video found: " + firstMovie.Path); return firstMovie; } diff --git a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj index 540e54f3b7..4b9dad90a0 100644 --- a/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj +++ b/MediaBrowser.WebDashboard/MediaBrowser.WebDashboard.csproj @@ -229,6 +229,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest