diff options
Diffstat (limited to 'MediaBrowser.Controller')
18 files changed, 257 insertions, 131 deletions
diff --git a/MediaBrowser.Controller/Channels/ChannelItemInfo.cs b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs new file mode 100644 index 000000000..496fbfbf4 --- /dev/null +++ b/MediaBrowser.Controller/Channels/ChannelItemInfo.cs @@ -0,0 +1,67 @@ +using MediaBrowser.Controller.Entities; +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Channels +{ + public class ChannelItemInfo + { + public string Name { get; set; } + + public string Id { get; set; } + + public ChannelItemType Type { get; set; } + + public string OfficialRating { get; set; } + + public string Overview { get; set; } + + public List<string> Genres { get; set; } + + public List<PersonInfo> People { get; set; } + + public float? CommunityRating { get; set; } + + public long? RunTimeTicks { get; set; } + + public bool IsInfinite { get; set; } + + public string ImageUrl { get; set; } + + public ChannelMediaType MediaType { get; set; } + + public ChannelMediaContentType ContentType { get; set; } + + public ChannelItemInfo() + { + Genres = new List<string>(); + People = new List<PersonInfo>(); + } + } + + public enum ChannelItemType + { + Media = 0, + + Category = 1 + } + + public enum ChannelMediaType + { + Audio = 0, + + Video = 1 + } + + public enum ChannelMediaContentType + { + Clip = 0, + + Podcast = 1, + + Trailer = 2, + + Movie = 3, + + Episode = 4 + } +} diff --git a/MediaBrowser.Controller/Channels/IChannel.cs b/MediaBrowser.Controller/Channels/IChannel.cs new file mode 100644 index 000000000..ba1bd4083 --- /dev/null +++ b/MediaBrowser.Controller/Channels/IChannel.cs @@ -0,0 +1,59 @@ +using MediaBrowser.Controller.Entities; +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Channels +{ + public interface IChannel + { + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; } + + /// <summary> + /// Gets the home page URL. + /// </summary> + /// <value>The home page URL.</value> + string HomePageUrl { get; } + + /// <summary> + /// Gets the capabilities. + /// </summary> + /// <returns>ChannelCapabilities.</returns> + ChannelCapabilities GetCapabilities(); + + /// <summary> + /// Searches the specified search term. + /// </summary> + /// <param name="searchTerm">The search term.</param> + /// <param name="user">The user.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItemInfo}}.</returns> + Task<IEnumerable<ChannelItemInfo>> Search(string searchTerm, User user, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel items. + /// </summary> + /// <param name="user">The user.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItem}}.</returns> + Task<IEnumerable<ChannelItemInfo>> GetChannelItems(User user, CancellationToken cancellationToken); + + /// <summary> + /// Gets the channel items. + /// </summary> + /// <param name="categoryId">The category identifier.</param> + /// <param name="user">The user.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task{IEnumerable{ChannelItem}}.</returns> + Task<IEnumerable<ChannelItemInfo>> GetChannelItems(string categoryId, User user, CancellationToken cancellationToken); + } + + public class ChannelCapabilities + { + public bool CanSearch { get; set; } + } +} diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs new file mode 100644 index 000000000..561ab555b --- /dev/null +++ b/MediaBrowser.Controller/Channels/IChannelManager.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MediaBrowser.Controller.Channels +{ + public interface IChannelManager + { + } +} diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index fd5ccac5b..606b51628 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -73,5 +73,26 @@ namespace MediaBrowser.Controller.Dto /// <param name="owner">The owner.</param> /// <returns>Task{BaseItemDto}.</returns> BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null); + + /// <summary> + /// Gets the item by name dto. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="fields">The fields.</param> + /// <param name="user">The user.</param> + /// <returns>BaseItemDto.</returns> + BaseItemDto GetItemByNameDto<T>(T item, List<ItemFields> fields, User user = null) + where T : BaseItem, IItemByName; + + /// <summary> + /// Gets the item by name dto. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="fields">The fields.</param> + /// <param name="taggedItems">The tagged items.</param> + /// <param name="user">The user.</param> + /// <returns>BaseItemDto.</returns> + BaseItemDto GetItemByNameDto<T>(T item, List<ItemFields> fields, List<BaseItem> taggedItems, User user = null) + where T : BaseItem, IItemByName; } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 73e276f3b..8eb6236d1 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -66,6 +66,24 @@ namespace MediaBrowser.Controller.Entities.Audio /// <value>The artist.</value> public List<string> Artists { get; set; } + [IgnoreDataMember] + public List<string> AllArtists + { + get + { + var list = new List<string>(); + + if (!string.IsNullOrEmpty(AlbumArtist)) + { + list.Add(AlbumArtist); + } + list.AddRange(Artists); + + return list; + + } + } + /// <summary> /// Gets or sets the album. /// </summary> diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 11cf441f7..0a5d8eec0 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -1,12 +1,10 @@ using MediaBrowser.Common.Progress; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Linq; -using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; @@ -17,9 +15,6 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasTags, IHasProductionLocations, IHasLookupInfo<ArtistInfo> { - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - public bool IsAccessedByName { get; set; } /// <summary> @@ -65,7 +60,6 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicArtist() { - UserItemCountList = new List<ItemByNameCounts>(); Tags = new List<string>(); ProductionLocations = new List<string>(); } @@ -230,5 +224,10 @@ namespace MediaBrowser.Controller.Entities.Audio return info; } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.OfType<IHasArtist>().Where(i => i.HasArtist(Name)).Cast<BaseItem>(); + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 5e1d4c3c9..bce9da4d1 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -1,7 +1,6 @@ -using System.Runtime.Serialization; -using MediaBrowser.Model.Dto; -using System; +using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Entities.Audio { @@ -10,11 +9,6 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> public class MusicGenre : BaseItem, IItemByName { - public MusicGenre() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets the user data key. /// </summary> @@ -24,9 +18,6 @@ namespace MediaBrowser.Controller.Entities.Audio return "MusicGenre-" + Name; } - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself @@ -51,5 +42,10 @@ namespace MediaBrowser.Controller.Entities.Audio return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.Where(i => (i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase)); + } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 3a3c575cd..825468954 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,16 +1,11 @@ -using MediaBrowser.Model.Dto; +using System; using System.Collections.Generic; -using System.Runtime.Serialization; +using System.Linq; namespace MediaBrowser.Controller.Entities { public class GameGenre : BaseItem, IItemByName { - public GameGenre() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets the user data key. /// </summary> @@ -20,9 +15,6 @@ namespace MediaBrowser.Controller.Entities return "GameGenre-" + Name; } - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself @@ -47,5 +39,10 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.Where(i => (i is Game) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase)); + } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index c15ca0aa2..05442f2b7 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -1,6 +1,7 @@ -using MediaBrowser.Model.Dto; +using MediaBrowser.Controller.Entities.Audio; +using System; using System.Collections.Generic; -using System.Runtime.Serialization; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -9,11 +10,6 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Genre : BaseItem, IItemByName { - public Genre() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets the user data key. /// </summary> @@ -23,9 +19,6 @@ namespace MediaBrowser.Controller.Entities return "Genre-" + Name; } - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself @@ -50,5 +43,10 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.Where(i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase)); + } } } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index 1e83c7466..70d5b840f 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -1,7 +1,4 @@ -using MediaBrowser.Model.Dto; -using System; -using System.Collections.Generic; -using System.Linq; +using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { @@ -10,37 +7,16 @@ namespace MediaBrowser.Controller.Entities /// </summary> public interface IItemByName { - List<ItemByNameCounts> UserItemCountList { get; set; } + /// <summary> + /// Gets the tagged items. + /// </summary> + /// <param name="inputItems">The input items.</param> + /// <returns>IEnumerable{BaseItem}.</returns> + IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems); } public interface IHasDualAccess : IItemByName { bool IsAccessedByName { get; } } - - public static class ItemByNameExtensions - { - public static ItemByNameCounts GetItemByNameCounts(this IItemByName item, Guid userId) - { - if (userId == Guid.Empty) - { - throw new ArgumentNullException("userId"); - } - - return item.UserItemCountList.FirstOrDefault(i => i.UserId == userId); - } - - public static void SetItemByNameCounts(this IItemByName item, Guid userId, ItemByNameCounts counts) - { - var current = item.UserItemCountList.FirstOrDefault(i => i.UserId == userId); - - if (current != null) - { - item.UserItemCountList.Remove(current); - } - - counts.UserId = userId; - item.UserItemCountList.Add(counts); - } - } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index c1dc81136..1def47391 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,7 +1,7 @@ using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Dto; +using System; using System.Collections.Generic; -using System.Runtime.Serialization; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -10,19 +10,11 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Person : BaseItem, IItemByName, IHasLookupInfo<PersonLookupInfo> { - public Person() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets or sets the place of birth. /// </summary> /// <value>The place of birth.</value> public string PlaceOfBirth { get; set; } - - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } /// <summary> /// Gets the user data key. @@ -62,6 +54,11 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.Where(i => i.People.Any(p => string.Equals(p.Name, Name, StringComparison.OrdinalIgnoreCase))); + } } /// <summary> diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 5c3946f9b..8271a3df2 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,7 +1,6 @@ -using System.Runtime.Serialization; -using MediaBrowser.Model.Dto; -using System; +using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -10,11 +9,6 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Studio : BaseItem, IItemByName { - public Studio() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets the user data key. /// </summary> @@ -24,9 +18,6 @@ namespace MediaBrowser.Controller.Entities return "Studio-" + Name; } - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself @@ -51,5 +42,10 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return inputItems.Where(i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase)); + } } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index c6ca028ae..8deb930e8 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -1,7 +1,6 @@ -using System.Runtime.Serialization; -using MediaBrowser.Model.Dto; -using System; -using System.Collections.Generic; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; namespace MediaBrowser.Controller.Entities { @@ -10,14 +9,6 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Year : BaseItem, IItemByName { - public Year() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Gets the user data key. /// </summary> @@ -51,5 +42,19 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + int year; + + var usCulture = new CultureInfo("en-US"); + + if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year)) + { + return inputItems; + } + + return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year); + } } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 747ae48ad..9bde9aa29 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -305,19 +305,6 @@ namespace MediaBrowser.Controller.Library string FindCollectionType(BaseItem item); /// <summary> - /// Gets all artists. - /// </summary> - /// <returns>IEnumerable{System.String}.</returns> - IEnumerable<string> GetAllArtists(); - - /// <summary> - /// Gets all artists. - /// </summary> - /// <param name="items">The items.</param> - /// <returns>IEnumerable{System.String}.</returns> - IEnumerable<string> GetAllArtists(IEnumerable<BaseItem> items); - - /// <summary> /// Normalizes the root path list. /// </summary> /// <param name="paths">The paths.</param> diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index ad42c5091..dddd26358 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -138,13 +138,6 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="id">The identifier.</param> /// <returns>Channel.</returns> LiveTvChannel GetInternalChannel(string id); - - /// <summary> - /// Gets the internal program. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>LiveTvProgram.</returns> - LiveTvProgram GetInternalProgram(string id); /// <summary> /// Gets the recording. diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index ff5d6a4d2..3e6832123 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -1,20 +1,13 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; -using MediaBrowser.Model.Dto; using MediaBrowser.Model.LiveTv; using System.Collections.Generic; -using System.Runtime.Serialization; using System.Linq; namespace MediaBrowser.Controller.LiveTv { public class LiveTvChannel : BaseItem, IItemByName { - public LiveTvChannel() - { - UserItemCountList = new List<ItemByNameCounts>(); - } - /// <summary> /// Gets the user data key. /// </summary> @@ -24,9 +17,6 @@ namespace MediaBrowser.Controller.LiveTv return GetClientTypeName() + "-" + Name; } - [IgnoreDataMember] - public List<ItemByNameCounts> UserItemCountList { get; set; } - /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself @@ -119,5 +109,10 @@ namespace MediaBrowser.Controller.LiveTv { return "Channel"; } + + public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems) + { + return new List<BaseItem>(); + } } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 100ac9f4c..16c54861e 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -68,6 +68,9 @@ <Compile Include="..\SharedVersion.cs"> <Link>Properties\SharedVersion.cs</Link> </Compile> + <Compile Include="Channels\ChannelItemInfo.cs" /> + <Compile Include="Channels\IChannel.cs" /> + <Compile Include="Channels\IChannelManager.cs" /> <Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\ICollectionManager.cs" /> <Compile Include="Drawing\IImageProcessor.cs" /> diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 892ec9345..ee29671c0 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -77,6 +77,13 @@ namespace MediaBrowser.Controller.Session Task OnPlaybackStopped(PlaybackStopInfo info); /// <summary> + /// Reports the session ended. + /// </summary> + /// <param name="sessionId">The session identifier.</param> + /// <returns>Task.</returns> + Task ReportSessionEnded(Guid sessionId); + + /// <summary> /// Sends the system command. /// </summary> /// <param name="sessionId">The session id.</param> |
