add additional view settings

This commit is contained in:
Luke Pulverenti 2014-07-01 00:06:28 -04:00
parent f77209cf77
commit 43943657b7
13 changed files with 114 additions and 40 deletions

View File

@ -38,5 +38,12 @@ namespace MediaBrowser.Controller.Collections
/// <param name="user">The user.</param> /// <param name="user">The user.</param>
/// <returns>IEnumerable{BaseItem}.</returns> /// <returns>IEnumerable{BaseItem}.</returns>
IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user); IEnumerable<BaseItem> CollapseItemsWithinBoxSets(IEnumerable<BaseItem> items, User user);
/// <summary>
/// Gets the collections folder.
/// </summary>
/// <param name="userId">The user identifier.</param>
/// <returns>Folder.</returns>
Folder GetCollectionsFolder(string userId);
} }
} }

View File

@ -134,6 +134,11 @@ namespace MediaBrowser.Controller.Entities
} }
} }
public virtual bool IsHiddenFromUser(User user)
{
return false;
}
[IgnoreDataMember] [IgnoreDataMember]
public virtual bool IsOwnedItem public virtual bool IsOwnedItem
{ {

View File

@ -808,9 +808,12 @@ namespace MediaBrowser.Controller.Entities
if (child.IsVisible(user)) if (child.IsVisible(user))
{ {
if (filter == null || filter(child)) if (filter == null || filter(child))
{
if (!child.IsHiddenFromUser(user))
{ {
list.Add(child); list.Add(child);
} }
}
if (recursive && child.IsFolder) if (recursive && child.IsFolder)
{ {

View File

@ -1,6 +1,4 @@
using System; using MediaBrowser.Model.Extensions;
using System.Linq;
using MediaBrowser.Model.Extensions;
namespace MediaBrowser.Model.Configuration namespace MediaBrowser.Model.Configuration
{ {
@ -90,7 +88,7 @@ namespace MediaBrowser.Model.Configuration
NotificationOption opt = GetOptions(notificationType); NotificationOption opt = GetOptions(notificationType);
return opt == null || return opt == null ||
!opt.DisabledServices.Contains(service, StringComparer.OrdinalIgnoreCase); !ListHelper.ContainsIgnoreCase(opt.DisabledServices, service);
} }
public bool IsEnabledToMonitorUser(string type, string userId) public bool IsEnabledToMonitorUser(string type, string userId)
@ -98,7 +96,7 @@ namespace MediaBrowser.Model.Configuration
NotificationOption opt = GetOptions(type); NotificationOption opt = GetOptions(type);
return opt != null && opt.Enabled && return opt != null && opt.Enabled &&
!opt.DisabledMonitorUsers.Contains(userId, StringComparer.OrdinalIgnoreCase); !ListHelper.ContainsIgnoreCase(opt.DisabledMonitorUsers, userId);
} }
public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig) public bool IsEnabledToSendToUser(string type, string userId, UserConfiguration userConfig)
@ -117,7 +115,7 @@ namespace MediaBrowser.Model.Configuration
return true; return true;
} }
return opt.SendToUsers.Contains(userId, StringComparer.OrdinalIgnoreCase); return ListHelper.ContainsIgnoreCase(opt.SendToUsers, userId);
} }
return false; return false;

View File

@ -72,6 +72,7 @@ namespace MediaBrowser.Model.Configuration
public UnratedItem[] BlockUnratedItems { get; set; } public UnratedItem[] BlockUnratedItems { get; set; }
public SubtitlePlaybackMode SubtitleMode { get; set; } public SubtitlePlaybackMode SubtitleMode { get; set; }
public bool DisplayCollectionsView { get; set; }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="UserConfiguration" /> class. /// Initializes a new instance of the <see cref="UserConfiguration" /> class.
@ -92,6 +93,8 @@ namespace MediaBrowser.Model.Configuration
BlockUnratedItems = new UnratedItem[] { }; BlockUnratedItems = new UnratedItem[] { };
ExcludeFoldersFromGrouping = new string[] { }; ExcludeFoldersFromGrouping = new string[] { };
DisplayCollectionsView = true;
} }
} }
} }

View File

