aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Library/MetadataConfigurationStore.cs29
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
-rw-r--r--MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs20
3 files changed, 47 insertions, 3 deletions
diff --git a/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs b/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs
new file mode 100644
index 000000000..6fad786a2
--- /dev/null
+++ b/MediaBrowser.Controller/Library/MetadataConfigurationStore.cs
@@ -0,0 +1,29 @@
+using MediaBrowser.Common.Configuration;
+using MediaBrowser.Model.Configuration;
+using System.Collections.Generic;
+
+namespace MediaBrowser.Controller.Library
+{
+ public class MetadataConfigurationStore : IConfigurationFactory
+ {
+ public IEnumerable<ConfigurationStore> GetConfigurations()
+ {
+ return new List<ConfigurationStore>
+ {
+ new ConfigurationStore
+ {
+ Key = "metadata",
+ ConfigurationType = typeof(MetadataConfiguration)
+ }
+ };
+ }
+ }
+
+ public static class MetadataConfigurationExtensions
+ {
+ public static MetadataConfiguration GetMetadataConfiguration(this IConfigurationManager config)
+ {
+ return config.GetConfiguration<MetadataConfiguration>("metadata");
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index e04cc2087..d966d4df5 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -174,6 +174,7 @@
<Compile Include="Library\IUserDataManager.cs" />
<Compile Include="Library\IUserViewManager.cs" />
<Compile Include="Library\LibraryManagerExtensions.cs" />
+ <Compile Include="Library\MetadataConfigurationStore.cs" />
<Compile Include="Library\PlaybackStopEventArgs.cs" />
<Compile Include="Library\UserDataSaveEventArgs.cs" />
<Compile Include="LiveTv\RecordingGroup.cs" />
diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
index 4ddfa5979..7d9c9d876 100644
--- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
+++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs
@@ -211,7 +211,7 @@ namespace MediaBrowser.Controller.Resolvers
{
if (includeCreationTime)
{
- item.DateCreated = DateTime.UtcNow;
+ SetDateCreated(item, fileSystem, childData);
}
item.DateModified = fileSystem.GetLastWriteTimeUtc(childData);
@@ -224,7 +224,7 @@ namespace MediaBrowser.Controller.Resolvers
{
if (includeCreationTime)
{
- item.DateCreated = DateTime.UtcNow;
+ SetDateCreated(item, fileSystem, fileData);
}
item.DateModified = fileSystem.GetLastWriteTimeUtc(fileData);
}
@@ -234,10 +234,24 @@ namespace MediaBrowser.Controller.Resolvers
{
if (includeCreationTime)
{
- item.DateCreated = DateTime.UtcNow;
+ SetDateCreated(item, fileSystem, args.FileInfo);
}
item.DateModified = fileSystem.GetLastWriteTimeUtc(args.FileInfo);
}
}
+
+ private static void SetDateCreated(BaseItem item, IFileSystem fileSystem, FileSystemInfo info)
+ {
+ var config = BaseItem.ConfigurationManager.GetMetadataConfiguration();
+
+ if (config.UseFileCreationTimeForDateAdded)
+ {
+ item.DateModified = fileSystem.GetCreationTimeUtc(info);
+ }
+ else
+ {
+ item.DateCreated = DateTime.UtcNow;
+ }
+ }
}
}