diff options
Diffstat (limited to 'MediaBrowser.Controller')
18 files changed, 240 insertions, 27 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Artist.cs b/MediaBrowser.Controller/Entities/Audio/Artist.cs index 274356b30..3d2d41fb7 100644 --- a/MediaBrowser.Controller/Entities/Audio/Artist.cs +++ b/MediaBrowser.Controller/Entities/Audio/Artist.cs @@ -1,11 +1,20 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities.Audio { /// <summary> /// Class Artist /// </summary> - public class Artist : BaseItem, IItemByName + public class Artist : BaseItem, IItemByName, IHasMusicGenres { + public Artist() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + public string LastFmImageUrl { get; set; } /// <summary> @@ -17,5 +26,8 @@ namespace MediaBrowser.Controller.Entities.Audio return "Artist-" + Name; } + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index ff632c981..beb25f1f2 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// <summary> /// Class Audio /// </summary> - public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist + public class Audio : BaseItem, IHasMediaStreams, IHasAlbumArtist, IHasArtist, IHasMusicGenres { public Audio() { diff --git a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs index d9dac077f..77bd3fd66 100644 --- a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs @@ -5,4 +5,9 @@ namespace MediaBrowser.Controller.Entities.Audio { string AlbumArtist { get; } } + + public interface IHasArtist + { + bool HasArtist(string name); + } } diff --git a/MediaBrowser.Controller/Entities/Audio/IHasMusicGenres.cs b/MediaBrowser.Controller/Entities/Audio/IHasMusicGenres.cs new file mode 100644 index 000000000..fdf939e35 --- /dev/null +++ b/MediaBrowser.Controller/Entities/Audio/IHasMusicGenres.cs @@ -0,0 +1,9 @@ +using System.Collections.Generic; + +namespace MediaBrowser.Controller.Entities.Audio +{ + public interface IHasMusicGenres + { + List<string> Genres { get; } + } +} diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 834fc6943..46b4bc73c 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -1,4 +1,5 @@ -using System.Linq; +using System; +using System.Linq; using System.Runtime.Serialization; namespace MediaBrowser.Controller.Entities.Audio @@ -6,10 +7,15 @@ namespace MediaBrowser.Controller.Entities.Audio /// <summary> /// Class MusicAlbum /// </summary> - public class MusicAlbum : Folder, IHasAlbumArtist + public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres { + public MusicAlbum() + { + Artists = new string[] { }; + } + public string LastFmImageUrl { get; set; } - + /// <summary> /// Songs will group into us so don't also include us in the index /// </summary> @@ -60,23 +66,17 @@ namespace MediaBrowser.Controller.Entities.Audio /// <returns><c>true</c> if the specified artist has artist; otherwise, <c>false</c>.</returns> public bool HasArtist(string artist) { - return RecursiveChildren.OfType<Audio>().Any(i => i.HasArtist(artist)); + return string.Equals(AlbumArtist, artist, StringComparison.OrdinalIgnoreCase) + || Artists.Contains(artist, StringComparer.OrdinalIgnoreCase); } - public string AlbumArtist - { - get - { - return RecursiveChildren - .OfType<Audio>() - .Select(i => i.AlbumArtist) - .FirstOrDefault(i => !string.IsNullOrEmpty(i)); - } - } + public string AlbumArtist { get; set; } + + public string[] Artists { get; set; } } public class MusicAlbumDisc : Folder { - + } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 452aaec58..3839f2a0b 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities.Audio { /// <summary> @@ -6,6 +9,12 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> public class MusicGenre : BaseItem, IItemByName { + public MusicGenre() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + /// <summary> /// Gets the user data key. /// </summary> @@ -14,5 +23,9 @@ namespace MediaBrowser.Controller.Entities.Audio { return "MusicGenre-" + Name; } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index fb2260769..4887af2cf 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -1537,5 +1537,58 @@ namespace MediaBrowser.Controller.Entities // Refresh metadata return RefreshMetadata(CancellationToken.None, forceSave: true); } + + /// <summary> + /// Validates that images within the item are still on the file system + /// </summary> + public void ValidateImages() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedKeys = Images + .ToList() + .Where(image => !File.Exists(image.Value)) + .Select(i => i.Key) + .ToList(); + + // Now remove them from the dictionary + foreach (var key in deletedKeys) + { + Images.Remove(key); + } + } + + /// <summary> + /// Validates that backdrops within the item are still on the file system + /// </summary> + public void ValidateBackdrops() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedImages = BackdropImagePaths + .Where(path => !File.Exists(path)) + .ToList(); + + // Now remove them from the dictionary + foreach (var path in deletedImages) + { + BackdropImagePaths.Remove(path); + } + } + + /// <summary> + /// Validates the screenshots. + /// </summary> + public void ValidateScreenshots() + { + // Only validate paths from the same directory - need to copy to a list because we are going to potentially modify the collection below + var deletedImages = ScreenshotImagePaths + .Where(path => !File.Exists(path)) + .ToList(); + + // Now remove them from the dictionary + foreach (var path in deletedImages) + { + ScreenshotImagePaths.Remove(path); + } + } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index f2462aac2..7ae4f8f73 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,8 +1,17 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { public class GameGenre : BaseItem, IItemByName { + public GameGenre() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + /// <summary> /// Gets the user data key. /// </summary> @@ -11,5 +20,9 @@ namespace MediaBrowser.Controller.Entities { return "GameGenre-" + Name; } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index e02a427e0..83fa57dfb 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { /// <summary> @@ -6,6 +9,12 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Genre : BaseItem, IItemByName { + public Genre() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + /// <summary> /// Gets the user data key. /// </summary> @@ -14,5 +23,9 @@ namespace MediaBrowser.Controller.Entities { return "Genre-" + Name; } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IItemByName.cs b/MediaBrowser.Controller/Entities/IItemByName.cs index 6d66acb70..380846d15 100644 --- a/MediaBrowser.Controller/Entities/IItemByName.cs +++ b/MediaBrowser.Controller/Entities/IItemByName.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { /// <summary> @@ -6,5 +9,8 @@ namespace MediaBrowser.Controller.Entities /// </summary> public interface IItemByName { + ItemByNameCounts ItemCounts { get; set; } + + Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 6b2601687..207f76efd 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -1,9 +1,10 @@ -using MediaBrowser.Model.Entities; +using MediaBrowser.Controller.Entities.Audio; +using MediaBrowser.Model.Entities; using System; namespace MediaBrowser.Controller.Entities { - public class MusicVideo : Video + public class MusicVideo : Video, IHasArtist, IHasMusicGenres { /// <summary> /// Gets or sets the artist. diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 273a10acc..3e0798435 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { /// <summary> @@ -6,6 +9,16 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Person : BaseItem, IItemByName { + public Person() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } + /// <summary> /// Gets the user data key. /// </summary> diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 57e560348..8bbf59173 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { /// <summary> @@ -6,6 +9,12 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Studio : BaseItem, IItemByName { + public Studio() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + /// <summary> /// Gets the user data key. /// </summary> @@ -14,5 +23,9 @@ namespace MediaBrowser.Controller.Entities { return "Studio-" + Name; } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 7ce008c5e..ed07e3175 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -136,6 +136,11 @@ namespace MediaBrowser.Controller.Entities get { return Video3DFormat.HasValue; } } + public bool IsHd + { + get { return MediaStreams != null && MediaStreams.Any(i => i.Type == MediaStreamType.Video && i.Width.HasValue && i.Width.Value >= 1280); } + } + /// <summary> /// Gets the type of the media. /// </summary> diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index c5235a07a..daaebdc85 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -1,4 +1,7 @@ - +using MediaBrowser.Model.Dto; +using System; +using System.Collections.Generic; + namespace MediaBrowser.Controller.Entities { /// <summary> @@ -6,6 +9,16 @@ namespace MediaBrowser.Controller.Entities /// </summary> public class Year : BaseItem, IItemByName { + public Year() + { + ItemCounts = new ItemByNameCounts(); + UserItemCounts = new Dictionary<Guid, ItemByNameCounts>(); + } + + public ItemByNameCounts ItemCounts { get; set; } + + public Dictionary<Guid, ItemByNameCounts> UserItemCounts { get; set; } + /// <summary> /// Gets the user data key. /// </summary> diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index f4165a630..b6b80586a 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -236,6 +236,38 @@ namespace MediaBrowser.Controller.Library Task ValidateArtists(CancellationToken cancellationToken, IProgress<double> progress); /// <summary> + /// Validates the music genres. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <param name="progress">The progress.</param> + /// <returns>Task.</returns> + Task ValidateMusicGenres(CancellationToken cancellationToken, IProgress<double> progress); + + /// <summary> + /// Validates the game genres. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <param name="progress">The progress.</param> + /// <returns>Task.</returns> + Task ValidateGameGenres(CancellationToken cancellationToken, IProgress<double> progress); + + /// <summary> + /// Validates the genres. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <param name="progress">The progress.</param> + /// <returns>Task.</returns> + Task ValidateGenres(CancellationToken cancellationToken, IProgress<double> progress); + + /// <summary> + /// Validates the studios. + /// </summary> + /// <param name="cancellationToken">The cancellation token.</param> + /// <param name="progress">The progress.</param> + /// <returns>Task.</returns> + Task ValidateStudios(CancellationToken cancellationToken, IProgress<double> progress); + + /// <summary> /// Occurs when [item added]. /// </summary> event EventHandler<ItemChangeEventArgs> ItemAdded; diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 3546b8b04..990c5f670 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -74,6 +74,7 @@ <Compile Include="Dto\IDtoService.cs" /> <Compile Include="Entities\AdultVideo.cs" /> <Compile Include="Entities\Audio\IHasAlbumArtist.cs" /> + <Compile Include="Entities\Audio\IHasMusicGenres.cs" /> <Compile Include="Entities\Book.cs" /> <Compile Include="Configuration\IServerConfigurationManager.cs" /> <Compile Include="Entities\Audio\MusicGenre.cs" /> @@ -90,6 +91,7 @@ <Compile Include="Localization\ILocalizationManager.cs" /> <Compile Include="Notifications\INotificationsRepository.cs" /> <Compile Include="Notifications\NotificationUpdateEventArgs.cs" /> + <Compile Include="Providers\IDynamicInfoProvider.cs" /> <Compile Include="Session\ISessionManager.cs" /> <Compile Include="Drawing\ImageExtensions.cs" /> <Compile Include="Drawing\ImageHeader.cs" /> diff --git a/MediaBrowser.Controller/Providers/IDynamicInfoProvider.cs b/MediaBrowser.Controller/Providers/IDynamicInfoProvider.cs new file mode 100644 index 000000000..0f5dea5f6 --- /dev/null +++ b/MediaBrowser.Controller/Providers/IDynamicInfoProvider.cs @@ -0,0 +1,10 @@ + +namespace MediaBrowser.Controller.Providers +{ + /// <summary> + /// Marker interface for a provider that always runs + /// </summary> + public interface IDynamicInfoProvider + { + } +} |