@ -115,7 +115,7 @@ namespace MediaBrowser.Model.Dlna
public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec) public TranscodingProfile GetAudioTranscodingProfile(string container, string audioCodec)
{ {
container = (container ?? string.Empty).TrimStart('.'); container = StringHelper.TrimStart((container ?? string.Empty), '.');
foreach (var i in TranscodingProfiles) foreach (var i in TranscodingProfiles)
{ {
@ -141,7 +141,7 @@ namespace MediaBrowser.Model.Dlna
public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec) public TranscodingProfile GetVideoTranscodingProfile(string container, string audioCodec, string videoCodec)
{ {
container = (container ?? string.Empty).TrimStart('.'); container = StringHelper.TrimStart((container ?? string.Empty), '.');
foreach (var i in TranscodingProfiles) foreach (var i in TranscodingProfiles)
{ {
@ -172,7 +172,7 @@ namespace MediaBrowser.Model.Dlna
public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate) public ResponseProfile GetAudioMediaProfile(string container, string audioCodec, int? audioChannels, int? audioBitrate)
{ {
container = (container ?? string.Empty).TrimStart('.'); container = StringHelper.TrimStart((container ?? string.Empty), '.');
foreach (var i in ResponseProfiles) foreach (var i in ResponseProfiles)
{ {
@ -217,7 +217,7 @@ namespace MediaBrowser.Model.Dlna
public ResponseProfile GetImageMediaProfile(string container, int? width, int? height) public ResponseProfile GetImageMediaProfile(string container, int? width, int? height)
{ {
container = (container ?? string.Empty).TrimStart('.'); container = StringHelper.TrimStart((container ?? string.Empty), '.');
foreach (var i in ResponseProfiles) foreach (var i in ResponseProfiles)
{ {
@ -270,7 +270,7 @@ namespace MediaBrowser.Model.Dlna
TransportStreamTimestamp timestamp, TransportStreamTimestamp timestamp,
bool? isAnamorphic) bool? isAnamorphic)
{ {
container = (container ?? string.Empty).TrimStart('.'); container = StringHelper.TrimStart((container ?? string.Empty), '.');
foreach (var i in ResponseProfiles) foreach (var i in ResponseProfiles)
{ {

View File

@ -136,7 +136,12 @@ namespace MediaBrowser.Model.Dlna
foreach (CodecProfile i in options.Profile.CodecProfiles) foreach (CodecProfile i in options.Profile.CodecProfiles)
{ {
if (i.Type == CodecType.Audio && i.ContainsCodec(audioCodec)) if (i.Type == CodecType.Audio && i.ContainsCodec(audioCodec))
conditions.AddRange(i.Conditions); {
foreach (var c in i.Conditions)
{
conditions.Add(c);
}
}
} }
int? audioChannels = audioStream.Channels; int? audioChannels = audioStream.Channels;
@ -195,7 +200,12 @@ namespace MediaBrowser.Model.Dlna
List<ProfileCondition> audioTranscodingConditions = new List<ProfileCondition>(); List<ProfileCondition> audioTranscodingConditions = new List<ProfileCondition>();
foreach (CodecProfile i in audioCodecProfiles) foreach (CodecProfile i in audioCodecProfiles)
audioTranscodingConditions.AddRange(i.Conditions); {
foreach (var c in i.Conditions)
{
audioTranscodingConditions.Add(c);
}
}
ApplyTranscodingConditions(playlistItem, audioTranscodingConditions); ApplyTranscodingConditions(playlistItem, audioTranscodingConditions);
@ -276,7 +286,10 @@ namespace MediaBrowser.Model.Dlna
{ {
if (i.Type == CodecType.Video && i.ContainsCodec(transcodingProfile.VideoCodec)) if (i.Type == CodecType.Video && i.ContainsCodec(transcodingProfile.VideoCodec))
{ {
videoTranscodingConditions.AddRange(i.Conditions); foreach (var c in i.Conditions)
{
videoTranscodingConditions.Add(c);
}
break; break;
} }
} }
@ -287,7 +300,10 @@ namespace MediaBrowser.Model.Dlna
{ {
if (i.Type == CodecType.VideoAudio && i.ContainsCodec(transcodingProfile.AudioCodec)) if (i.Type == CodecType.VideoAudio && i.ContainsCodec(transcodingProfile.AudioCodec))
{ {
audioTranscodingConditions.AddRange(i.Conditions); foreach (var c in i.Conditions)
{
audioTranscodingConditions.Add(c);
}
break; break;
} }
} }
@ -363,7 +379,10 @@ namespace MediaBrowser.Model.Dlna
if (i.Type == DlnaProfileType.Video && if (i.Type == DlnaProfileType.Video &&
ListHelper.ContainsIgnoreCase(i.GetContainers(), container)) ListHelper.ContainsIgnoreCase(i.GetContainers(), container))
{ {
conditions.AddRange(i.Conditions); foreach (var c in i.Conditions)
{
conditions.Add(c);
}
} }
} }
@ -405,7 +424,12 @@ namespace MediaBrowser.Model.Dlna
foreach (CodecProfile i in profile.CodecProfiles) foreach (CodecProfile i in profile.CodecProfiles)
{ {
if (i.Type == CodecType.Video && i.ContainsCodec(videoCodec)) if (i.Type == CodecType.Video && i.ContainsCodec(videoCodec))
conditions.AddRange(i.Conditions); {
foreach (var c in i.Conditions)
{
conditions.Add(c);
}
}
} }
foreach (ProfileCondition i in conditions) foreach (ProfileCondition i in conditions)
@ -429,7 +453,12 @@ namespace MediaBrowser.Model.Dlna
foreach (CodecProfile i in profile.CodecProfiles) foreach (CodecProfile i in profile.CodecProfiles)
{ {
if (i.Type == CodecType.VideoAudio && i.ContainsCodec(audioCodec)) if (i.Type == CodecType.VideoAudio && i.ContainsCodec(audioCodec))
conditions.AddRange(i.Conditions); {
foreach (var c in i.Conditions)
{
conditions.Add(c);
}
}
} }
foreach (ProfileCondition i in conditions) foreach (ProfileCondition i in conditions)

View File

@ -305,8 +305,14 @@ namespace MediaBrowser.Model.Dlna
{ {
int? totalBitrate = TargetTotalBitrate; int? totalBitrate = TargetTotalBitrate;
double totalSeconds = RunTimeTicks.Value;
// Convert to ms
totalSeconds /= 10000;
// Convert to seconds
totalSeconds /= 1000;
return totalBitrate.HasValue ? return totalBitrate.HasValue ?
Convert.ToInt64(totalBitrate.Value * TimeSpan.FromTicks(RunTimeTicks.Value).TotalSeconds) : Convert.ToInt64(totalBitrate.Value * totalSeconds) :
(long?)null; (long?)null;
} }
@ -375,11 +381,14 @@ namespace MediaBrowser.Model.Dlna
Height = videoStream.Height.Value Height = videoStream.Height.Value
}; };
double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null;
double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null;
ImageSize newSize = DrawingUtils.Resize(size, ImageSize newSize = DrawingUtils.Resize(size,
null, null,
null, null,
MaxWidth, maxWidth,
MaxHeight); maxHeight);
return Convert.ToInt32(newSize.Width); return Convert.ToInt32(newSize.Width);
} }
@ -402,11 +411,14 @@ namespace MediaBrowser.Model.Dlna
Height = videoStream.Height.Value Height = videoStream.Height.Value
}; };
double? maxWidth = MaxWidth.HasValue ? (double)MaxWidth.Value : (double?)null;
double? maxHeight = MaxHeight.HasValue ? (double)MaxHeight.Value : (double?)null;
ImageSize newSize = DrawingUtils.Resize(size, ImageSize newSize = DrawingUtils.Resize(size,
null, null,
null, null,
MaxWidth, maxWidth,
MaxHeight); maxHeight);
return Convert.ToInt32(newSize.Height); return Convert.ToInt32(newSize.Height);
} }

View File

@ -59,5 +59,16 @@ namespace MediaBrowser.Model.Extensions
{ {
return val.ToString(CultureInfo.InvariantCulture); return val.ToString(CultureInfo.InvariantCulture);
} }
/// <summary>
/// Trims the start.
/// </summary>
/// <param name="str">The string.</param>
/// <param name="c">The c.</param>
/// <returns>System.String.</returns>
public static string TrimStart(string str, char c)
{
return str.TrimStart(c);
}
} }
} }

View File

@ -19,10 +19,5 @@ namespace MediaBrowser.Model.Notifications
public string Url { get; set; } public string Url { get; set; }
public NotificationLevel Level { get; set; } public NotificationLevel Level { get; set; }
public Notification()
{
Date = DateTime.UtcNow;
}
} }
} }

