From 12757d094b4998be8b56fc51e5199358d819d0da Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 7 Feb 2014 17:40:03 -0500 Subject: use music brainz values from audio files with bottom up refresh --- .../Entities/Audio/MusicAlbum.cs | 11 +++++++- .../Entities/Audio/MusicArtist.cs | 27 ++++++++++++++++++- .../Entities/Audio/MusicGenre.cs | 25 +++++++++++++++++ MediaBrowser.Controller/Entities/BaseItem.cs | 11 +++++--- MediaBrowser.Controller/Entities/GameGenre.cs | 26 +++++++++++++++++- MediaBrowser.Controller/Entities/Genre.cs | 25 +++++++++++++++++ MediaBrowser.Controller/Entities/Person.cs | 31 +++++++++++++++++++--- MediaBrowser.Controller/Entities/Studio.cs | 25 +++++++++++++++++ MediaBrowser.Controller/Entities/User.cs | 30 +++++++++++++++++++++ MediaBrowser.Controller/Entities/Year.cs | 25 +++++++++++++++++ .../LiveTv/LiveTvAudioRecording.cs | 25 +++++++++++++++++ MediaBrowser.Controller/LiveTv/LiveTvChannel.cs | 25 +++++++++++++++++ MediaBrowser.Controller/LiveTv/LiveTvProgram.cs | 25 +++++++++++++++++ .../LiveTv/LiveTvVideoRecording.cs | 25 +++++++++++++++++ .../Providers/BaseItemXmlParser.cs | 22 +++++++++++++-- .../Providers/ILocalImageProvider.cs | 2 +- 16 files changed, 348 insertions(+), 12 deletions(-) (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 6dda902c9e..8b8c1a6ff4 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -22,6 +22,15 @@ namespace MediaBrowser.Controller.Entities.Audio Tags = new List(); } + [IgnoreDataMember] + public MusicArtist MusicArtist + { + get + { + return Parents.OfType().FirstOrDefault(); + } + } + /// /// Gets or sets the tags. /// @@ -99,7 +108,7 @@ namespace MediaBrowser.Controller.Entities.Audio return "MusicAlbum-MusicBrainzReleaseGroup-" + id; } - id = this.GetProviderId(MetadataProviders.Musicbrainz); + id = this.GetProviderId(MetadataProviders.MusicBrainzAlbum); if (!string.IsNullOrEmpty(id)) { diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 570a011c29..e80aaa69a3 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -89,6 +89,31 @@ namespace MediaBrowser.Controller.Entities.Audio return GetUserDataKey(this); } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + /// /// Gets the user data key. /// @@ -96,7 +121,7 @@ namespace MediaBrowser.Controller.Entities.Audio /// System.String. private static string GetUserDataKey(MusicArtist item) { - var id = item.GetProviderId(MetadataProviders.Musicbrainz); + var id = item.GetProviderId(MetadataProviders.MusicBrainzArtist); if (!string.IsNullOrEmpty(id)) { diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index b54e14f2da..5e1d4c3c9c 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -26,5 +26,30 @@ namespace MediaBrowser.Controller.Entities.Audio [IgnoreDataMember] public List UserItemCountList { get; set; } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 35691a0800..01e8741af2 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -124,7 +124,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public bool IsOwnedItem + public virtual bool IsOwnedItem { get { @@ -1215,7 +1215,12 @@ namespace MediaBrowser.Controller.Entities currentFile.Delete(); } - return LibraryManager.UpdateItem(this, ItemUpdateType.ImageUpdate, CancellationToken.None); + return UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None); + } + + public virtual Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) + { + return LibraryManager.UpdateItem(this, ItemUpdateType.ImageUpdate, cancellationToken); } /// @@ -1370,7 +1375,7 @@ namespace MediaBrowser.Controller.Entities info1.DateModified = FileSystem.GetLastWriteTimeUtc(info1.Path); info2.DateModified = FileSystem.GetLastWriteTimeUtc(info2.Path); - return LibraryManager.UpdateItem(this, ItemUpdateType.ImageUpdate, CancellationToken.None); + return UpdateToRepository(ItemUpdateType.ImageUpdate, CancellationToken.None); } public virtual bool IsPlayed(User user) diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index ffe62ba03f..3a3c575cd1 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,5 +1,4 @@ using MediaBrowser.Model.Dto; -using System; using System.Collections.Generic; using System.Runtime.Serialization; @@ -23,5 +22,30 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public List UserItemCountList { get; set; } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 53bc641946..c15ca0aa2a 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -25,5 +25,30 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public List UserItemCountList { get; set; } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index acf7508708..c1dc811369 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -8,7 +8,7 @@ namespace MediaBrowser.Controller.Entities /// /// This is the full Person object that can be retrieved with all of it's data. /// - public class Person : BaseItem, IItemByName, IHasLookupInfo + public class Person : BaseItem, IItemByName, IHasLookupInfo { public Person() { @@ -33,9 +33,34 @@ namespace MediaBrowser.Controller.Entities return "Person-" + Name; } - public Providers.PersonLookupInfo GetLookupInfo() + public PersonLookupInfo GetLookupInfo() { - return GetItemLookupInfo(); + return GetItemLookupInfo(); + } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } } } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 7bc17549f3..5c3946f9ba 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -26,5 +26,30 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public List UserItemCountList { get; set; } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index ddaa0eb266..66ef8c7dc7 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -72,6 +72,31 @@ namespace MediaBrowser.Controller.Entities } } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + /// /// The _root folder /// @@ -222,6 +247,11 @@ namespace MediaBrowser.Controller.Entities }, CancellationToken.None); } + public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) + { + return UserManager.UpdateUser(this); + } + /// /// Gets the path to the user's configuration directory /// diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index cd50a1c60c..c6ca028aef 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -26,5 +26,30 @@ namespace MediaBrowser.Controller.Entities { return "Year-" + Name; } + + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 93de9d5c34..f093ef7cbd 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -25,6 +25,31 @@ namespace MediaBrowser.Controller.LiveTv public string ServiceName { get; set; } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + public override string MediaType { get diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index f37e947140..583b90fd42 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -25,6 +25,31 @@ namespace MediaBrowser.Controller.LiveTv [IgnoreDataMember] public List UserItemCountList { get; set; } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + /// /// Gets or sets the number. /// diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 6a00607e41..497cfad671 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -127,6 +127,31 @@ namespace MediaBrowser.Controller.LiveTv /// true if this instance is premiere; otherwise, false. public bool IsPremiere { get; set; } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + public override string MediaType { get diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index bc4ed54934..aad760cc93 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -46,6 +46,31 @@ namespace MediaBrowser.Controller.LiveTv } } + /// + /// Returns the folder containing the item. + /// If the item is a folder, it returns the folder itself + /// + /// The containing folder path. + public override string ContainingFolderPath + { + get + { + return Path; + } + } + + /// + /// Gets a value indicating whether this instance is owned item. + /// + /// true if this instance is owned item; otherwise, false. + public override bool IsOwnedItem + { + get + { + return false; + } + } + public override string GetClientTypeName() { return "Recording"; diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 76530d7dd4..dbb8c1edf2 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -680,12 +680,30 @@ namespace MediaBrowser.Controller.Providers } break; } - case "MusicbrainzId": + case "MusicBrainzAlbumId": { var mbz = reader.ReadElementContentAsString(); if (!string.IsNullOrWhiteSpace(mbz)) { - item.SetProviderId(MetadataProviders.Musicbrainz, mbz); + item.SetProviderId(MetadataProviders.MusicBrainzAlbum, mbz); + } + break; + } + case "MusicBrainzAlbumArtistId": + { + var mbz = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(mbz)) + { + item.SetProviderId(MetadataProviders.MusicBrainzAlbumArtist, mbz); + } + break; + } + case "MusicBrainzArtistId": + { + var mbz = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(mbz)) + { + item.SetProviderId(MetadataProviders.MusicBrainzArtist, mbz); } break; } diff --git a/MediaBrowser.Controller/Providers/ILocalImageProvider.cs b/MediaBrowser.Controller/Providers/ILocalImageProvider.cs index 69242d1e20..d1ef68ce2a 100644 --- a/MediaBrowser.Controller/Providers/ILocalImageProvider.cs +++ b/MediaBrowser.Controller/Providers/ILocalImageProvider.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Providers public class LocalImageInfo { - public string Path { get; set; } + public FileInfo FileInfo { get; set; } public ImageType Type { get; set; } } -- cgit v1.2.3