From 1e532d4f53bd65fc1dca3ec8cc6408f1b1efdc02 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 23 May 2014 19:58:28 -0400 Subject: [PATCH] factor device pixel ratio into downloaded image size --- MediaBrowser.Api/Images/ImageByNameService.cs | 10 ++--- MediaBrowser.Api/LiveTv/LiveTvService.cs | 10 ++++- .../Channels/ChannelAudioItem.cs | 5 --- .../Channels/ChannelFolderItem.cs | 5 --- .../Channels/ChannelVideoItem.cs | 5 --- MediaBrowser.Controller/Channels/IChannel.cs | 18 +++++++- .../Channels/InternalChannelItemQuery.cs | 10 +++++ .../MediaBrowser.Model.Portable.csproj | 3 ++ .../MediaBrowser.Model.net35.csproj | 3 ++ MediaBrowser.Model/ApiClient/IApiClient.cs | 24 +++++++++++ .../Channels/ChannelFeatures.cs | 43 +++++++++++++++++++ MediaBrowser.Model/Channels/ChannelInfo.cs | 39 ++++++++--------- .../Channels/ChannelItemQuery.cs | 1 + .../Configuration/ServerConfiguration.cs | 9 +++- MediaBrowser.Model/LiveTv/ChannelQuery.cs | 12 ++++++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../TV/TvdbEpisodeProvider.cs | 6 ++- .../Channels/ChannelManager.cs | 10 ++--- .../Dto/MediaStreamSelector.cs | 18 +++----- .../LiveTv/LiveTvManager.cs | 26 +++++++++++ .../Localization/Server/server.json | 3 +- Nuget/MediaBrowser.Common.Internal.nuspec | 4 +- Nuget/MediaBrowser.Common.nuspec | 2 +- Nuget/MediaBrowser.Server.Core.nuspec | 4 +- 24 files changed, 200 insertions(+), 71 deletions(-) create mode 100644 MediaBrowser.Model/Channels/ChannelFeatures.cs diff --git a/MediaBrowser.Api/Images/ImageByNameService.cs b/MediaBrowser.Api/Images/ImageByNameService.cs index c741dd8a8..8c543c8c2 100644 --- a/MediaBrowser.Api/Images/ImageByNameService.cs +++ b/MediaBrowser.Api/Images/ImageByNameService.cs @@ -118,20 +118,20 @@ namespace MediaBrowser.Api.Images public object Get(GetMediaInfoImages request) { - return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath)); + return ToOptimizedResult(GetImageList(_appPaths.MediaInfoImagesPath, true)); } public object Get(GetRatingImages request) { - return ToOptimizedResult(GetImageList(_appPaths.RatingsPath)); + return ToOptimizedResult(GetImageList(_appPaths.RatingsPath, true)); } public object Get(GetGeneralImages request) { - return ToOptimizedResult(GetImageList(_appPaths.GeneralPath)); + return ToOptimizedResult(GetImageList(_appPaths.GeneralPath, false)); } - private List GetImageList(string path) + private List GetImageList(string path, bool supportsThemes) { try { @@ -142,7 +142,7 @@ namespace MediaBrowser.Api.Images { Name = Path.GetFileNameWithoutExtension(i.FullName), FileLength = i.Length, - Theme = GetThemeName(i.FullName, path), + Theme = supportsThemes ? GetThemeName(i.FullName, path) : null, Format = i.Extension.ToLower().TrimStart('.') }) .OrderBy(i => i.Name) diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index abeaba910..a6074e529 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -42,6 +42,12 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "IsFavorite", Description = "Filter by channels that are favorites, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] public bool? IsFavorite { get; set; } + + [ApiMember(Name = "IsLiked", Description = "Filter by channels that are liked, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsLiked { get; set; } + + [ApiMember(Name = "IsDisliked", Description = "Filter by channels that are disliked, or not.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")] + public bool? IsDisliked { get; set; } } [Route("/LiveTv/Channels/{Id}", "GET", Summary = "Gets a live tv channel")] @@ -294,7 +300,9 @@ namespace MediaBrowser.Api.LiveTv UserId = request.UserId, StartIndex = request.StartIndex, Limit = request.Limit, - IsFavorite = request.IsFavorite + IsFavorite = request.IsFavorite, + IsLiked = request.IsLiked, + IsDisliked = request.IsDisliked }, CancellationToken.None).Result; diff --git a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs index f62573780..7072d4284 100644 --- a/MediaBrowser.Controller/Channels/ChannelAudioItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelAudioItem.cs @@ -53,10 +53,5 @@ namespace MediaBrowser.Controller.Channels return base.LocationType; } } - - public override string GetClientTypeName() - { - return "audio.channelItem"; - } } } diff --git a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs index 56262ab20..3b66e52ce 100644 --- a/MediaBrowser.Controller/Channels/ChannelFolderItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelFolderItem.cs @@ -33,10 +33,5 @@ namespace MediaBrowser.Controller.Channels { Tags = new List(); } - - public override string GetClientTypeName() - { - return "folder.channelItem"; - } } } diff --git a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs index 6d0497c4d..572e316a0 100644 --- a/MediaBrowser.Controller/Channels/ChannelVideoItem.cs +++ b/MediaBrowser.Controller/Channels/ChannelVideoItem.cs @@ -77,10 +77,5 @@ namespace MediaBrowser.Controller.Channels return base.LocationType; } } - - public override string GetClientTypeName() - { - return "video.channelItem"; - } } } diff --git a/MediaBrowser.Controller/Channels/IChannel.cs b/MediaBrowser.Controller/Channels/IChannel.cs index 527454284..7f03579f3 100644 --- a/MediaBrowser.Controller/Channels/IChannel.cs +++ b/MediaBrowser.Controller/Channels/IChannel.cs @@ -22,11 +22,17 @@ namespace MediaBrowser.Controller.Channels /// The data version. string DataVersion { get; } + /// + /// Gets the home page URL. + /// + /// The home page URL. + string HomePageUrl { get; } + /// /// Gets the channel information. /// - /// ChannelInfo. - ChannelInfo GetChannelInfo(); + /// ChannelFeatures. + ChannelFeatures GetChannelFeatures(); /// /// Determines whether [is enabled for] [the specified user]. @@ -52,6 +58,14 @@ namespace MediaBrowser.Controller.Channels /// Task{IEnumerable{ChannelItem}}. Task GetChannelItems(InternalChannelItemQuery query, CancellationToken cancellationToken); + /// + /// Gets all media. + /// + /// The query. + /// The cancellation token. + /// Task{ChannelItemResult}. + Task GetAllMedia(InternalAllChannelItemsQuery query, CancellationToken cancellationToken); + /// /// Gets the channel image. /// diff --git a/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs b/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs index aa8e7b9f1..4f032fe91 100644 --- a/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs +++ b/MediaBrowser.Controller/Channels/InternalChannelItemQuery.cs @@ -12,4 +12,14 @@ namespace MediaBrowser.Controller.Channels public int? Limit { get; set; } } + + public class InternalAllChannelItemsQuery + { + public User User { get; set; } + + public int? StartIndex { get; set; } + + public int? Limit { get; set; } + } + } \ No newline at end of file diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index c66d58ea6..561d0d9e4 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -77,6 +77,9 @@ ApiClient\SessionUpdatesEventArgs.cs + + Channels\ChannelFeatures.cs + Channels\ChannelInfo.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 677c78309..92f0afb53 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -64,6 +64,9 @@ ApiClient\SessionUpdatesEventArgs.cs + + Channels\ChannelFeatures.cs + Channels\ChannelInfo.cs diff --git a/MediaBrowser.Model/ApiClient/IApiClient.cs b/MediaBrowser.Model/ApiClient/IApiClient.cs index e12a6cf2b..02dce0f6b 100644 --- a/MediaBrowser.Model/ApiClient/IApiClient.cs +++ b/MediaBrowser.Model/ApiClient/IApiClient.cs @@ -59,6 +59,30 @@ namespace MediaBrowser.Model.ApiClient Task GetAsync(string url, CancellationToken cancellationToken) where T : class; + /// + /// Gets the url needed to stream an audio file + /// + /// The options. + /// System.String. + /// options + string GetAudioStreamUrl(StreamOptions options); + + /// + /// Gets the url needed to stream a video file + /// + /// The options. + /// System.String. + /// options + string GetVideoStreamUrl(VideoStreamOptions options); + + /// + /// Formulates a url for streaming video using the HLS protocol + /// + /// The options. + /// System.String. + /// options + string GetHlsVideoStreamUrl(VideoStreamOptions options); + /// /// Reports the capabilities. /// diff --git a/MediaBrowser.Model/Channels/ChannelFeatures.cs b/MediaBrowser.Model/Channels/ChannelFeatures.cs new file mode 100644 index 000000000..dbfab87db --- /dev/null +++ b/MediaBrowser.Model/Channels/ChannelFeatures.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Model.Channels +{ + public class ChannelFeatures + { + /// + /// Gets or sets a value indicating whether this instance can search. + /// + /// true if this instance can search; otherwise, false. + public bool CanSearch { get; set; } + + /// + /// Gets or sets a value indicating whether this instance can index all media. + /// + /// true if this instance can index all media; otherwise, false. + public bool CanGetAllMedia { get; set; } + + /// + /// Gets or sets the media types. + /// + /// The media types. + public List MediaTypes { get; set; } + + /// + /// Gets or sets the content types. + /// + /// The content types. + public List ContentTypes { get; set; } + + /// + /// Represents the maximum number of records the channel allows retrieving at a time + /// + public int? MaxPageSize { get; set; } + + public ChannelFeatures() + { + MediaTypes = new List(); + ContentTypes = new List(); + } + } + +} diff --git a/MediaBrowser.Model/Channels/ChannelInfo.cs b/MediaBrowser.Model/Channels/ChannelInfo.cs index 2ebfb432a..36e3c17d9 100644 --- a/MediaBrowser.Model/Channels/ChannelInfo.cs +++ b/MediaBrowser.Model/Channels/ChannelInfo.cs @@ -1,35 +1,30 @@ -using System.Collections.Generic; - + namespace MediaBrowser.Model.Channels { public class ChannelInfo { /// - /// Gets the home page URL. + /// Gets or sets the name. + /// + /// The name. + public string Name { get; set; } + + /// + /// Gets or sets the identifier. + /// + /// The identifier. + public string Id { get; set; } + + /// + /// Gets or sets the home page URL. /// /// The home page URL. public string HomePageUrl { get; set; } /// - /// Gets or sets a value indicating whether this instance can search. + /// Gets or sets the features. /// - /// true if this instance can search; otherwise, false. - public bool CanSearch { get; set; } - - public List MediaTypes { get; set; } - - public List ContentTypes { get; set; } - - /// - /// Represents the maximum number of records the channel allows retrieving at a time - /// - public int? MaxPageSize { get; set; } - - public ChannelInfo() - { - MediaTypes = new List(); - ContentTypes = new List(); - } + /// The features. + public ChannelFeatures Features { get; set; } } - } diff --git a/MediaBrowser.Model/Channels/ChannelItemQuery.cs b/MediaBrowser.Model/Channels/ChannelItemQuery.cs index 632db5581..0cabe1d04 100644 --- a/MediaBrowser.Model/Channels/ChannelItemQuery.cs +++ b/MediaBrowser.Model/Channels/ChannelItemQuery.cs @@ -45,4 +45,5 @@ namespace MediaBrowser.Model.Channels SortBy = new string[] { }; } } + } \ No newline at end of file diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index c19039439..4fe5c8bcf 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -170,8 +170,8 @@ namespace MediaBrowser.Model.Configuration public bool EnableTmdbUpdates { get; set; } public bool EnableFanArtUpdates { get; set; } - public bool RequireManualLoginForMobileApps { get; set; } - public bool RequireManualLoginForOtherApps { get; set; } + public bool RequireMobileManualLogin { get; set; } + public bool RequireNonMobileManualLogin { get; set; } /// /// Gets or sets the image saving convention. @@ -223,6 +223,9 @@ namespace MediaBrowser.Model.Configuration public SubtitleOptions SubtitleOptions { get; set; } + [Obsolete] + public string[] ManualLoginClients { get; set; } + /// /// Initializes a new instance of the class. /// @@ -263,6 +266,8 @@ namespace MediaBrowser.Model.Configuration SortRemoveCharacters = new[] { ",", "&", "-", "{", "}", "'" }; SortRemoveWords = new[] { "the", "a", "an" }; + ManualLoginClients = new string[] { }; + SeasonZeroDisplayName = "Specials"; LiveTvOptions = new LiveTvOptions(); diff --git a/MediaBrowser.Model/LiveTv/ChannelQuery.cs b/MediaBrowser.Model/LiveTv/ChannelQuery.cs index 9079ebacd..6d986d337 100644 --- a/MediaBrowser.Model/LiveTv/ChannelQuery.cs +++ b/MediaBrowser.Model/LiveTv/ChannelQuery.cs @@ -17,6 +17,18 @@ namespace MediaBrowser.Model.LiveTv /// /// null if [is favorite] contains no value, true if [is favorite]; otherwise, false. public bool? IsFavorite { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is liked. + /// + /// null if [is liked] contains no value, true if [is liked]; otherwise, false. + public bool? IsLiked { get; set; } + + /// + /// Gets or sets a value indicating whether this instance is disliked. + /// + /// null if [is disliked] contains no value, true if [is disliked]; otherwise, false. + public bool? IsDisliked { get; set; } /// /// Gets or sets the user identifier. diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index f6f7666c7..c98db03c0 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -59,6 +59,7 @@ + diff --git a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs index 922c29fe9..ba7455e23 100644 --- a/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbEpisodeProvider.cs @@ -609,10 +609,14 @@ namespace MediaBrowser.Providers.TV var roles = nameGroup.Count() > 1 ? nameGroup[1].Trim() : null; if (roles != null) roles = roles.EndsWith(")") ? roles.Substring(0, roles.Length - 1) : roles; + return new PersonInfo { Type = PersonType.GuestStar, Name = name, Role = roles }; })) { - item.AddPerson(person); + if (!string.IsNullOrWhiteSpace(person.Name)) + { + item.AddPerson(person); + } } } diff --git a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs index db5c6b439..355ac43fc 100644 --- a/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs +++ b/MediaBrowser.Server.Implementations/Channels/ChannelManager.cs @@ -215,9 +215,7 @@ namespace MediaBrowser.Server.Implementations.Channels isNew = true; } - var info = channelInfo.GetChannelInfo(); - - item.HomePageUrl = info.HomePageUrl; + item.HomePageUrl = channelInfo.HomePageUrl; item.OriginalChannelName = channelInfo.Name; if (string.IsNullOrEmpty(item.Name)) @@ -258,7 +256,7 @@ namespace MediaBrowser.Server.Implementations.Channels // Find the corresponding channel provider plugin var channelProvider = GetChannelProvider(channel); - var channelInfo = channelProvider.GetChannelInfo(); + var channelInfo = channelProvider.GetChannelFeatures(); int? providerStartIndex = null; int? providerLimit = null; @@ -448,7 +446,7 @@ namespace MediaBrowser.Server.Implementations.Channels { // Increment this as needed to force new downloads // Incorporate Name because it's being used to convert channel entity to provider - return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "12"; + return externalId + (channelProvider.DataVersion ?? string.Empty) + (channelProvider.Name ?? string.Empty) + "13"; } private async Task GetChannelItemEntity(ChannelItemInfo info, IChannel channelProvider, Channel internalChannel, CancellationToken cancellationToken) @@ -473,7 +471,7 @@ namespace MediaBrowser.Server.Implementations.Channels } else if (info.MediaType == ChannelMediaType.Audio) { - id = idToHash.GetMBId(typeof(ChannelFolderItem)); + id = idToHash.GetMBId(typeof(ChannelAudioItem)); item = _libraryManager.GetItemById(id) as ChannelAudioItem; diff --git a/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs b/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs index e5a859cdc..10c78b300 100644 --- a/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs +++ b/MediaBrowser.Server.Implementations/Dto/MediaStreamSelector.cs @@ -64,7 +64,7 @@ namespace MediaBrowser.Server.Implementations.Dto // always load the most suitable full subtitles stream = full.FirstOrDefault(); } - + // load forced subs if we have found no suitable full subtitles stream = stream ?? forced.FirstOrDefault(); @@ -86,17 +86,13 @@ namespace MediaBrowser.Server.Implementations.Dto var orderStreams = streams .Where(i => i.Type == type); - if (languagePreferences.Count == 0) - { - return orderStreams.OrderBy(i => i.IsDefault) - .ThenBy(i => i.Index) - .ToList(); - } - + // Give some preferance to external text subs for better performance return orderStreams.OrderBy(i => languagePreferences.FindIndex(l => string.Equals(i.Language, l, StringComparison.OrdinalIgnoreCase))) - .ThenBy(i => i.IsDefault) - .ThenBy(i => i.Index) - .ToList(); + .ThenBy(i => i.IsDefault) + .ThenBy(i => !i.IsGraphicalSubtitleStream) + .ThenBy(i => i.IsExternal) + .ThenBy(i => i.Index) + .ToList(); } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index daed33436..f72cfc7df 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -150,6 +150,32 @@ namespace MediaBrowser.Server.Implementations.LiveTv channels = channels .Where(i => _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).IsFavorite == val); } + + if (query.IsLiked.HasValue) + { + var val = query.IsLiked.Value; + + channels = channels + .Where(i => + { + var likes = _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Likes; + + return likes.HasValue && likes.Value == val; + }); + } + + if (query.IsDisliked.HasValue) + { + var val = query.IsDisliked.Value; + + channels = channels + .Where(i => + { + var likes = _userDataManager.GetUserData(user.Id, i.GetUserDataKey()).Likes; + + return likes.HasValue && likes.Value != val; + }); + } } channels = channels.OrderBy(i => diff --git a/MediaBrowser.Server.Implementations/Localization/Server/server.json b/MediaBrowser.Server.Implementations/Localization/Server/server.json index 7658b07f1..019039725 100644 --- a/MediaBrowser.Server.Implementations/Localization/Server/server.json +++ b/MediaBrowser.Server.Implementations/Localization/Server/server.json @@ -785,5 +785,6 @@ "HeaderLiveTv": "Live TV", "HeaderReports": "Reports", "HeaderMetadataManager": "Metadata Manager", - "HeaderPreferences": "Preferences" + "HeaderPreferences": "Preferences", + "MessageLoadingChannels": "Loading channel content..." } \ No newline at end of file diff --git a/Nuget/MediaBrowser.Common.Internal.nuspec b/Nuget/MediaBrowser.Common.Internal.nuspec index 5f90fd709..2f54f7952 100644 --- a/Nuget/MediaBrowser.Common.Internal.nuspec +++ b/Nuget/MediaBrowser.Common.Internal.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common.Internal - 3.0.374 + 3.0.378 MediaBrowser.Common.Internal Luke ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption. Copyright © Media Browser 2013 - + diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index bb936bc0c..4155976b4 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.374 + 3.0.378 MediaBrowser.Common Media Browser Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index e3bc343ab..38111ed1a 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.374 + 3.0.378 Media Browser.Server.Core Media Browser Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Media Browser Server. Copyright © Media Browser 2013 - +