View File

@ -4,13 +4,13 @@ using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies; using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Providers;
using MoreLinq;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MoreLinq;
namespace MediaBrowser.Server.Implementations.Collections namespace MediaBrowser.Server.Implementations.Collections
{ {
@ -27,6 +27,12 @@ namespace MediaBrowser.Server.Implementations.Collections
_iLibraryMonitor = iLibraryMonitor; _iLibraryMonitor = iLibraryMonitor;
} }
public Folder GetCollectionsFolder(string userId)
{
return _libraryManager.RootFolder.Children.Concat(_libraryManager.RootFolder.GetHiddenChildren()).OfType<ManualCollectionsFolder>()
.FirstOrDefault();
}
public async Task<BoxSet> CreateCollection(CollectionCreationOptions options) public async Task<BoxSet> CreateCollection(CollectionCreationOptions options)
{ {
var name = options.Name; var name = options.Name;
@ -104,8 +110,7 @@ namespace MediaBrowser.Server.Implementations.Collections
} }
} }
return _libraryManager.RootFolder.Children.OfType<ManualCollectionsFolder>().FirstOrDefault() ?? return GetCollectionsFolder(string.Empty);
_libraryManager.RootFolder.GetHiddenChildren().OfType<ManualCollectionsFolder>().FirstOrDefault();
} }
public async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids) public async Task AddToCollection(Guid collectionId, IEnumerable<Guid> ids)

