diff options
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Connect/IConnectManager.cs | 9 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Drawing/ImageExtensions.cs | 33 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/Audio.cs | 36 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 26 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/IThemeMedia.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Photo.cs | 39 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/PhotoAlbum.cs | 21 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/TV/Episode.cs | 1 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 3 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Net/IHttpResultFactory.cs | 8 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs | 13 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs | 41 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Session/SessionInfo.cs | 2 |
16 files changed, 187 insertions, 90 deletions
diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs new file mode 100644 index 000000000..83f565472 --- /dev/null +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -0,0 +1,9 @@ + +namespace MediaBrowser.Controller.Connect +{ + public interface IConnectManager + { + string WanIpAddress { get; } + string WanApiAddress { get; } + } +} diff --git a/MediaBrowser.Controller/Drawing/ImageExtensions.cs b/MediaBrowser.Controller/Drawing/ImageExtensions.cs index c7e1968e7..2511659c3 100644 --- a/MediaBrowser.Controller/Drawing/ImageExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageExtensions.cs @@ -72,39 +72,6 @@ namespace MediaBrowser.Controller.Drawing } /// <summary> - /// Determines whether [is pixel format supported by graphics object] [the specified format]. - /// </summary> - /// <param name="format">The format.</param> - /// <returns><c>true</c> if [is pixel format supported by graphics object] [the specified format]; otherwise, <c>false</c>.</returns> - public static bool IsPixelFormatSupportedByGraphicsObject(PixelFormat format) - { - // http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx - - if ((format & PixelFormat.Indexed) == PixelFormat.Indexed) - { - return false; - } - if ((format & PixelFormat.Undefined) == PixelFormat.Undefined) - { - return false; - } - if ((format & PixelFormat.DontCare) == PixelFormat.DontCare) - { - return false; - } - if ((format & PixelFormat.Format16bppArgb1555) == PixelFormat.Format16bppArgb1555) - { - return false; - } - if ((format & PixelFormat.Format16bppGrayScale) == PixelFormat.Format16bppGrayScale) - { - return false; - } - - return true; - } - - /// <summary> /// Crops an image by removing whitespace and transparency from the edges /// </summary> /// <param name="bmp">The BMP.</param> diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index d3085cb68..b13403bbf 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -20,7 +20,8 @@ namespace MediaBrowser.Controller.Entities.Audio IHasMusicGenres, IHasLookupInfo<SongInfo>, IHasTags, - IHasMediaSources + IHasMediaSources, + IThemeMedia { public string FormatName { get; set; } public long? Size { get; set; } @@ -28,9 +29,12 @@ namespace MediaBrowser.Controller.Entities.Audio public int? TotalBitrate { get; set; } public List<string> Tags { get; set; } + public bool IsThemeMedia { get; set; } + public Audio() { Artists = new List<string>(); + AlbumArtists = new List<string>(); Tags = new List<string>(); } @@ -73,6 +77,7 @@ namespace MediaBrowser.Controller.Entities.Audio } } + [IgnoreDataMember] public override Folder LatestItemsIndexContainer { get @@ -87,12 +92,14 @@ namespace MediaBrowser.Controller.Entities.Audio /// <value>The artist.</value> public List<string> Artists { get; set; } + public List<string> AlbumArtists { get; set; } + [IgnoreDataMember] public List<string> AllArtists { get { - var list = AlbumArtists; + var list = AlbumArtists.ToList(); list.AddRange(Artists); @@ -101,36 +108,11 @@ namespace MediaBrowser.Controller.Entities.Audio } } - [IgnoreDataMember] - public List<string> AlbumArtists - { - get - { - var list = new List<string>(); - - if (!string.IsNullOrEmpty(AlbumArtist)) - { - list.Add(AlbumArtist); - } - - return list; - } - set - { - AlbumArtist = value.FirstOrDefault(); - } - } - /// <summary> /// Gets or sets the album. /// </summary> /// <value>The album.</value> public string Album { get; set; } - /// <summary> - /// Gets or sets the album artist. - /// </summary> - /// <value>The album artist.</value> - public string AlbumArtist { get; set; } /// <summary> /// Gets the type of the media. diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 152d76782..2eeec9715 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -17,8 +17,9 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicAlbum() { - Artists = new List<string>(); SoundtrackIds = new List<Guid>(); + Artists = new List<string>(); + AlbumArtists = new List<string>(); } public override bool SupportsAddingToPlaylist @@ -40,7 +41,7 @@ namespace MediaBrowser.Controller.Entities.Audio { get { - var list = AlbumArtists; + var list = AlbumArtists.ToList(); list.AddRange(Artists); @@ -49,24 +50,12 @@ namespace MediaBrowser.Controller.Entities.Audio } } + public List<string> AlbumArtists { get; set; } + [IgnoreDataMember] - public List<string> AlbumArtists + public string AlbumArtist { - get - { - var list = new List<string>(); - - if (!string.IsNullOrEmpty(AlbumArtist)) - { - list.Add(AlbumArtist); - } - - return list; - } - set - { - AlbumArtist = value.FirstOrDefault(); - } + get { return AlbumArtists.FirstOrDefault(); } } /// <summary> @@ -139,8 +128,6 @@ namespace MediaBrowser.Controller.Entities.Audio return AllArtists.Contains(artist, StringComparer.OrdinalIgnoreCase); } - public string AlbumArtist { get; set; } - public List<string> Artists { get; set; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index e718a53ff..fd7a33ddf 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -749,7 +749,18 @@ namespace MediaBrowser.Controller.Entities var themeVideosChanged = !item.ThemeVideoIds.SequenceEqual(newThemeVideoIds); - var tasks = newThemeVideos.Select(i => i.RefreshMetadata(options, cancellationToken)); + var tasks = newThemeVideos.Select(i => + { + var subOptions = new MetadataRefreshOptions(options); + + if (!i.IsThemeMedia) + { + i.IsThemeMedia = true; + subOptions.ForceSave = true; + } + + return i.RefreshMetadata(subOptions, cancellationToken); + }); await Task.WhenAll(tasks).ConfigureAwait(false); @@ -768,7 +779,18 @@ namespace MediaBrowser.Controller.Entities var themeSongsChanged = !item.ThemeSongIds.SequenceEqual(newThemeSongIds); - var tasks = newThemeSongs.Select(i => i.RefreshMetadata(options, cancellationToken)); + var tasks = newThemeSongs.Select(i => + { + var subOptions = new MetadataRefreshOptions(options); + + if (!i.IsThemeMedia) + { + i.IsThemeMedia = true; + subOptions.ForceSave = true; + } + + return i.RefreshMetadata(subOptions, cancellationToken); + }); await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/IThemeMedia.cs b/MediaBrowser.Controller/Entities/IThemeMedia.cs new file mode 100644 index 000000000..b2eff230f --- /dev/null +++ b/MediaBrowser.Controller/Entities/IThemeMedia.cs @@ -0,0 +1,8 @@ + +namespace MediaBrowser.Controller.Entities +{ + public interface IThemeMedia + { + bool IsThemeMedia { get; } + } +} diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index 96995c315..1f38de9a3 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -1,4 +1,8 @@ -using System.Collections.Generic; +using MediaBrowser.Model.Configuration; +using MediaBrowser.Model.Drawing; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities { @@ -13,6 +17,14 @@ namespace MediaBrowser.Controller.Entities Taglines = new List<string>(); } + public override bool SupportsLocalMetadata + { + get + { + return false; + } + } + public override string MediaType { get @@ -20,5 +32,30 @@ namespace MediaBrowser.Controller.Entities return Model.Entities.MediaType.Photo; } } + + [IgnoreDataMember] + public override Folder LatestItemsIndexContainer + { + get + { + return Parents.OfType<PhotoAlbum>().FirstOrDefault(); + } + } + + public int? Width { get; set; } + public int? Height { get; set; } + public string CameraMake { get; set; } + public string CameraModel { get; set; } + public string Software { get; set; } + public double? ExposureTime { get; set; } + public double? FocalLength { get; set; } + public ImageOrientation? Orientation { get; set; } + public double? Aperture { get; set; } + public double? ShutterSpeed { get; set; } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.Other); + } } } diff --git a/MediaBrowser.Controller/Entities/PhotoAlbum.cs b/MediaBrowser.Controller/Entities/PhotoAlbum.cs new file mode 100644 index 000000000..7af4109f3 --- /dev/null +++ b/MediaBrowser.Controller/Entities/PhotoAlbum.cs @@ -0,0 +1,21 @@ +using MediaBrowser.Model.Configuration; +using System.Linq; + +namespace MediaBrowser.Controller.Entities +{ + public class PhotoAlbum : Folder + { + public override bool SupportsLocalMetadata + { + get + { + return false; + } + } + + protected override bool GetBlockUnratedValue(UserConfiguration config) + { + return config.BlockUnratedItems.Contains(UnratedItem.Other); + } + } +} diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 70577bbfd..b95c7df9c 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -95,6 +95,7 @@ namespace MediaBrowser.Controller.Entities.TV } } + [IgnoreDataMember] public override Folder LatestItemsIndexContainer { get diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index ff4c5dd90..ea530272d 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -24,7 +24,8 @@ namespace MediaBrowser.Controller.Entities IHasTags, ISupportsPlaceHolders, IHasMediaSources, - IHasShortOverview + IHasShortOverview, + IThemeMedia { public bool IsMultiPart { get; set; } public bool HasLocalAlternateVersions { get; set; } @@ -33,6 +34,8 @@ namespace MediaBrowser.Controller.Entities public List<Guid> AdditionalPartIds { get; set; } public List<Guid> LocalAlternateVersionIds { get; set; } + public bool IsThemeMedia { get; set; } + public string FormatName { get; set; } public long? Size { get; set; } public string Container { get; set; } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 66c6d39ee..aeeaae073 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,6 +99,7 @@ <Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\CollectionEvents.cs" /> <Compile Include="Collections\ICollectionManager.cs" /> + <Compile Include="Connect\IConnectManager.cs" /> <Compile Include="Dlna\ControlRequest.cs" /> <Compile Include="Dlna\ControlResponse.cs" /> <Compile Include="Dlna\DlnaIconResponse.cs" /> @@ -150,10 +151,12 @@ <Compile Include="Entities\ISupportsBoxSetGrouping.cs" /> <Compile Include="Entities\ISupportsPlaceHolders.cs" /> <Compile Include="Entities\ItemImageInfo.cs" /> + <Compile Include="Entities\IThemeMedia.cs" /> <Compile Include="Entities\LinkedChild.cs" /> <Compile Include="Entities\MusicVideo.cs" /> <Compile Include="Entities\IHasAwards.cs" /> <Compile Include="Entities\Photo.cs" /> + <Compile Include="Entities\PhotoAlbum.cs" /> <Compile Include="Entities\UserView.cs" /> <Compile Include="FileOrganization\IFileOrganizationService.cs" /> <Compile Include="Library\DeleteOptions.cs" /> diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs index 17ab0f31c..50a1c4e4f 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs @@ -127,8 +127,9 @@ namespace MediaBrowser.Controller.MediaEncoding stream.BitDepth = GetBitDepth(stream.PixelFormat); - stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", - StringComparison.OrdinalIgnoreCase); + stream.IsAnamorphic = string.Equals(streamInfo.sample_aspect_ratio, "0:1", StringComparison.OrdinalIgnoreCase) || + string.Equals(stream.AspectRatio, "2.35:1", StringComparison.OrdinalIgnoreCase) || + string.Equals(stream.AspectRatio, "2.40:1", StringComparison.OrdinalIgnoreCase); } else { diff --git a/MediaBrowser.Controller/Net/IHttpResultFactory.cs b/MediaBrowser.Controller/Net/IHttpResultFactory.cs index 665c1f8d9..f0cfbbcfa 100644 --- a/MediaBrowser.Controller/Net/IHttpResultFactory.cs +++ b/MediaBrowser.Controller/Net/IHttpResultFactory.cs @@ -109,14 +109,18 @@ namespace MediaBrowser.Controller.Net /// <param name="fileShare">The file share.</param> /// <param name="responseHeaders">The response headers.</param> /// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param> + /// <param name="throttle">if set to <c>true</c> [throttle].</param> + /// <param name="throttleLimit">The throttle limit.</param> /// <returns>System.Object.</returns> object GetStaticFileResult(IRequest requestContext, string path, string contentType, TimeSpan? cacheCuration = null, FileShare fileShare = FileShare.Read, - IDictionary<string, string> responseHeaders = null, - bool isHeadRequest = false); + IDictionary<string, string> responseHeaders = null, + bool isHeadRequest = false, + bool throttle = false, + long throttleLimit = 0); /// <summary> /// Gets the optimized serialized result using cache. diff --git a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs index 7f1ddbce9..dd07979d3 100644 --- a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs +++ b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs @@ -1,6 +1,7 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -23,6 +24,18 @@ namespace MediaBrowser.Controller.Providers { MetadataRefreshMode = MetadataRefreshMode.Default; } + + public MetadataRefreshOptions(MetadataRefreshOptions copy) + { + MetadataRefreshMode = copy.MetadataRefreshMode; + ForceSave = copy.ForceSave; + ReplaceAllMetadata = copy.ReplaceAllMetadata; + + ImageRefreshMode = copy.ImageRefreshMode; + DirectoryService = copy.DirectoryService; + ReplaceAllImages = copy.ReplaceAllImages; + ReplaceImages = copy.ReplaceImages.ToList(); + } } public class ImageRefreshOptions diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index ff94ceff3..7c68448e5 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Common.IO; +using System.Globalization; +using MediaBrowser.Common.IO; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Library; using System; @@ -189,6 +190,44 @@ namespace MediaBrowser.Controller.Resolvers } /// <summary> + /// Determines whether [is multi disc album folder] [the specified path]. + /// </summary> + /// <param name="path">The path.</param> + /// <returns><c>true</c> if [is multi disc album folder] [the specified path]; otherwise, <c>false</c>.</returns> + public static bool IsMultiDiscAlbumFolder(string path) + { + var filename = Path.GetFileName(path); + + if (string.IsNullOrWhiteSpace(filename)) + { + return false; + } + + // Normalize + // Remove whitespace + filename = filename.Replace("-", string.Empty); + filename = Regex.Replace(filename, @"\s+", ""); + + var prefixes = new[] { "disc", "cd", "disk" }; + + foreach (var prefix in prefixes) + { + if (filename.IndexOf(prefix, StringComparison.OrdinalIgnoreCase) == 0) + { + var tmp = filename.Substring(prefix.Length); + + int val; + if (int.TryParse(tmp, NumberStyles.Any, CultureInfo.InvariantCulture, out val)) + { + return true; + } + } + } + + return false; + } + + /// <summary> /// Ensures DateCreated and DateModified have values /// </summary> /// <param name="fileSystem">The file system.</param> diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 58d455955..53a8d5a7c 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -156,7 +156,7 @@ namespace MediaBrowser.Controller.Session public bool ContainsUser(Guid userId) { - return (UserId ?? Guid.Empty) == UserId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); + return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); } } } |
