diff --git a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs index 6b4faa5cb..31cd23057 100644 --- a/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs +++ b/src/NzbDrone.Core.Test/MetadataSource/SkyHook/SkyHookProxyFixture.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using FluentAssertions; @@ -102,7 +102,7 @@ namespace NzbDrone.Core.Test.MetadataSource.SkyHook episode.AirDateUtc.Value.Kind.Should().Be(DateTimeKind.Utc); } - episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.Url.Contains("-940.")) + episode.Images.Any(i => i.CoverType == MediaCoverTypes.Screenshot && i.RemoteUrl.Contains("-940.")) .Should() .BeFalse(); } diff --git a/src/NzbDrone.Core/Datastore/Migration/183_update_images_remote_url.cs b/src/NzbDrone.Core/Datastore/Migration/183_update_images_remote_url.cs new file mode 100644 index 000000000..e100657e0 --- /dev/null +++ b/src/NzbDrone.Core/Datastore/Migration/183_update_images_remote_url.cs @@ -0,0 +1,15 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Migration(183)] + public class update_images_remote_url : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Execute.Sql("UPDATE Episodes SET Images = REPLACE(Images, '\"url\"', '\"remoteUrl\"')"); + Execute.Sql("UPDATE Series SET Images = REPLACE(Images, '\"url\"', '\"remoteUrl\"'), Actors = REPLACE(Actors, '\"url\"', '\"remoteUrl\"'), Seasons = REPLACE(Seasons, '\"url\"', '\"remoteUrl\"')"); + } + } +} diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs index 343873072..b8e717392 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Roksbox/RoksboxMetadata.cs @@ -227,7 +227,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox var filename = Path.GetFileName(seasonFolder) + ".jpg"; var path = series.Path.GetRelativePath(Path.Combine(series.Path, seasonFolder, filename)); - return new List { new ImageFileResult(path, image.Url) }; + return new List { new ImageFileResult(path, image.RemoteUrl) }; } public override List EpisodeImages(Series series, EpisodeFile episodeFile) @@ -245,7 +245,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Roksbox return new List(); } - return new List { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url) }; + return new List { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl) }; } private string GetEpisodeMetadataFilename(string episodeFilePath) diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs index ef0a6b9b8..d9f052799 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Wdtv/WdtvMetadata.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -220,7 +220,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv var path = Path.Combine(seasonFolder, "folder.jpg"); - return new List { new ImageFileResult(path, image.Url) }; + return new List { new ImageFileResult(path, image.RemoteUrl) }; } public override List EpisodeImages(Series series, EpisodeFile episodeFile) @@ -238,7 +238,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Wdtv return new List(); } - return new List { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url) }; + return new List { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl) }; } private string GetEpisodeMetadataFilename(string episodeFilePath) diff --git a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs index 5ac8e5eff..78a90804e 100644 --- a/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs +++ b/src/NzbDrone.Core/Extras/Metadata/Consumers/Xbmc/XbmcMetadata.cs @@ -205,7 +205,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc if (actor.Images.Any()) { - xmlActor.Add(new XElement("thumb", actor.Images.First().Url)); + xmlActor.Add(new XElement("thumb", actor.Images.First().RemoteUrl)); } tvShow.Add(xmlActor); @@ -287,7 +287,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc } else { - details.Add(new XElement("thumb", image.Url)); + details.Add(new XElement("thumb", image.RemoteUrl)); } details.Add(new XElement("watched", watched)); @@ -394,7 +394,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc return new List { - new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url) + new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl) }; } catch (Exception ex) @@ -427,7 +427,7 @@ namespace NzbDrone.Core.Extras.Metadata.Consumers.Xbmc filename = string.Format("season-specials-{0}.jpg", image.CoverType.ToString().ToLower()); } - yield return new ImageFileResult(filename, image.Url); + yield return new ImageFileResult(filename, image.RemoteUrl); } } diff --git a/src/NzbDrone.Core/MediaCover/MediaCover.cs b/src/NzbDrone.Core/MediaCover/MediaCover.cs index acea3ab42..d98f50e18 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCover.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCover.cs @@ -22,10 +22,10 @@ namespace NzbDrone.Core.MediaCover { } - public MediaCover(MediaCoverTypes coverType, string url) + public MediaCover(MediaCoverTypes coverType, string remoteUrl) { CoverType = coverType; - Url = url; + RemoteUrl = remoteUrl; } } } diff --git a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs index d45ab6161..b4c6f0022 100644 --- a/src/NzbDrone.Core/MediaCover/MediaCoverService.cs +++ b/src/NzbDrone.Core/MediaCover/MediaCoverService.cs @@ -77,7 +77,6 @@ namespace NzbDrone.Core.MediaCover // Series isn't in Sonarr yet, map via a proxy to circument referrer issues foreach (var mediaCover in covers) { - mediaCover.RemoteUrl = mediaCover.Url; mediaCover.Url = _mediaCoverProxy.RegisterUrl(mediaCover.RemoteUrl); } } @@ -87,7 +86,6 @@ namespace NzbDrone.Core.MediaCover { var filePath = GetCoverPath(seriesId, mediaCover.CoverType); - mediaCover.RemoteUrl = mediaCover.Url; mediaCover.Url = _configFileProvider.UrlBase + @"/MediaCover/" + seriesId + "/" + mediaCover.CoverType.ToString().ToLower() + ".jpg"; if (_diskProvider.FileExists(filePath)) @@ -115,7 +113,7 @@ namespace NzbDrone.Core.MediaCover var alreadyExists = false; try { - alreadyExists = _coverExistsSpecification.AlreadyExists(cover.Url, fileName); + alreadyExists = _coverExistsSpecification.AlreadyExists(cover.RemoteUrl, fileName); if (!alreadyExists) { DownloadCover(series, cover); @@ -159,8 +157,8 @@ namespace NzbDrone.Core.MediaCover { var fileName = GetCoverPath(series.Id, cover.CoverType); - _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, series, cover.Url); - _httpClient.DownloadFile(cover.Url, fileName); + _logger.Info("Downloading {0} for {1} {2}", cover.CoverType, series, cover.RemoteUrl); + _httpClient.DownloadFile(cover.RemoteUrl, fileName); } private void EnsureResizedCovers(Series series, MediaCover cover, bool forceResize) diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index c5ff70ddb..97c91ed56 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -310,7 +310,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { return new MediaCover.MediaCover { - Url = arg.Url, + RemoteUrl = arg.Url, CoverType = MapCoverType(arg.CoverType) }; } diff --git a/src/NzbDrone.Core/Notifications/Discord/Discord.cs b/src/NzbDrone.Core/Notifications/Discord/Discord.cs index d7f3479cd..f6e22ecb7 100644 --- a/src/NzbDrone.Core/Notifications/Discord/Discord.cs +++ b/src/NzbDrone.Core/Notifications/Discord/Discord.cs @@ -48,7 +48,7 @@ namespace NzbDrone.Core.Notifications.Discord { embed.Thumbnail = new DiscordImage { - Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url + Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl }; } @@ -56,7 +56,7 @@ namespace NzbDrone.Core.Notifications.Discord { embed.Image = new DiscordImage { - Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url + Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.RemoteUrl }; } @@ -139,7 +139,7 @@ namespace NzbDrone.Core.Notifications.Discord { embed.Thumbnail = new DiscordImage { - Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url + Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl }; } @@ -147,7 +147,7 @@ namespace NzbDrone.Core.Notifications.Discord { embed.Image = new DiscordImage { - Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url + Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.RemoteUrl }; } diff --git a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs index 4c6b9ad22..53e175fa3 100644 --- a/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs +++ b/src/NzbDrone.Core/Notifications/Gotify/Gotify.cs @@ -101,7 +101,7 @@ namespace NzbDrone.Core.Notifications.Gotify if (Settings.IncludeSeriesPoster && series != null) { - var poster = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.Url; + var poster = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Poster)?.RemoteUrl; if (poster != null) { diff --git a/src/Sonarr.Api.V3/Series/SeriesResource.cs b/src/Sonarr.Api.V3/Series/SeriesResource.cs index 1bdf58ae3..c57e52af5 100644 --- a/src/Sonarr.Api.V3/Series/SeriesResource.cs +++ b/src/Sonarr.Api.V3/Series/SeriesResource.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Languages; using NzbDrone.Core.MediaCover; using NzbDrone.Core.Tv; @@ -100,7 +101,9 @@ namespace Sonarr.Api.V3.Series // PreviousAiring Network = model.Network, AirTime = model.AirTime, - Images = model.Images, + + // JsonClone + Images = model.Images.JsonClone(), Seasons = model.Seasons.ToResource(includeSeasonImages), Year = model.Year,