From 89eb080464191b4a748b86e40c2e624c59956a20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Sat, 15 Jun 2013 18:19:47 -0400 Subject: [PATCH] using lockedfields and lockedimages when populating data --- MediaBrowser.Api/LibraryService.cs | 14 +++- .../Movies/FanArtMovieProvider.cs | 10 +-- .../Movies/MovieDbImagesProvider.cs | 4 +- .../Movies/MovieDbProvider.cs | 19 +++-- .../Movies/TmdbPersonProvider.cs | 2 +- .../Music/FanArtAlbumProvider.cs | 4 +- .../Music/FanArtArtistProvider.cs | 10 +-- MediaBrowser.Providers/Music/LastfmHelper.cs | 19 +++-- .../TV/FanArtSeasonProvider.cs | 4 +- MediaBrowser.Providers/TV/FanArtTVProvider.cs | 10 +-- .../TV/RemoteEpisodeProvider.cs | 73 ++++++++++--------- .../TV/RemoteSeasonProvider.cs | 6 +- .../TV/RemoteSeriesProvider.cs | 60 ++++++++------- .../TV/TvdbSeriesImageProvider.cs | 6 +- 14 files changed, 136 insertions(+), 105 deletions(-) diff --git a/MediaBrowser.Api/LibraryService.cs b/MediaBrowser.Api/LibraryService.cs index 40a5fd693c..c2ccf4dcdd 100644 --- a/MediaBrowser.Api/LibraryService.cs +++ b/MediaBrowser.Api/LibraryService.cs @@ -266,9 +266,17 @@ namespace MediaBrowser.Api item.OfficialRating = request.OfficialRating; item.CustomRating = request.CustomRating; item.DontFetchMeta = !(request.EnableInternetProviders ?? true); - item.LockedFields = request.LockedFields; - item.LockedImages = request.LockedImages; - + if (request.EnableInternetProviders ?? true) + { + item.LockedFields = request.LockedFields; + item.LockedImages = request.LockedImages; + } + else + { + item.LockedFields.Clear(); + item.LockedImages.Clear(); + } + foreach (var pair in request.ProviderIds.ToList()) { if (string.IsNullOrEmpty(pair.Value)) diff --git a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs index b34a692d3e..5245dca5f2 100644 --- a/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs +++ b/MediaBrowser.Providers/Movies/FanArtMovieProvider.cs @@ -310,7 +310,7 @@ namespace MediaBrowser.Providers.Movies string path; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Logo && !item.HasImage(ImageType.Logo) && !item.LockedImages.Contains(ImageType.Logo)) { var node = doc.SelectSingleNode("//fanart/movie/movielogos/" + hd + "movielogo[@lang = \"" + language + "\"]/@url") ?? @@ -328,7 +328,7 @@ namespace MediaBrowser.Providers.Movies } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Art && !item.HasImage(ImageType.Art) && !item.LockedImages.Contains(ImageType.Art)) { var node = doc.SelectSingleNode("//fanart/movie/moviearts/" + hd + "movieart[@lang = \"" + language + "\"]/@url") ?? @@ -343,7 +343,7 @@ namespace MediaBrowser.Providers.Movies } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Disc && !item.HasImage(ImageType.Disc) && !item.LockedImages.Contains(ImageType.Disc)) { var node = doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviediscs/moviedisc/@url"); @@ -356,7 +356,7 @@ namespace MediaBrowser.Providers.Movies cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Banner && !item.HasImage(ImageType.Banner) && !item.LockedImages.Contains(ImageType.Banner)) { var node = doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviebanners/moviebanner/@url"); @@ -369,7 +369,7 @@ namespace MediaBrowser.Providers.Movies cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb)) + if (ConfigurationManager.Configuration.DownloadMovieImages.Thumb && !item.HasImage(ImageType.Thumb) && !item.LockedImages.Contains(ImageType.Thumb)) { var node = doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/movie/moviethumbs/moviethumb/@url"); diff --git a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs index 5847fcd693..d2ac6d7402 100644 --- a/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbImagesProvider.cs @@ -232,7 +232,7 @@ namespace MediaBrowser.Providers.Movies var status = ProviderRefreshStatus.Success; // poster - if (images.posters != null && images.posters.Count > 0 && !item.HasImage(ImageType.Primary)) + if (images.posters != null && images.posters.Count > 0 && !item.HasImage(ImageType.Primary) && !item.LockedImages.Contains(ImageType.Primary)) { var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); @@ -273,7 +273,7 @@ namespace MediaBrowser.Providers.Movies cancellationToken.ThrowIfCancellationRequested(); // backdrops - only download if earlier providers didn't find any (fanart) - if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0) + if (images.backdrops != null && images.backdrops.Count > 0 && ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0 && !item.LockedImages.Contains(ImageType.Backdrop)) { var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Providers/Movies/MovieDbProvider.cs b/MediaBrowser.Providers/Movies/MovieDbProvider.cs index a4154207ab..6e42963d0e 100644 --- a/MediaBrowser.Providers/Movies/MovieDbProvider.cs +++ b/MediaBrowser.Providers/Movies/MovieDbProvider.cs @@ -720,9 +720,14 @@ namespace MediaBrowser.Providers.Movies { if (movie != null && movieData != null) { - - movie.Name = movieData.title ?? movieData.original_title ?? movie.Name; - movie.Overview = movieData.overview; + if (!movie.LockedFields.Contains(MetadataFields.Name)) + { + movie.Name = movieData.title ?? movieData.original_title ?? movie.Name; + } + if (!movie.LockedFields.Contains(MetadataFields.Overview)) + { + movie.Overview = movieData.overview; + } movie.Overview = movie.Overview != null ? movie.Overview.Replace("\n\n", "\n") : null; movie.HomePageUrl = movieData.homepage; movie.Budget = movieData.budget; @@ -798,7 +803,7 @@ namespace MediaBrowser.Providers.Movies movie.OriginalRunTimeTicks = TimeSpan.FromMinutes(movieData.runtime).Ticks; //studios - if (movieData.production_companies != null) + if (movieData.production_companies != null && !movie.LockedFields.Contains(MetadataFields.Studios)) { movie.Studios.Clear(); @@ -809,7 +814,7 @@ namespace MediaBrowser.Providers.Movies } //genres - if (movieData.genres != null) + if (movieData.genres != null && !movie.LockedFields.Contains(MetadataFields.Genres)) { movie.Genres.Clear(); @@ -824,7 +829,7 @@ namespace MediaBrowser.Providers.Movies //Actors, Directors, Writers - all in People //actors come from cast - if (movieData.casts != null && movieData.casts.cast != null) + if (movieData.casts != null && movieData.casts.cast != null && !movie.LockedFields.Contains(MetadataFields.Cast)) { foreach (var actor in movieData.casts.cast.OrderBy(a => a.order)) movie.AddPerson(new PersonInfo { Name = actor.name, Role = actor.character, Type = PersonType.Actor }); } @@ -835,7 +840,7 @@ namespace MediaBrowser.Providers.Movies foreach (var person in movieData.casts.crew) movie.AddPerson(new PersonInfo { Name = person.name, Role = person.job, Type = person.department }); } - if (movieData.keywords != null && movieData.keywords.keywords != null) + if (movieData.keywords != null && movieData.keywords.keywords != null && !movie.LockedFields.Contains(MetadataFields.Tags)) { movie.Tags = movieData.keywords.keywords.Select(i => i.name).ToList(); } diff --git a/MediaBrowser.Providers/Movies/TmdbPersonProvider.cs b/MediaBrowser.Providers/Movies/TmdbPersonProvider.cs index 1b02aec3d2..6fe4d3c7c0 100644 --- a/MediaBrowser.Providers/Movies/TmdbPersonProvider.cs +++ b/MediaBrowser.Providers/Movies/TmdbPersonProvider.cs @@ -265,7 +265,7 @@ namespace MediaBrowser.Providers.Movies //still nothing - just get first one profile = searchResult.profiles[0]; } - if (profile != null && !person.HasImage(ImageType.Primary)) + if (profile != null && !person.HasImage(ImageType.Primary) && !person.LockedImages.Contains(ImageType.Primary)) { var tmdbSettings = await MovieDbProvider.Current.GetTmdbSettings(cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs index c424c13e59..4c7251d040 100644 --- a/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtAlbumProvider.cs @@ -187,7 +187,7 @@ namespace MediaBrowser.Providers.Music cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.HasImage(ImageType.Disc)) + if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Disc && !item.HasImage(ImageType.Disc) && !item.LockedImages.Contains(ImageType.Disc)) { // Try try with the release entry Id, if that doesn't produce anything try the release group id var node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + releaseEntryId + "\"]/cdart/@url"); @@ -205,7 +205,7 @@ namespace MediaBrowser.Providers.Music } } - if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.HasImage(ImageType.Primary)) + if (ConfigurationManager.Configuration.DownloadMusicAlbumImages.Primary && !item.HasImage(ImageType.Primary) && !item.LockedImages.Contains(ImageType.Primary)) { // Try try with the release entry Id, if that doesn't produce anything try the release group id var node = doc.SelectSingleNode("//fanart/music/albums/album[@id=\"" + releaseEntryId + "\"]/albumcover/@url"); diff --git a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs index e1f52d5441..89bcd6164c 100644 --- a/MediaBrowser.Providers/Music/FanArtArtistProvider.cs +++ b/MediaBrowser.Providers/Music/FanArtArtistProvider.cs @@ -301,7 +301,7 @@ namespace MediaBrowser.Providers.Music string path; var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Logo && !item.HasImage(ImageType.Logo) && !item.LockedImages.Contains(ImageType.Logo)) { var node = doc.SelectSingleNode("//fanart/music/musiclogos/" + hd + "musiclogo/@url") ?? @@ -314,7 +314,7 @@ namespace MediaBrowser.Providers.Music } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && item.BackdropImagePaths.Count == 0) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Backdrops && item.BackdropImagePaths.Count == 0 && !item.LockedImages.Contains(ImageType.Backdrop)) { var nodes = doc.SelectNodes("//fanart/music/artistbackgrounds//@url"); if (nodes != null) @@ -338,7 +338,7 @@ namespace MediaBrowser.Providers.Music cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Art && !item.HasImage(ImageType.Art) && !item.LockedImages.Contains(ImageType.Art)) { var node = doc.SelectSingleNode("//fanart/music/musicarts/" + hd + "musicart/@url") ?? @@ -351,7 +351,7 @@ namespace MediaBrowser.Providers.Music } cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Banner && !item.HasImage(ImageType.Banner) && !item.LockedImages.Contains(ImageType.Banner)) { var node = doc.SelectSingleNode("//fanart/music/musicbanners/" + hd + "musicbanner/@url") ?? doc.SelectSingleNode("//fanart/music/musicbanners/musicbanner/@url"); @@ -365,7 +365,7 @@ namespace MediaBrowser.Providers.Music cancellationToken.ThrowIfCancellationRequested(); // Artist thumbs are actually primary images (they are square/portrait) - if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary)) + if (ConfigurationManager.Configuration.DownloadMusicArtistImages.Primary && !item.HasImage(ImageType.Primary) && !item.LockedImages.Contains(ImageType.Primary)) { var node = doc.SelectSingleNode("//fanart/music/artistthumbs/artistthumb/@url"); path = node != null ? node.Value : null; diff --git a/MediaBrowser.Providers/Music/LastfmHelper.cs b/MediaBrowser.Providers/Music/LastfmHelper.cs index 6c0ba54311..e8541aa5f5 100644 --- a/MediaBrowser.Providers/Music/LastfmHelper.cs +++ b/MediaBrowser.Providers/Music/LastfmHelper.cs @@ -19,10 +19,11 @@ namespace MediaBrowser.Providers.Music if (data.bio != null) { Int32.TryParse(data.bio.yearformed, out yearFormed); - - artist.Overview = data.bio.content; - - if (!string.IsNullOrEmpty(data.bio.placeformed)) + if (!artist.LockedFields.Contains(MetadataFields.Overview)) + { + artist.Overview = data.bio.content; + } + if (!string.IsNullOrEmpty(data.bio.placeformed) && !artist.LockedFields.Contains(MetadataFields.ProductionLocations)) { artist.AddProductionLocation(data.bio.placeformed); } @@ -30,7 +31,7 @@ namespace MediaBrowser.Providers.Music artist.PremiereDate = yearFormed > 0 ? new DateTime(yearFormed, 1, 1, 0, 0, 0, DateTimeKind.Utc) : (DateTime?)null; artist.ProductionYear = yearFormed; - if (data.tags != null) + if (data.tags != null && !artist.LockedFields.Contains(MetadataFields.Tags)) { AddTags(artist, data.tags); } @@ -52,13 +53,15 @@ namespace MediaBrowser.Providers.Music var overview = data.wiki != null ? data.wiki.content : null; - item.Overview = overview; - + if (!item.LockedFields.Contains(MetadataFields.Overview)) + { + item.Overview = overview; + } DateTime release; DateTime.TryParse(data.releasedate, out release); item.PremiereDate = release; item.ProductionYear = release.Year; - if (data.toptags != null) + if (data.toptags != null && !item.LockedFields.Contains(MetadataFields.Tags)) { AddTags(item, data.toptags); } diff --git a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs index 8f86789cfb..f604d309a2 100644 --- a/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/FanArtSeasonProvider.cs @@ -164,8 +164,8 @@ namespace MediaBrowser.Providers.TV } var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); - - if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb)) + + if (ConfigurationManager.Configuration.DownloadSeasonImages.Thumb && !season.HasImage(ImageType.Thumb) && !season.LockedImages.Contains(ImageType.Thumb)) { var node = doc.SelectSingleNode("//fanart/series/seasonthumbs/seasonthumb[@lang = \"" + language + "\"][@season = \"" + seasonNumber + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/seasonthumbs/seasonthumb[@season = \"" + seasonNumber + "\"]/@url"); diff --git a/MediaBrowser.Providers/TV/FanArtTVProvider.cs b/MediaBrowser.Providers/TV/FanArtTVProvider.cs index ea0a1c1289..bc36d50eeb 100644 --- a/MediaBrowser.Providers/TV/FanArtTVProvider.cs +++ b/MediaBrowser.Providers/TV/FanArtTVProvider.cs @@ -225,7 +225,7 @@ namespace MediaBrowser.Providers.TV var language = ConfigurationManager.Configuration.PreferredMetadataLanguage.ToLower(); var hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hdtv" : "clear"; - if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Logo && !item.HasImage(ImageType.Logo) && !item.LockedImages.Contains(ImageType.Logo)) { var node = doc.SelectSingleNode("//fanart/series/" + hd + "logos/" + hd + "logo[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/clearlogos/clearlogo[@lang = \"" + language + "\"]/@url") ?? @@ -241,7 +241,7 @@ namespace MediaBrowser.Providers.TV cancellationToken.ThrowIfCancellationRequested(); hd = ConfigurationManager.Configuration.DownloadHDFanArt ? "hd" : ""; - if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Art && !item.HasImage(ImageType.Art) && !item.LockedImages.Contains(ImageType.Art)) { var node = doc.SelectSingleNode("//fanart/series/" + hd + "cleararts/" + hd + "clearart[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/cleararts/clearart[@lang = \"" + language + "\"]/@url") ?? @@ -256,7 +256,7 @@ namespace MediaBrowser.Providers.TV cancellationToken.ThrowIfCancellationRequested(); - if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Thumb && !item.HasImage(ImageType.Thumb) && !item.LockedImages.Contains(ImageType.Thumb)) { var node = doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/tvthumbs/tvthumb/@url"); @@ -267,7 +267,7 @@ namespace MediaBrowser.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !item.HasImage(ImageType.Banner) && !item.LockedImages.Contains(ImageType.Banner)) { var node = doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner[@lang = \"" + language + "\"]/@url") ?? doc.SelectSingleNode("//fanart/series/tbbanners/tvbanner/@url"); @@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0) + if (ConfigurationManager.Configuration.DownloadMovieImages.Backdrops && item.BackdropImagePaths.Count == 0 && !item.LockedImages.Contains(ImageType.Backdrop)) { var nodes = doc.SelectNodes("//fanart/series/showbackgrounds//@url"); diff --git a/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs b/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs index 243d77c31e..6b6eed3eb8 100644 --- a/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs +++ b/MediaBrowser.Providers/TV/RemoteEpisodeProvider.cs @@ -274,7 +274,7 @@ namespace MediaBrowser.Providers.TV var doc = new XmlDocument(); doc.LoadXml(episodeNode.OuterXml); - if (!episode.HasImage(ImageType.Primary)) + if (!episode.HasImage(ImageType.Primary) && !episode.LockedImages.Contains(ImageType.Primary)) { var p = doc.SafeGetString("//filename"); if (p != null) @@ -291,14 +291,18 @@ namespace MediaBrowser.Providers.TV } } } - - episode.Overview = doc.SafeGetString("//Overview"); + if (!episode.LockedFields.Contains(MetadataFields.Overview)) + { + episode.Overview = doc.SafeGetString("//Overview"); + } if (usingAbsoluteData) episode.IndexNumber = doc.SafeGetInt32("//absolute_number", -1); if (episode.IndexNumber < 0) episode.IndexNumber = doc.SafeGetInt32("//EpisodeNumber"); - - episode.Name = doc.SafeGetString("//EpisodeName"); + if (!episode.LockedFields.Contains(MetadataFields.Name)) + { + episode.Name = doc.SafeGetString("//EpisodeName"); + } episode.CommunityRating = doc.SafeGetSingle("//Rating", -1, 10); var firstAired = doc.SafeGetString("//FirstAired"); DateTime airDate; @@ -307,47 +311,48 @@ namespace MediaBrowser.Providers.TV episode.PremiereDate = airDate.ToUniversalTime(); episode.ProductionYear = airDate.Year; } - - episode.People.Clear(); - - var actors = doc.SafeGetString("//GuestStars"); - if (actors != null) + if (!episode.LockedFields.Contains(MetadataFields.Cast)) { - // Sometimes tvdb actors have leading spaces - foreach (var person in actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) - .Where(i => !string.IsNullOrWhiteSpace(i)) - .Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str.Trim() })) + episode.People.Clear(); + + var actors = doc.SafeGetString("//GuestStars"); + if (actors != null) { - episode.AddPerson(person); + // Sometimes tvdb actors have leading spaces + foreach (var person in actors.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries) + .Where(i => !string.IsNullOrWhiteSpace(i)) + .Select(str => new PersonInfo {Type = PersonType.GuestStar, Name = str.Trim()})) + { + episode.AddPerson(person); + } } - } - var directors = doc.SafeGetString("//Director"); - if (directors != null) - { - // Sometimes tvdb actors have leading spaces - foreach (var person in directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) - .Where(i => !string.IsNullOrWhiteSpace(i)) - .Select(str => new PersonInfo { Type = PersonType.Director, Name = str.Trim() })) + var directors = doc.SafeGetString("//Director"); + if (directors != null) { - episode.AddPerson(person); + // Sometimes tvdb actors have leading spaces + foreach (var person in directors.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries) + .Where(i => !string.IsNullOrWhiteSpace(i)) + .Select(str => new PersonInfo {Type = PersonType.Director, Name = str.Trim()})) + { + episode.AddPerson(person); + } } - } - var writers = doc.SafeGetString("//Writer"); - if (writers != null) - { - // Sometimes tvdb actors have leading spaces - foreach (var person in writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries) - .Where(i => !string.IsNullOrWhiteSpace(i)) - .Select(str => new PersonInfo { Type = PersonType.Writer, Name = str.Trim() })) + var writers = doc.SafeGetString("//Writer"); + if (writers != null) { - episode.AddPerson(person); + // Sometimes tvdb actors have leading spaces + foreach (var person in writers.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries) + .Where(i => !string.IsNullOrWhiteSpace(i)) + .Select(str => new PersonInfo {Type = PersonType.Writer, Name = str.Trim()})) + { + episode.AddPerson(person); + } } } - if (ConfigurationManager.Configuration.SaveLocalMeta) { //if (!Directory.Exists(episode.MetaLocation)) Directory.CreateDirectory(episode.MetaLocation); diff --git a/MediaBrowser.Providers/TV/RemoteSeasonProvider.cs b/MediaBrowser.Providers/TV/RemoteSeasonProvider.cs index 6e813ce82c..3edc21422d 100644 --- a/MediaBrowser.Providers/TV/RemoteSeasonProvider.cs +++ b/MediaBrowser.Providers/TV/RemoteSeasonProvider.cs @@ -225,7 +225,7 @@ namespace MediaBrowser.Providers.TV return; } - if (!season.HasImage(ImageType.Primary)) + if (!season.HasImage(ImageType.Primary) && !season.LockedImages.Contains(ImageType.Primary)) { var n = images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='season'][Season='" + seasonNumber + "'][Language='" + ConfigurationManager.Configuration.PreferredMetadataLanguage + "']") ?? images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='season'][Season='" + seasonNumber + "'][Language='en']"); @@ -238,7 +238,7 @@ namespace MediaBrowser.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && !season.HasImage(ImageType.Banner)) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Banner && !season.HasImage(ImageType.Banner) && !season.LockedImages.Contains(ImageType.Banner)) { var n = images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='seasonwide'][Season='" + seasonNumber + "'][Language='" + ConfigurationManager.Configuration.PreferredMetadataLanguage + "']") ?? images.SelectSingleNode("//Banner[BannerType='season'][BannerType2='seasonwide'][Season='" + seasonNumber + "'][Language='en']"); @@ -273,7 +273,7 @@ namespace MediaBrowser.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && season.BackdropImagePaths.Count == 0) + if (ConfigurationManager.Configuration.DownloadSeasonImages.Backdrops && season.BackdropImagePaths.Count == 0 && !season.LockedImages.Contains(ImageType.Backdrop)) { var n = images.SelectSingleNode("//Banner[BannerType='fanart'][Season='" + seasonNumber + "']"); if (n != null) diff --git a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs b/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs index 2e4e53b3bf..9bd24cdd38 100644 --- a/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/RemoteSeriesProvider.cs @@ -282,12 +282,13 @@ namespace MediaBrowser.Providers.TV seriesDoc.Load(seriesXmlPath); FetchMainInfo(series, seriesDoc); + if (!series.LockedFields.Contains(MetadataFields.Cast)) + { + var actorsDoc = new XmlDocument(); + actorsDoc.Load(actorsXmlPath); - var actorsDoc = new XmlDocument(); - actorsDoc.Load(actorsXmlPath); - - FetchActors(series, actorsDoc, seriesDoc); - + FetchActors(series, actorsDoc, seriesDoc); + } if (ConfigurationManager.Configuration.SaveLocalMeta) { var ms = new MemoryStream(); @@ -370,8 +371,14 @@ namespace MediaBrowser.Providers.TV /// The doc. private void FetchMainInfo(Series series, XmlDocument doc) { - series.Name = doc.SafeGetString("//SeriesName"); - series.Overview = doc.SafeGetString("//Overview"); + if (!series.LockedFields.Contains(MetadataFields.Name)) + { + series.Name = doc.SafeGetString("//SeriesName"); + } + if (!series.LockedFields.Contains(MetadataFields.Overview)) + { + series.Overview = doc.SafeGetString("//Overview"); + } series.CommunityRating = doc.SafeGetSingle("//Rating", 0, 10); series.AirDays = TVUtils.GetAirDays(doc.SafeGetString("//Airs_DayOfWeek")); series.AirTime = doc.SafeGetString("//Airs_Time"); @@ -384,36 +391,39 @@ namespace MediaBrowser.Providers.TV //Runtime is in minutes, and 1 tick = 10000 ms series.RunTimeTicks = doc.SafeGetInt32("//Runtime") * 6; - string s = doc.SafeGetString("//Network"); - - if (!string.IsNullOrWhiteSpace(s)) + if (!series.LockedFields.Contains(MetadataFields.Studios)) { - series.Studios.Clear(); + string s = doc.SafeGetString("//Network"); - foreach (var studio in s.Trim().Split('|')) + if (!string.IsNullOrWhiteSpace(s)) { - series.AddStudio(studio); + series.Studios.Clear(); + + foreach (var studio in s.Trim().Split('|')) + { + series.AddStudio(studio); + } } } - series.OfficialRating = doc.SafeGetString("//ContentRating"); - - string g = doc.SafeGetString("//Genre"); - - if (g != null) + if (!series.LockedFields.Contains(MetadataFields.Genres)) { - string[] genres = g.Trim('|').Split('|'); - if (g.Length > 0) - { - series.Genres.Clear(); + string g = doc.SafeGetString("//Genre"); - foreach (var genre in genres) + if (g != null) + { + string[] genres = g.Trim('|').Split('|'); + if (g.Length > 0) { - series.AddGenre(genre); + series.Genres.Clear(); + + foreach (var genre in genres) + { + series.AddGenre(genre); + } } } } - if (series.Status == SeriesStatus.Ended) { var document = XDocument.Load(new XmlNodeReader(doc)); diff --git a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs index 93f28075d9..56bfdb215d 100644 --- a/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs +++ b/MediaBrowser.Providers/TV/TvdbSeriesImageProvider.cs @@ -227,7 +227,7 @@ namespace MediaBrowser.Providers.TV /// Task. private async Task FetchImages(Series series, XmlDocument images, CancellationToken cancellationToken) { - if (!series.HasImage(ImageType.Primary)) + if (!series.HasImage(ImageType.Primary) && !series.LockedImages.Contains(ImageType.Primary)) { var n = images.SelectSingleNode("//Banner[BannerType='poster']"); if (n != null) @@ -242,7 +242,7 @@ namespace MediaBrowser.Providers.TV } } - if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.HasImage(ImageType.Banner)) + if (ConfigurationManager.Configuration.DownloadSeriesImages.Banner && !series.HasImage(ImageType.Banner) && !series.LockedImages.Contains(ImageType.Banner)) { var n = images.SelectSingleNode("//Banner[BannerType='series']"); if (n != null) @@ -257,7 +257,7 @@ namespace MediaBrowser.Providers.TV } } - if (series.BackdropImagePaths.Count == 0) + if (series.BackdropImagePaths.Count == 0 && !series.LockedImages.Contains(ImageType.Backdrop)) { var bdNo = series.BackdropImagePaths.Count;