Merge pull request #3199 from msdeibel/3195_AlbumCoverUrls

Fixes issue #3195
pull/3200/head
Jamie 5 years ago committed by GitHub
commit c13958980e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,18 @@
name: ASP.NET Core CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 2.2.108
- name: Build Backend
run: ./build.sh --settings_skipverification=true

@ -0,0 +1,9 @@
workflow "New workflow" {
on = "push"
resolves = [".NET Core CLI"]
}
action ".NET Core CLI" {
uses = "baruchiro/github-actions@0.0.1"
args = "build src/Ombi.sln"
}

@ -17,6 +17,7 @@ using Ombi.Api.Lidarr.Models;
using Ombi.Core.Authentication; using Ombi.Core.Authentication;
using Ombi.Core.Settings; using Ombi.Core.Settings;
using Ombi.Helpers; using Ombi.Helpers;
using Ombi.Core.Helpers;
using Ombi.Settings.Settings.Models; using Ombi.Settings.Settings.Models;
using Ombi.Settings.Settings.Models.External; using Ombi.Settings.Settings.Models.External;
using Ombi.Store.Entities; using Ombi.Store.Entities;
@ -166,7 +167,7 @@ namespace Ombi.Core.Engine
Rating = a.ratings?.value ?? 0m, Rating = a.ratings?.value ?? 0m,
ReleaseDate = a.releaseDate, ReleaseDate = a.releaseDate,
Title = a.title, Title = a.title,
Disk = a.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url?.Replace("http", "https"), Disk = a.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url?.ToHttpsUrl(),
Genres = a.genres, Genres = a.genres,
AlbumType = a.albumType, AlbumType = a.albumType,
ArtistName = a.artist.artistName, ArtistName = a.artist.artistName,
@ -187,7 +188,7 @@ namespace Ombi.Core.Engine
//vm.ArtistName = a.artist?.artistName; //vm.ArtistName = a.artist?.artistName;
} }
vm.Cover = a.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url?.Replace("http", "https"); vm.Cover = a.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url?.ToHttpsUrl();
await Rules.StartSpecificRules(vm, SpecificRules.LidarrAlbum); await Rules.StartSpecificRules(vm, SpecificRules.LidarrAlbum);
@ -205,7 +206,7 @@ namespace Ombi.Core.Engine
Rating = a.ratings?.value ?? 0m, Rating = a.ratings?.value ?? 0m,
ReleaseDate = a.releaseDate, ReleaseDate = a.releaseDate,
Title = a.title, Title = a.title,
Disk = a.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url?.Replace("http", "https"), Disk = a.images?.FirstOrDefault(x => x.coverType.Equals("disc"))?.url?.ToHttpsUrl(),
Genres = a.genres Genres = a.genres
}; };
if (a.artistId > 0) if (a.artistId > 0)
@ -223,7 +224,7 @@ namespace Ombi.Core.Engine
vm.ArtistName = a.artist?.artistName; vm.ArtistName = a.artist?.artistName;
} }
vm.Cover = a.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url?.Replace("http", "https"); vm.Cover = a.images?.FirstOrDefault(x => x.coverType.Equals("cover"))?.url?.ToHttpsUrl();
if (vm.Cover.IsNullOrEmpty()) if (vm.Cover.IsNullOrEmpty())
{ {
vm.Cover = a.remoteCover; vm.Cover = a.remoteCover;

@ -0,0 +1,44 @@
using NUnit.Framework;
namespace Ombi.Helpers.Tests
{
[TestFixture]
public class StringHelperTests
{
[Test]
public void ToHttpsUrl_ShouldReturnsHttpsUrl_HttpUrl()
{
var sourceUrl = "http://www.test.url";
var expectedUrl = "https://www.test.url";
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the source URL as https");
}
[Test]
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_HttpsUrl()
{
var sourceUrl = "https://www.test.url";
var expectedUrl = "https://www.test.url";
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged https URL");
}
[Test]
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_NonHttpUrl()
{
var sourceUrl = "ftp://www.test.url";
var expectedUrl = "ftp://www.test.url";
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged non-http URL");
}
[Test]
public void ToHttpsUrl_ShouldReturnsUnchangedUrl_InvalidUrl()
{
var sourceUrl = "http:/www.test.url";
var expectedUrl = "http:/www.test.url";
Assert.AreEqual(expectedUrl, sourceUrl.ToHttpsUrl(), "Should return the unchanged invalid URL");
}
}
}

@ -128,5 +128,10 @@ namespace Ombi.Helpers
{ {
return string.Concat(str.Where(c => !chars.Contains(c))); return string.Concat(str.Where(c => !chars.Contains(c)));
} }
public static string ToHttpsUrl(this string currentUrl)
{
return currentUrl.Replace("http://", "https://");
}
} }
} }

@ -29,7 +29,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.show.runtime.ToString())) .ForMember(dest => dest.Runtime, opts => opts.MapFrom(src => src.show.runtime.ToString()))
.ForMember(dest => dest.SeriesId, opts => opts.MapFrom(src => src.show.id)) .ForMember(dest => dest.SeriesId, opts => opts.MapFrom(src => src.show.id))
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.show.name)) .ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.show.name))
.ForMember(dest => dest.Banner, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.show.image.medium) ? src.show.image.medium.Replace("http", "https") : string.Empty)) .ForMember(dest => dest.Banner, opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.show.image.medium) ? src.show.image.medium.ToHttpsUrl() : string.Empty))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.show.status)); .ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.show.status));
CreateMap<TvMazeShow, SearchTvShowViewModel>() CreateMap<TvMazeShow, SearchTvShowViewModel>()
@ -46,7 +46,7 @@ namespace Ombi.Mapping.Profiles
.ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.name)) .ForMember(dest => dest.Title, opts => opts.MapFrom(src => src.name))
.ForMember(dest => dest.Banner, .ForMember(dest => dest.Banner,
opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.image.medium) opts => opts.MapFrom(src => !string.IsNullOrEmpty(src.image.medium)
? src.image.medium.Replace("http", "https") ? src.image.medium.ToHttpsUrl()
: string.Empty)) : string.Empty))
.ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.status)); .ForMember(dest => dest.Status, opts => opts.MapFrom(src => src.status));

@ -682,7 +682,7 @@ namespace Ombi.Schedule.Jobs.Ombi
var banner = info.image?.original; var banner = info.image?.original;
if (!string.IsNullOrEmpty(banner)) if (!string.IsNullOrEmpty(banner))
{ {
banner = banner.Replace("http", "https"); // Always use the Https banners banner = banner.ToHttpsUrl(); // Always use the Https banners
} }
var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId); var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId);
@ -804,7 +804,7 @@ namespace Ombi.Schedule.Jobs.Ombi
var banner = info.image?.original; var banner = info.image?.original;
if (!string.IsNullOrEmpty(banner)) if (!string.IsNullOrEmpty(banner))
{ {
banner = banner.Replace("http", "https"); // Always use the Https banners banner = banner.ToHttpsUrl(); // Always use the Https banners
} }
var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId); var tvInfo = await _movieApi.GetTVInfo(t.TheMovieDbId);

Loading…
Cancel
Save