diff options
| author | Sven Van den brande <sven.vandenbrande@outlook.com> | 2013-10-31 21:46:03 +0100 |
|---|---|---|
| committer | Sven Van den brande <sven.vandenbrande@outlook.com> | 2013-10-31 21:46:03 +0100 |
| commit | e8f8d6651c86b3fd3350a5afae1d759fbbad06bd (patch) | |
| tree | 6496b1525f0dfc448f0250f4fddaa634296ae94b /MediaBrowser.Controller/Entities | |
| parent | 28ab28768a307d1cac60ebe79163b98291068cde (diff) | |
| parent | 882d0681e68c5e0ae663cca75752e4df765c8dd5 (diff) | |
Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
Diffstat (limited to 'MediaBrowser.Controller/Entities')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 20 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Folder.cs | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Episode.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Season.cs | 23 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/User.cs | 2 |
5 files changed, 59 insertions, 9 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 77cc54167..839fe34ff 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1,4 +1,5 @@ using MediaBrowser.Common.Extensions; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.IO; @@ -212,6 +213,7 @@ namespace MediaBrowser.Controller.Entities public static IProviderManager ProviderManager { get; set; } public static ILocalizationManager LocalizationManager { get; set; } public static IItemRepository ItemRepository { get; set; } + public static IFileSystem FileSystem { get; set; } /// <summary> /// Returns a <see cref="System.String" /> that represents this instance. @@ -395,7 +397,7 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + args.FileSystemDictionary = FileData.GetFilteredFileSystemEntries(args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action @@ -413,7 +415,7 @@ namespace MediaBrowser.Controller.Entities } //update our dates - EntityResolutionHelper.EnsureDates(this, args, false); + EntityResolutionHelper.EnsureDates(FileSystem, this, args, false); IsOffline = false; @@ -1337,6 +1339,13 @@ namespace MediaBrowser.Controller.Entities var data = userManager.GetUserData(user.Id, key); + if (datePlayed.HasValue) + { + // Incremenet + data.PlayCount++; + } + + // Ensure it's at least one data.PlayCount = Math.Max(data.PlayCount, 1); data.LastPlayedDate = datePlayed ?? data.LastPlayedDate; @@ -1530,7 +1539,8 @@ namespace MediaBrowser.Controller.Entities } // Refresh metadata - return RefreshMetadata(CancellationToken.None, forceSave: true); + // Need to disable slow providers or the image might get re-downloaded + return RefreshMetadata(CancellationToken.None, forceSave: true, allowSlowProviders: false); } /// <summary> @@ -1728,7 +1738,7 @@ namespace MediaBrowser.Controller.Entities if (locationType == LocationType.Remote || locationType == LocationType.Virtual) { - return File.GetLastWriteTimeUtc(imagePath); + return FileSystem.GetLastWriteTimeUtc(imagePath); } var metaFileEntry = ResolveArgs.GetMetaFileByPath(imagePath); @@ -1745,7 +1755,7 @@ namespace MediaBrowser.Controller.Entities } // See if we can avoid a file system lookup by looking for the file in ResolveArgs - return metaFileEntry == null ? File.GetLastWriteTimeUtc(imagePath) : metaFileEntry.LastWriteTimeUtc; + return metaFileEntry == null ? FileSystem.GetLastWriteTimeUtc(imagePath) : FileSystem.GetLastWriteTimeUtc(metaFileEntry); } } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index c54b81242..a4ba14616 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -693,7 +693,7 @@ namespace MediaBrowser.Controller.Entities //existing item - check if it has changed if (currentChild.HasChanged(child)) { - EntityResolutionHelper.EnsureDates(currentChild, child.ResolveArgs, false); + EntityResolutionHelper.EnsureDates(FileSystem, currentChild, child.ResolveArgs, false); validChildren.Add(new Tuple<BaseItem, bool>(currentChild, true)); } diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 14c655455..96b120b8f 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; @@ -191,5 +192,23 @@ namespace MediaBrowser.Controller.Entities.TV return false; } + + public bool IsMissingEpisode + { + get + { + return LocationType == Model.Entities.LocationType.Virtual && PremiereDate.HasValue && PremiereDate.Value < DateTime.UtcNow; + } + } + + public bool IsUnaired + { + get { return PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date; } + } + + public bool IsVirtualUnaired + { + get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; } + } } } diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 9f15de920..5a53e8c0f 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Library; +using System.Linq; +using MediaBrowser.Controller.Library; using MediaBrowser.Controller.Localization; using System; using System.Collections.Generic; @@ -147,5 +148,25 @@ namespace MediaBrowser.Controller.Entities.TV { return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name; } + + public bool IsMissingSeason + { + get { return LocationType == Model.Entities.LocationType.Virtual && Children.OfType<Episode>().All(i => i.IsMissingEpisode); } + } + + public bool IsUnaired + { + get { return Children.OfType<Episode>().All(i => i.IsUnaired); } + } + + public bool IsVirtualUnaired + { + get { return LocationType == Model.Entities.LocationType.Virtual && IsUnaired; } + } + + public bool IsMissingOrVirtualUnaired + { + get { return LocationType == Model.Entities.LocationType.Virtual && Children.OfType<Episode>().All(i => i.IsVirtualUnaired || i.IsMissingEpisode); } + } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 9d8539906..06f50e552 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Controller.Entities // Ensure it's been lazy loaded var config = Configuration; - return File.GetLastWriteTimeUtc(ConfigurationFilePath); + return FileSystem.GetLastWriteTimeUtc(ConfigurationFilePath); } } |