View File

@ -28,6 +28,11 @@ namespace MediaBrowser.Server.Implementations.Collections
} }
} }
public override bool IsHiddenFromUser(User user)
{
return true;
}
public override string CollectionType public override string CollectionType
{ {
get { return Model.Entities.CollectionType.BoxSets; } get { return Model.Entities.CollectionType.BoxSets; }

View File

@ -62,28 +62,29 @@ namespace MediaBrowser.Server.Implementations.Library
if (recursiveChildren.OfType<Series>().Any()) if (recursiveChildren.OfType<Series>().Any())
{ {
list.Add(await GetUserView(CollectionType.TvShows, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(CollectionType.TvShows, user, string.Empty, cancellationToken).ConfigureAwait(false));
} }
if (recursiveChildren.OfType<MusicAlbum>().Any() || if (recursiveChildren.OfType<MusicAlbum>().Any() ||
recursiveChildren.OfType<MusicVideo>().Any()) recursiveChildren.OfType<MusicVideo>().Any())
{ {
list.Add(await GetUserView(CollectionType.Music, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(CollectionType.Music, user, string.Empty, cancellationToken).ConfigureAwait(false));
} }
if (recursiveChildren.OfType<Movie>().Any()) if (recursiveChildren.OfType<Movie>().Any())
{ {
list.Add(await GetUserView(CollectionType.Movies, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(CollectionType.Movies, user, string.Empty, cancellationToken).ConfigureAwait(false));
} }
if (recursiveChildren.OfType<Game>().Any()) if (recursiveChildren.OfType<Game>().Any())
{ {
list.Add(await GetUserView(CollectionType.Games, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(CollectionType.Games, user, string.Empty, cancellationToken).ConfigureAwait(false));
} }
if (recursiveChildren.OfType<BoxSet>().Any()) if (user.Configuration.DisplayCollectionsView ||
recursiveChildren.OfType<BoxSet>().Any())
{ {
list.Add(await GetUserView(CollectionType.BoxSets, user, cancellationToken).ConfigureAwait(false)); list.Add(await GetUserView(CollectionType.BoxSets, user, "zzz_" + CollectionType.BoxSets, cancellationToken).ConfigureAwait(false));
} }
if (query.IncludeExternalContent) if (query.IncludeExternalContent)
@ -116,11 +117,11 @@ namespace MediaBrowser.Server.Implementations.Library
return list.OrderBy(i => i.SortName); return list.OrderBy(i => i.SortName);
} }
private Task<UserView> GetUserView(string type, User user, CancellationToken cancellationToken) private Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken)
{ {
var name = _localizationManager.GetLocalizedString("ViewType" + type); var name = _localizationManager.GetLocalizedString("ViewType" + type);
return _libraryManager.GetNamedView(name, type, string.Empty, cancellationToken); return _libraryManager.GetNamedView(name, type, sortName, cancellationToken);
} }
} }
} }