1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Fixed: Images for some series not downloading

Closes #5376
This commit is contained in:
Mark McDowall 2023-01-15 20:09:34 -08:00
parent c08b451564
commit b848100693
11 changed files with 41 additions and 25 deletions

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using FluentAssertions;
@ -102,7 +102,7 @@ private void ValidateEpisode(Episode episode)
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();
}

View File

@ -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\"')");
}
}
}

View File

@ -227,7 +227,7 @@ public override List<ImageFileResult> SeasonImages(Series series, Season season)
var filename = Path.GetFileName(seasonFolder) + ".jpg";
var path = series.Path.GetRelativePath(Path.Combine(series.Path, seasonFolder, filename));
return new List<ImageFileResult> { new ImageFileResult(path, image.Url) };
return new List<ImageFileResult> { new ImageFileResult(path, image.RemoteUrl) };
}
public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile episodeFile)
@ -245,7 +245,7 @@ public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile e
return new List<ImageFileResult>();
}
return new List<ImageFileResult> { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url) };
return new List<ImageFileResult> { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl) };
}
private string GetEpisodeMetadataFilename(string episodeFilePath)

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -220,7 +220,7 @@ public override List<ImageFileResult> SeasonImages(Series series, Season season)
var path = Path.Combine(seasonFolder, "folder.jpg");
return new List<ImageFileResult> { new ImageFileResult(path, image.Url) };
return new List<ImageFileResult> { new ImageFileResult(path, image.RemoteUrl) };
}
public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile episodeFile)
@ -238,7 +238,7 @@ public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile e
return new List<ImageFileResult>();
}
return new List<ImageFileResult> { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url) };
return new List<ImageFileResult> { new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl) };
}
private string GetEpisodeMetadataFilename(string episodeFilePath)

View File

@ -205,7 +205,7 @@ public override MetadataFileResult SeriesMetadata(Series series)
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 @@ public override MetadataFileResult EpisodeMetadata(Series series, EpisodeFile ep
}
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 @@ public override List<ImageFileResult> EpisodeImages(Series series, EpisodeFile e
return new List<ImageFileResult>
{
new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.Url)
new ImageFileResult(GetEpisodeImageFilename(episodeFile.RelativePath), screenshot.RemoteUrl)
};
}
catch (Exception ex)
@ -427,7 +427,7 @@ private IEnumerable<ImageFileResult> ProcessSeasonImages(Series series, Season s
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);
}
}

View File

@ -22,10 +22,10 @@ public MediaCover()
{
}
public MediaCover(MediaCoverTypes coverType, string url)
public MediaCover(MediaCoverTypes coverType, string remoteUrl)
{
CoverType = coverType;
Url = url;
RemoteUrl = remoteUrl;
}
}
}

View File

@ -77,7 +77,6 @@ public void ConvertToLocalUrls(int seriesId, IEnumerable<MediaCover> covers)
// 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 @@ public void ConvertToLocalUrls(int seriesId, IEnumerable<MediaCover> covers)
{
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 @@ private bool EnsureCovers(Series series)
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 @@ private void DownloadCover(Series series, MediaCover cover)
{
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)

View File

@ -310,7 +310,7 @@ private static MediaCover.MediaCover MapImage(ImageResource arg)
{
return new MediaCover.MediaCover
{
Url = arg.Url,
RemoteUrl = arg.Url,
CoverType = MapCoverType(arg.CoverType)
};
}

View File

@ -48,7 +48,7 @@ public override void OnGrab(GrabMessage message)
{
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 @@ public override void OnGrab(GrabMessage message)
{
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 @@ public override void OnDownload(DownloadMessage message)
{
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 @@ public override void OnDownload(DownloadMessage message)
{
embed.Image = new DiscordImage
{
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.Url
Url = series.Images.FirstOrDefault(x => x.CoverType == MediaCoverTypes.Fanart)?.RemoteUrl
};
}

View File

@ -101,7 +101,7 @@ private void SendNotification(string title, string message, Series series)
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)
{

View File

@ -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 @@ public static SeriesResource ToResource(this NzbDrone.Core.Tv.Series model, bool
// PreviousAiring
Network = model.Network,
AirTime = model.AirTime,
Images = model.Images,
// JsonClone
Images = model.Images.JsonClone(),
Seasons = model.Seasons.ToResource(includeSeasonImages),
Year = model.Year,