diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 16e8a434a..78aa5e165 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -245,12 +245,8 @@ namespace MediaBrowser.Api item.OriginalTitle = string.IsNullOrWhiteSpace(request.OriginalTitle) ? null : request.OriginalTitle; - var hasCriticRating = item as IHasCriticRating; - if (hasCriticRating != null) - { - hasCriticRating.CriticRating = request.CriticRating; - hasCriticRating.CriticRatingSummary = request.CriticRatingSummary; - } + item.CriticRating = request.CriticRating; + item.CriticRatingSummary = request.CriticRatingSummary; item.DisplayMediaType = request.DisplayMediaType; item.CommunityRating = request.CommunityRating; @@ -279,11 +275,7 @@ namespace MediaBrowser.Api item.Tagline = request.Taglines.FirstOrDefault(); } - var hasShortOverview = item as IHasShortOverview; - if (hasShortOverview != null) - { - hasShortOverview.ShortOverview = request.ShortOverview; - } + item.ShortOverview = request.ShortOverview; item.Keywords = request.Keywords; diff --git a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs index 270b068fd..8dea9068d 100644 --- a/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/DynamicHlsService.cs @@ -886,7 +886,6 @@ namespace MediaBrowser.Api.Playback.Hls var mapArgs = state.IsOutputVideo ? GetMapArgs(state) : string.Empty; var enableSplittingOnNonKeyFrames = state.VideoRequest.EnableSplittingOnNonKeyFrames && string.Equals(state.OutputVideoCodec, "copy", StringComparison.OrdinalIgnoreCase); - enableSplittingOnNonKeyFrames = false; // TODO: check libavformat version for 57 50.100 and use -hls_flags split_by_time var hlsProtocolSupportsSplittingByTime = false; diff --git a/MediaBrowser.Common.Implementations/Logging/NLogger.cs b/MediaBrowser.Common.Implementations/Logging/NLogger.cs index 97bc437a0..11f41261a 100644 --- a/MediaBrowser.Common.Implementations/Logging/NLogger.cs +++ b/MediaBrowser.Common.Implementations/Logging/NLogger.cs @@ -127,7 +127,9 @@ namespace MediaBrowser.Common.Implementations.Logging { for (var i = 0; i < paramList.Length; i++) { - message = message.Replace("{" + i + "}", paramList[i].ToString()); + var obj = paramList[i]; + + message = message.Replace("{" + i + "}", (obj == null ? "null" : obj.ToString())); } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 3ebefa217..e1a7741c9 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -33,7 +33,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class BaseItem /// - public abstract class BaseItem : IHasProviderIds, ILibraryItem, IHasImages, IHasUserData, IHasMetadata, IHasLookupInfo + public abstract class BaseItem : IHasProviderIds, IHasImages, IHasUserData, IHasMetadata, IHasLookupInfo { protected BaseItem() { diff --git a/MediaBrowser.Controller/Entities/BasePluginFolder.cs b/MediaBrowser.Controller/Entities/BasePluginFolder.cs index 5a1ad6b15..bd109af7a 100644 --- a/MediaBrowser.Controller/Entities/BasePluginFolder.cs +++ b/MediaBrowser.Controller/Entities/BasePluginFolder.cs @@ -7,7 +7,7 @@ namespace MediaBrowser.Controller.Entities /// Plugins derive from and export this class to create a folder that will appear in the root along /// with all the other actual physical folders in the system. /// - public abstract class BasePluginFolder : Folder, ICollectionFolder, IByReferenceItem + public abstract class BasePluginFolder : Folder, ICollectionFolder { public virtual string CollectionType { diff --git a/MediaBrowser.Controller/Entities/IByReferenceItem.cs b/MediaBrowser.Controller/Entities/IByReferenceItem.cs deleted file mode 100644 index b071473e1..000000000 --- a/MediaBrowser.Controller/Entities/IByReferenceItem.cs +++ /dev/null @@ -1,12 +0,0 @@ - -namespace MediaBrowser.Controller.Entities -{ - /// - /// This is a marker class that tells us that a particular item type may be physically resolved - /// more than once within the library and we need to be sure to resolve them all to the same - /// instance of that item. - /// - public interface IByReferenceItem - { - } -} diff --git a/MediaBrowser.Controller/Entities/IHasCriticRating.cs b/MediaBrowser.Controller/Entities/IHasCriticRating.cs deleted file mode 100644 index d2b93759d..000000000 --- a/MediaBrowser.Controller/Entities/IHasCriticRating.cs +++ /dev/null @@ -1,20 +0,0 @@ -namespace MediaBrowser.Controller.Entities -{ - /// - /// Interface IHasCriticRating - /// - public interface IHasCriticRating - { - /// - /// Gets or sets the critic rating. - /// - /// The critic rating. - float? CriticRating { get; set; } - - /// - /// Gets or sets the critic rating summary. - /// - /// The critic rating summary. - string CriticRatingSummary { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasShortOverview.cs b/MediaBrowser.Controller/Entities/IHasShortOverview.cs deleted file mode 100644 index 437201faa..000000000 --- a/MediaBrowser.Controller/Entities/IHasShortOverview.cs +++ /dev/null @@ -1,12 +0,0 @@ - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasShortOverview - { - /// - /// Gets or sets the short overview. - /// - /// The short overview. - string ShortOverview { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/ILibraryItem.cs b/MediaBrowser.Controller/Entities/ILibraryItem.cs deleted file mode 100644 index b2f39608f..000000000 --- a/MediaBrowser.Controller/Entities/ILibraryItem.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; - -namespace MediaBrowser.Controller.Entities -{ - /// - /// Interface ILibraryItem - /// - public interface ILibraryItem - { - /// - /// Gets the name. - /// - /// The name. - string Name { get; } - - /// - /// Gets the id. - /// - /// The id. - Guid Id { get; } - - /// - /// Gets the path. - /// - /// The path. - string Path { get; } - } -} diff --git a/MediaBrowser.Controller/Entities/ImageSourceInfo.cs b/MediaBrowser.Controller/Entities/ImageSourceInfo.cs deleted file mode 100644 index 6dc072431..000000000 --- a/MediaBrowser.Controller/Entities/ImageSourceInfo.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace MediaBrowser.Controller.Entities -{ - public class ImageSourceInfo - { - public Guid ImagePathMD5 { get; set; } - public Guid ImageUrlMD5 { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index dea42c463..f13adb21c 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Entities.Movies /// /// Class Movie /// - public class Movie : Video, IHasCriticRating, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping, IHasOriginalTitle + public class Movie : Video, IHasSpecialFeatures, IHasBudget, IHasTrailers, IHasAwards, IHasMetascore, IHasLookupInfo, ISupportsBoxSetGrouping, IHasOriginalTitle { public List SpecialFeatureIds { get; set; } diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 62af14159..ce13f5fc5 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Entities.TV { get { - return true; + return false; } } diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 0bcd5c14e..0780cfec5 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class Trailer /// - public class Trailer : Video, IHasCriticRating, IHasBudget, IHasMetascore, IHasOriginalTitle, IHasLookupInfo + public class Trailer : Video, IHasBudget, IHasMetascore, IHasOriginalTitle, IHasLookupInfo { public Trailer() { diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 3b7e3c5d2..38397572e 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1668,16 +1668,7 @@ namespace MediaBrowser.Controller.Entities { var val = query.MinCriticRating.Value; - var hasCriticRating = item as IHasCriticRating; - - if (hasCriticRating != null) - { - if (!(hasCriticRating.CriticRating.HasValue && hasCriticRating.CriticRating >= val)) - { - return false; - } - } - else + if (!(item.CriticRating.HasValue && item.CriticRating >= val)) { return false; } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index e87b726b2..78d7a7fdd 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -24,7 +24,6 @@ namespace MediaBrowser.Controller.Entities IHasAspectRatio, ISupportsPlaceHolders, IHasMediaSources, - IHasShortOverview, IThemeMedia { [IgnoreDataMember] diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 610d4b6f8..5e99d6fa3 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -78,14 +78,17 @@ namespace MediaBrowser.Controller.LiveTv protected override string CreateSortName() { - double number = 0; - if (!string.IsNullOrEmpty(Number)) { - double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number); + double number = 0; + + if (double.TryParse(Number, NumberStyles.Any, CultureInfo.InvariantCulture, out number)) + { + return number.ToString("00000-") + (Name ?? string.Empty); + } } - return number.ToString("00000-") + (Name ?? string.Empty); + return Number + "-" + (Name ?? string.Empty); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 11ed0f674..a8062af19 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -132,10 +132,8 @@ - - @@ -146,15 +144,12 @@ - - - diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 13d43eee6..931af293c 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -185,14 +185,12 @@ namespace MediaBrowser.Controller.Providers { var text = reader.ReadElementContentAsString(); - var hasCriticRating = item as IHasCriticRating; - - if (hasCriticRating != null && !string.IsNullOrEmpty(text)) + if (!string.IsNullOrEmpty(text)) { float value; if (float.TryParse(text, NumberStyles.Any, _usCulture, out value)) { - hasCriticRating.CriticRating = value; + item.CriticRating = value; } } @@ -292,12 +290,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrWhiteSpace(val)) { - var hasShortOverview = item as IHasShortOverview; - - if (hasShortOverview != null) - { - hasShortOverview.ShortOverview = val; - } + item.ShortOverview = val; } break; @@ -309,12 +302,7 @@ namespace MediaBrowser.Controller.Providers if (!string.IsNullOrWhiteSpace(val)) { - var hasCriticRating = item as IHasCriticRating; - - if (hasCriticRating != null) - { - hasCriticRating.CriticRatingSummary = val; - } + item.CriticRatingSummary = val; } break; diff --git a/MediaBrowser.Controller/Providers/DynamicImageResponse.cs b/MediaBrowser.Controller/Providers/DynamicImageResponse.cs index fdd1891ed..d19a28a24 100644 --- a/MediaBrowser.Controller/Providers/DynamicImageResponse.cs +++ b/MediaBrowser.Controller/Providers/DynamicImageResponse.cs @@ -12,7 +12,6 @@ namespace MediaBrowser.Controller.Providers public Stream Stream { get; set; } public ImageFormat Format { get; set; } public bool HasImage { get; set; } - public string InternalCacheKey { get; set; } public void SetFormatFromMimeType(string mimeType) { diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index d3e5685bb..428651ed5 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -69,28 +69,8 @@ namespace MediaBrowser.Controller.Providers /// /// Saves the image. /// - /// The item. - /// The source. - /// Type of the MIME. - /// The type. - /// Index of the image. - /// The internal cache key. - /// The cancellation token. /// Task. - Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken); - - /// - /// Saves the image. - /// - /// The item. - /// The source. - /// Type of the MIME. - /// The type. - /// Index of the image. - /// The internal cache key. - /// The cancellation token. - /// Task. - Task SaveImage(IHasImages item, string source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken); + Task SaveImage(IHasImages item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken); /// /// Adds the metadata providers. diff --git a/MediaBrowser.Dlna/Didl/DidlBuilder.cs b/MediaBrowser.Dlna/Didl/DidlBuilder.cs index f53dec3bf..1330c54c2 100644 --- a/MediaBrowser.Dlna/Didl/DidlBuilder.cs +++ b/MediaBrowser.Dlna/Didl/DidlBuilder.cs @@ -585,10 +585,9 @@ namespace MediaBrowser.Dlna.Didl { var desc = item.Overview; - var hasShortOverview = item as IHasShortOverview; - if (hasShortOverview != null && !string.IsNullOrEmpty(hasShortOverview.ShortOverview)) + if (!string.IsNullOrEmpty(item.ShortOverview)) { - desc = hasShortOverview.ShortOverview; + desc = item.ShortOverview; } if (!string.IsNullOrWhiteSpace(desc)) diff --git a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs index c9810b042..314840558 100644 --- a/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.LocalMetadata/Savers/XmlSaverHelpers.cs @@ -258,18 +258,14 @@ namespace MediaBrowser.LocalMetadata.Savers builder.Append("" + SecurityElement.Escape(item.DisplayMediaType) + ""); } - var hasCriticRating = item as IHasCriticRating; - if (hasCriticRating != null) + if (item.CriticRating.HasValue) { - if (hasCriticRating.CriticRating.HasValue) - { - builder.Append("" + SecurityElement.Escape(hasCriticRating.CriticRating.Value.ToString(UsCulture)) + ""); - } + builder.Append("" + SecurityElement.Escape(item.CriticRating.Value.ToString(UsCulture)) + ""); + } - if (!string.IsNullOrEmpty(hasCriticRating.CriticRatingSummary)) - { - builder.Append(""); - } + if (!string.IsNullOrEmpty(item.CriticRatingSummary)) + { + builder.Append(""); } if (!string.IsNullOrEmpty(item.Overview)) @@ -285,14 +281,10 @@ namespace MediaBrowser.LocalMetadata.Savers builder.Append("" + SecurityElement.Escape(hasOriginalTitle.OriginalTitle) + ""); } } - - var hasShortOverview = item as IHasShortOverview; - if (hasShortOverview != null) + + if (!string.IsNullOrEmpty(item.ShortOverview)) { - if (!string.IsNullOrEmpty(hasShortOverview.ShortOverview)) - { - builder.Append(""); - } + builder.Append(""); } if (!string.IsNullOrEmpty(item.CustomRating)) diff --git a/MediaBrowser.Providers/Manager/ImageSaver.cs b/MediaBrowser.Providers/Manager/ImageSaver.cs index 5203adc9d..7e1fa8984 100644 --- a/MediaBrowser.Providers/Manager/ImageSaver.cs +++ b/MediaBrowser.Providers/Manager/ImageSaver.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Providers.Manager return SaveImage(item, source, mimeType, type, imageIndex, null, cancellationToken); } - public async Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken) + public async Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(mimeType)) { @@ -109,9 +109,9 @@ namespace MediaBrowser.Providers.Manager } } } - if (!string.IsNullOrEmpty(internalCacheKey)) + if (saveLocallyWithMedia.HasValue && !saveLocallyWithMedia.Value) { - saveLocally = false; + saveLocally = saveLocallyWithMedia.Value; } if (!imageIndex.HasValue && item.AllowsMultipleImages(type)) diff --git a/MediaBrowser.Providers/Manager/ItemImageProvider.cs b/MediaBrowser.Providers/Manager/ItemImageProvider.cs index 87da835dc..898fa522d 100644 --- a/MediaBrowser.Providers/Manager/ItemImageProvider.cs +++ b/MediaBrowser.Providers/Manager/ItemImageProvider.cs @@ -156,14 +156,14 @@ namespace MediaBrowser.Providers.Manager var stream = _fileSystem.GetFileStream(response.Path, FileMode.Open, FileAccess.Read, FileShare.Read, true); - await _providerManager.SaveImage(item, stream, mimeType, imageType, null, response.InternalCacheKey, cancellationToken).ConfigureAwait(false); + await _providerManager.SaveImage(item, stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false); } } else { var mimeType = "image/" + response.Format.ToString().ToLower(); - await _providerManager.SaveImage(item, response.Stream, mimeType, imageType, null, response.InternalCacheKey, cancellationToken).ConfigureAwait(false); + await _providerManager.SaveImage(item, response.Stream, mimeType, imageType, null, cancellationToken).ConfigureAwait(false); } downloadedImages.Add(imageType); diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index c470f55f2..41cacbe0a 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -353,19 +353,16 @@ namespace MediaBrowser.Providers.Manager { var updateType = ItemUpdateType.None; - if (isFullRefresh || currentUpdateType > ItemUpdateType.None) + var folder = item as Folder; + if (folder != null && folder.SupportsDateLastMediaAdded) { - var folder = item as Folder; - if (folder != null && folder.SupportsDateLastMediaAdded) - { - var items = folder.GetRecursiveChildren(i => !i.IsFolder).Select(i => i.DateCreated).ToList(); - var date = items.Count == 0 ? (DateTime?)null : items.Max(); + var items = folder.GetRecursiveChildren(i => !i.IsFolder).Select(i => i.DateCreated).ToList(); + var date = items.Count == 0 ? (DateTime?)null : items.Max(); - if ((!folder.DateLastMediaAdded.HasValue && date.HasValue) || folder.DateLastMediaAdded != date) - { - folder.DateLastMediaAdded = date; - updateType = ItemUpdateType.MetadataEdit; - } + if ((!folder.DateLastMediaAdded.HasValue && date.HasValue) || folder.DateLastMediaAdded != date) + { + folder.DateLastMediaAdded = date; + updateType = ItemUpdateType.MetadataImport; } } diff --git a/MediaBrowser.Providers/Manager/ProviderManager.cs b/MediaBrowser.Providers/Manager/ProviderManager.cs index ae1d60eb9..dfeceed7d 100644 --- a/MediaBrowser.Providers/Manager/ProviderManager.cs +++ b/MediaBrowser.Providers/Manager/ProviderManager.cs @@ -140,12 +140,7 @@ namespace MediaBrowser.Providers.Manager return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger, _memoryStreamProvider).SaveImage(item, source, mimeType, type, imageIndex, cancellationToken); } - public Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken) - { - return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger, _memoryStreamProvider).SaveImage(item, source, mimeType, type, imageIndex, internalCacheKey, cancellationToken); - } - - public Task SaveImage(IHasImages item, string source, string mimeType, ImageType type, int? imageIndex, string internalCacheKey, CancellationToken cancellationToken) + public Task SaveImage(IHasImages item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(source)) { @@ -154,7 +149,7 @@ namespace MediaBrowser.Providers.Manager var fileStream = _fileSystem.GetFileStream(source, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, true); - return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger, _memoryStreamProvider).SaveImage(item, fileStream, mimeType, type, imageIndex, internalCacheKey, cancellationToken); + return new ImageSaver(ConfigurationManager, _libraryMonitor, _fileSystem, _logger, _memoryStreamProvider).SaveImage(item, fileStream, mimeType, type, imageIndex, saveLocallyWithMedia, cancellationToken); } public async Task> GetAvailableRemoteImages(IHasImages item, RemoteImageQuery query, CancellationToken cancellationToken) diff --git a/MediaBrowser.Providers/Manager/ProviderUtils.cs b/MediaBrowser.Providers/Manager/ProviderUtils.cs index fabe08f33..178e861a3 100644 --- a/MediaBrowser.Providers/Manager/ProviderUtils.cs +++ b/MediaBrowser.Providers/Manager/ProviderUtils.cs @@ -236,15 +236,9 @@ namespace MediaBrowser.Providers.Manager private static void MergeShortOverview(BaseItem source, BaseItem target, List lockedFields, bool replaceData) { - var sourceHasShortOverview = source as IHasShortOverview; - var targetHasShortOverview = target as IHasShortOverview; - - if (sourceHasShortOverview != null && targetHasShortOverview != null) + if (replaceData || string.IsNullOrEmpty(target.ShortOverview)) { - if (replaceData || string.IsNullOrEmpty(targetHasShortOverview.ShortOverview)) - { - targetHasShortOverview.ShortOverview = sourceHasShortOverview.ShortOverview; - } + target.ShortOverview = source.ShortOverview; } } @@ -311,20 +305,14 @@ namespace MediaBrowser.Providers.Manager private static void MergeCriticRating(BaseItem source, BaseItem target, List lockedFields, bool replaceData) { - var sourceCast = source as IHasCriticRating; - var targetCast = target as IHasCriticRating; - - if (sourceCast != null && targetCast != null) + if (replaceData || !target.CriticRating.HasValue) { - if (replaceData || !targetCast.CriticRating.HasValue) - { - targetCast.CriticRating = sourceCast.CriticRating; - } + target.CriticRating = source.CriticRating; + } - if (replaceData || string.IsNullOrEmpty(targetCast.CriticRatingSummary)) - { - targetCast.CriticRatingSummary = sourceCast.CriticRatingSummary; - } + if (replaceData || string.IsNullOrEmpty(target.CriticRatingSummary)) + { + target.CriticRatingSummary = source.CriticRatingSummary; } } diff --git a/MediaBrowser.Providers/Omdb/OmdbProvider.cs b/MediaBrowser.Providers/Omdb/OmdbProvider.cs index f3766f007..8fb4d8fcc 100644 --- a/MediaBrowser.Providers/Omdb/OmdbProvider.cs +++ b/MediaBrowser.Providers/Omdb/OmdbProvider.cs @@ -66,28 +66,24 @@ namespace MediaBrowser.Providers.Omdb item.ProductionYear = year; } - var hasCriticRating = item as IHasCriticRating; - if (hasCriticRating != null) - { - // Seeing some bogus RT data on omdb for series, so filter it out here - // RT doesn't even have tv series - int tomatoMeter; + // Seeing some bogus RT data on omdb for series, so filter it out here + // RT doesn't even have tv series + int tomatoMeter; - if (!string.IsNullOrEmpty(result.tomatoMeter) - && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) - && tomatoMeter >= 0) - { - hasCriticRating.CriticRating = tomatoMeter; - } + if (!string.IsNullOrEmpty(result.tomatoMeter) + && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) + && tomatoMeter >= 0) + { + item.CriticRating = tomatoMeter; + } - if (!string.IsNullOrEmpty(result.tomatoConsensus) - && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) - { - hasCriticRating.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); - } - } + if (!string.IsNullOrEmpty(result.tomatoConsensus) + && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) + { + item.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); + } - int voteCount; + int voteCount; if (!string.IsNullOrEmpty(result.imdbVotes) && int.TryParse(result.imdbVotes, NumberStyles.Number, _usCulture, out voteCount) @@ -167,25 +163,21 @@ namespace MediaBrowser.Providers.Omdb item.ProductionYear = year; } - var hasCriticRating = item as IHasCriticRating; - if (hasCriticRating != null) + // Seeing some bogus RT data on omdb for series, so filter it out here + // RT doesn't even have tv series + int tomatoMeter; + + if (!string.IsNullOrEmpty(result.tomatoMeter) + && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) + && tomatoMeter >= 0) { - // Seeing some bogus RT data on omdb for series, so filter it out here - // RT doesn't even have tv series - int tomatoMeter; + item.CriticRating = tomatoMeter; + } - if (!string.IsNullOrEmpty(result.tomatoMeter) - && int.TryParse(result.tomatoMeter, NumberStyles.Integer, _usCulture, out tomatoMeter) - && tomatoMeter >= 0) - { - hasCriticRating.CriticRating = tomatoMeter; - } - - if (!string.IsNullOrEmpty(result.tomatoConsensus) - && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) - { - hasCriticRating.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); - } + if (!string.IsNullOrEmpty(result.tomatoConsensus) + && !string.Equals(result.tomatoConsensus, "No consensus yet.", StringComparison.OrdinalIgnoreCase)) + { + item.CriticRatingSummary = WebUtility.HtmlDecode(result.tomatoConsensus); } int voteCount; @@ -420,12 +412,8 @@ namespace MediaBrowser.Providers.Omdb hasAwards.AwardSummary = WebUtility.HtmlDecode(result.Awards); } - var hasShortOverview = item as IHasShortOverview; - if (hasShortOverview != null) - { - // Imdb plots are usually pretty short - hasShortOverview.ShortOverview = result.Plot; - } + // Imdb plots are usually pretty short + item.ShortOverview = result.Plot; //if (!string.IsNullOrWhiteSpace(result.Director)) //{ diff --git a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs b/MediaBrowser.Server.Implementations/IO/FileRefresher.cs index 3df7a03d4..c2c776c2b 100644 --- a/MediaBrowser.Server.Implementations/IO/FileRefresher.cs +++ b/MediaBrowser.Server.Implementations/IO/FileRefresher.cs @@ -45,6 +45,11 @@ namespace MediaBrowser.Server.Implementations.IO private void AddAffectedPath(string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + if (!_affectedPaths.Contains(path, StringComparer.Ordinal)) { _affectedPaths.Add(path); @@ -53,6 +58,11 @@ namespace MediaBrowser.Server.Implementations.IO public void AddPath(string path) { + if (string.IsNullOrWhiteSpace(path)) + { + throw new ArgumentNullException("path"); + } + lock (_timerLock) { AddAffectedPath(path); diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b2302cf86..a45d7ae5f 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -2838,7 +2838,7 @@ namespace MediaBrowser.Server.Implementations.Library private bool ValidateNetworkPath(string path) { - if (Environment.OSVersion.Platform == PlatformID.Win32NT || !path.StartsWith("\\\\", StringComparison.OrdinalIgnoreCase)) + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { return Directory.Exists(path); } diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs index c3d5f3441..5f4199564 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Movies/MovieResolver.cs @@ -207,14 +207,18 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies // Find movies with their own folders if (args.IsDirectory) { + var files = args.FileSystemChildren + .Where(i => !LibraryManager.IgnoreFile(i, args.Parent)) + .ToList(); + if (string.Equals(collectionType, CollectionType.MusicVideos, StringComparison.OrdinalIgnoreCase)) { - return null; + return FindMovie(args.Path, args.Parent, files, args.DirectoryService, collectionType, false); } if (string.Equals(collectionType, CollectionType.HomeVideos, StringComparison.OrdinalIgnoreCase)) { - return null; + return FindMovie /// - /// The path. - /// The parent. - /// The file system entries. - /// The directory service. - /// Type of the collection. /// Movie. - private T FindMovie(string path, Folder parent, List fileSystemEntries, IDirectoryService directoryService, string collectionType) + private T FindMovie(string path, Folder parent, List fileSystemEntries, IDirectoryService directoryService, string collectionType, bool allowFilesAsFolders) where T : Video, new() { var multiDiscFolders = new List(); @@ -413,23 +405,27 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies } } - var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) && - !string.Equals(collectionType, CollectionType.Photos) && - !string.Equals(collectionType, CollectionType.MusicVideos); - - var result = ResolveVideos(parent, fileSystemEntries, directoryService, supportsMultiVersion); - - if (result.Items.Count == 1) + if (allowFilesAsFolders) { - var movie = (T)result.Items[0]; - movie.IsInMixedFolder = false; - movie.Name = Path.GetFileName(movie.ContainingFolderPath); - return movie; - } + // TODO: Allow GetMultiDiscMovie in here + var supportsMultiVersion = !string.Equals(collectionType, CollectionType.HomeVideos) && + !string.Equals(collectionType, CollectionType.Photos) && + !string.Equals(collectionType, CollectionType.MusicVideos); - if (result.Items.Count == 0 && multiDiscFolders.Count > 0) - { - return GetMultiDiscMovie(multiDiscFolders, directoryService); + var result = ResolveVideos(parent, fileSystemEntries, directoryService, supportsMultiVersion); + + if (result.Items.Count == 1) + { + var movie = (T)result.Items[0]; + movie.IsInMixedFolder = false; + movie.Name = Path.GetFileName(movie.ContainingFolderPath); + return movie; + } + + if (result.Items.Count == 0 && multiDiscFolders.Count > 0) + { + return GetMultiDiscMovie(multiDiscFolders, directoryService); + } } return null; diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 9b69b84d3..0939d1c6b 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -1854,23 +1854,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV ParentIndexNumber = program.SeasonNumber.Value, IndexNumber = program.EpisodeNumber.Value, AncestorIds = seriesIds, - ExcludeLocationTypes = new[] { LocationType.Virtual } - }); - - if (result.TotalRecordCount > 0) - { - return true; - } - } - - if (!string.IsNullOrWhiteSpace(program.EpisodeTitle)) - { - var result = _libraryManager.GetItemsResult(new InternalItemsQuery - { - IncludeItemTypes = new[] { typeof(Episode).Name }, - Name = program.EpisodeTitle, - AncestorIds = seriesIds, - ExcludeLocationTypes = new[] { LocationType.Virtual } + IsVirtualItem = false }); if (result.TotalRecordCount > 0) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs index 8c46b4597..c7a2d295d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvDtoService.cs @@ -72,7 +72,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv { dto.ProgramInfo = _dtoService.GetBaseItemDto(program, new DtoOptions()); - dto.ProgramInfo.TimerId = dto.Id; + if (info.Status != RecordingStatus.Cancelled && info.Status != RecordingStatus.Error) + { + dto.ProgramInfo.TimerId = dto.Id; + dto.ProgramInfo.Status = info.Status.ToString(); + } dto.ProgramInfo.SeriesTimerId = dto.SeriesTimerId; } diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index abf0f3425..22d7ba3be 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -144,7 +144,7 @@ namespace MediaBrowser.Server.Implementations.Photos return ItemUpdateType.None; } - await ProviderManager.SaveImage(item, outputPath, "image/png", imageType, null, Guid.NewGuid().ToString("N"), cancellationToken).ConfigureAwait(false); + await ProviderManager.SaveImage(item, outputPath, "image/png", imageType, null, false, cancellationToken).ConfigureAwait(false); return ItemUpdateType.ImageUpdate; } diff --git a/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs b/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs index d01f7ed1b..9484130cb 100644 --- a/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/CriticRatingComparer.cs @@ -22,9 +22,7 @@ namespace MediaBrowser.Server.Implementations.Sorting private float GetValue(BaseItem x) { - var hasCriticRating = x as IHasCriticRating; - - return hasCriticRating == null ? 0 : hasCriticRating.CriticRating ?? 0; + return x.CriticRating ?? 0; } /// diff --git a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs index 8c45b8001..59f6e8722 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/BaseNfoParser.cs @@ -294,14 +294,12 @@ namespace MediaBrowser.XbmcMetadata.Parsers { var text = reader.ReadElementContentAsString(); - var hasCriticRating = item as IHasCriticRating; - - if (hasCriticRating != null && !string.IsNullOrEmpty(text)) + if (!string.IsNullOrEmpty(text)) { float value; if (float.TryParse(text, NumberStyles.Any, _usCulture, out value)) { - hasCriticRating.CriticRating = value; + item.CriticRating = value; } } @@ -388,12 +386,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - var hasShortOverview = item as IHasShortOverview; - - if (hasShortOverview != null) - { - hasShortOverview.ShortOverview = val; - } + item.ShortOverview = val; } break; } @@ -418,12 +411,7 @@ namespace MediaBrowser.XbmcMetadata.Parsers if (!string.IsNullOrWhiteSpace(val)) { - var hasCriticRating = item as IHasCriticRating; - - if (hasCriticRating != null) - { - hasCriticRating.CriticRatingSummary = val; - } + item.CriticRatingSummary = val; } break;