stub out objects for per library settings

This commit is contained in:
Luke Pulverenti
2016-08-13 01:49:00 -04:00
parent e0e6c98e43
commit 68d1b60964
32 changed files with 234 additions and 79 deletions

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MediaBrowser.Controller.Configuration
{
public class LibraryOptions
{
public bool EnableAudioArchiveFiles { get; set; }
public bool EnableVideoArchiveFiles { get; set; }
}
}

View File

@@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Entities.Audio
}
[IgnoreDataMember]
public override bool EnableForceSaveOnDateModifiedChange
public override bool EnableRefreshOnDateModifiedChange
{
get { return true; }
}

View File

@@ -455,7 +455,7 @@ namespace MediaBrowser.Controller.Entities
public DateTime DateLastRefreshed { get; set; }
[IgnoreDataMember]
public virtual bool EnableForceSaveOnDateModifiedChange
public virtual bool EnableRefreshOnDateModifiedChange
{
get { return false; }
}
@@ -951,7 +951,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => !i.IsDirectory && string.Equals(FileSystem.GetFileNameWithoutExtension(i), ThemeSongFilename, StringComparison.OrdinalIgnoreCase))
);
return LibraryManager.ResolvePaths(files, directoryService, null)
return LibraryManager.ResolvePaths(files, directoryService, null, new LibraryOptions())
.OfType<Audio.Audio>()
.Select(audio =>
{
@@ -981,7 +981,7 @@ namespace MediaBrowser.Controller.Entities
.Where(i => string.Equals(i.Name, ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
.SelectMany(i => directoryService.GetFiles(i.FullName));
return LibraryManager.ResolvePaths(files, directoryService, null)
return LibraryManager.ResolvePaths(files, directoryService, null, new LibraryOptions())
.OfType<Video>()
.Select(item =>
{

View File

@@ -35,7 +35,7 @@ namespace MediaBrowser.Controller.Entities
}
[IgnoreDataMember]
public override bool EnableForceSaveOnDateModifiedChange
public override bool EnableRefreshOnDateModifiedChange
{
get { return true; }
}

View File

@@ -3,11 +3,14 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Serialization;
using MoreLinq;
namespace MediaBrowser.Controller.Entities
@@ -18,6 +21,8 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public class CollectionFolder : Folder, ICollectionFolder
{
public static IXmlSerializer XmlSerializer { get; set; }
public CollectionFolder()
{
PhysicalLocationsList = new List<string>();
@@ -39,6 +44,61 @@ namespace MediaBrowser.Controller.Entities
public string CollectionType { get; set; }
private readonly Dictionary<string, LibraryOptions> _libraryOptions = new Dictionary<string, LibraryOptions>();
public LibraryOptions GetLibraryOptions()
{
lock (_libraryOptions)
{
LibraryOptions options;
if (!_libraryOptions.TryGetValue(Path, out options))
{
options = LoadLibraryOptions();
_libraryOptions[Path] = options;
}
return options;
}
}
private LibraryOptions LoadLibraryOptions()
{
try
{
var result = XmlSerializer.DeserializeFromFile(typeof(LibraryOptions), GetLibraryOptionsPath(Path)) as LibraryOptions;
if (result == null)
{
return new LibraryOptions();
}
return result;
}
catch (FileNotFoundException)
{
return new LibraryOptions();
}
catch (DirectoryNotFoundException)
{
return new LibraryOptions();
}
catch (Exception ex)
{
Logger.ErrorException("Error loading library options", ex);
return new LibraryOptions();
}
}
private static string GetLibraryOptionsPath(string path)
{
return System.IO.Path.Combine(path, "options.xml");
}
public static void SaveLibraryOptions(string path, LibraryOptions options)
{
XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path));
}
/// <summary>
/// Allow different display preferences for each collection folder
/// </summary>

View File

@@ -273,6 +273,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
protected virtual IEnumerable<BaseItem> LoadChildren()
{
//Logger.Debug("Loading children from {0} {1}", Id, Path);
//just load our children from the repo - the library will be validated and maintained in other processes
return GetCachedChildren();
}
@@ -643,8 +644,9 @@ namespace MediaBrowser.Controller.Entities
protected virtual IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService)
{
var collectionType = LibraryManager.GetContentType(this);
var libraryOptions = LibraryManager.GetLibraryOptions(this);
return LibraryManager.ResolvePaths(GetFileSystemChildren(directoryService), directoryService, this, collectionType);
return LibraryManager.ResolvePaths(GetFileSystemChildren(directoryService), directoryService, this, libraryOptions, collectionType);
}
/// <summary>

View File

@@ -34,7 +34,7 @@ namespace MediaBrowser.Controller.Entities
}
[IgnoreDataMember]
public override bool EnableForceSaveOnDateModifiedChange
public override bool EnableRefreshOnDateModifiedChange
{
get { return true; }
}

View File

@@ -52,7 +52,7 @@ namespace MediaBrowser.Controller.Entities
bool RequiresRefresh();
bool EnableForceSaveOnDateModifiedChange { get; }
bool EnableRefreshOnDateModifiedChange { get; }
string PresentationUniqueKey { get; set; }

View File

@@ -62,6 +62,19 @@ namespace MediaBrowser.Controller.Entities.Movies
return UnratedItem.Movie;
}
protected override IEnumerable<BaseItem> LoadChildren()
{
var first = LinkedChildren.FirstOrDefault();
if (first != null && first.Type == LinkedChildType.Shortcut)
{
return base.LoadChildren();
}
// Save a trip to the database
return new List<BaseItem>();
}
[IgnoreDataMember]
public override bool IsPreSorted
{

View File

@@ -52,7 +52,7 @@ namespace MediaBrowser.Controller.Entities
}
[IgnoreDataMember]
public override bool EnableForceSaveOnDateModifiedChange
public override bool EnableRefreshOnDateModifiedChange
{
get { return true; }
}

View File

@@ -55,9 +55,12 @@ namespace MediaBrowser.Controller.Entities
}
[IgnoreDataMember]
public override bool EnableForceSaveOnDateModifiedChange
public override bool EnableRefreshOnDateModifiedChange
{
get { return true; }
get
{
return VideoType == VideoType.VideoFile || VideoType == VideoType.Iso;
}
}
public int? TotalBitrate { get; set; }

View File

@@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CommonIO;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Controller.Library
@@ -32,15 +33,11 @@ namespace MediaBrowser.Controller.Library
/// <summary>
/// Resolves a set of files into a list of BaseItem
/// </summary>
/// <param name="files">The files.</param>
/// <param name="directoryService">The directory service.</param>
/// <param name="parent">The parent.</param>
/// <param name="collectionType">Type of the collection.</param>
/// <returns>List{``0}.</returns>
IEnumerable<BaseItem> ResolvePaths(IEnumerable<FileSystemMetadata> files,
IDirectoryService directoryService,
Folder parent, string
collectionType = null);
Folder parent,
LibraryOptions libraryOptions,
string collectionType = null);
/// <summary>
/// Gets the root folder.
@@ -397,6 +394,9 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if [is audio file] [the specified path]; otherwise, <c>false</c>.</returns>
bool IsAudioFile(string path);
bool IsAudioFile(string path, LibraryOptions libraryOptions);
bool IsVideoFile(string path, LibraryOptions libraryOptions);
/// <summary>
/// Gets the season number from path.
/// </summary>
@@ -453,6 +453,8 @@ namespace MediaBrowser.Controller.Library
/// <returns>IEnumerable&lt;Folder&gt;.</returns>
IEnumerable<Folder> GetCollectionFolders(BaseItem item);
LibraryOptions GetLibraryOptions(BaseItem item);
/// <summary>
/// Gets the people.
/// </summary>
@@ -551,7 +553,7 @@ namespace MediaBrowser.Controller.Library
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
bool IgnoreFile(FileSystemMetadata file, BaseItem parent);
void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, bool refreshLibrary);
void AddVirtualFolder(string name, string collectionType, string[] mediaPaths, LibraryOptions options, bool refreshLibrary);
void RemoveVirtualFolder(string name, bool refreshLibrary);
void AddMediaPath(string virtualFolderName, string path);
void RemoveMediaPath(string virtualFolderName, string path);

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using CommonIO;
using MediaBrowser.Controller.Configuration;
namespace MediaBrowser.Controller.Library
{
@@ -51,6 +52,13 @@ namespace MediaBrowser.Controller.Library
}
}
public LibraryOptions LibraryOptions { get; set; }
public LibraryOptions GetLibraryOptions()
{
return LibraryOptions ?? (LibraryOptions = (Parent == null ? new LibraryOptions() : BaseItem.LibraryManager.GetLibraryOptions(Parent)));
}
/// <summary>
/// Gets or sets the file system dictionary.
/// </summary>

View File

@@ -98,6 +98,7 @@
<Compile Include="Collections\CollectionCreationOptions.cs" />
<Compile Include="Collections\CollectionEvents.cs" />
<Compile Include="Collections\ICollectionManager.cs" />
<Compile Include="Configuration\LibraryOptions.cs" />
<Compile Include="Connect\ConnectSupporterSummary.cs" />
<Compile Include="Connect\IConnectManager.cs" />
<Compile Include="Connect\UserLinkResult.cs" />

View File

@@ -58,6 +58,12 @@ namespace MediaBrowser.Controller.Playlists
return true;
}
protected override IEnumerable<BaseItem> LoadChildren()
{
// Save a trip to the database
return new List<BaseItem>();
}
public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren)
{
return GetPlayableItems(user).Result;