diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index c7e22b5..fbef5c3 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -4,13 +4,14 @@ Describe the big picture of your changes here to communicate to the maintainers
## Types of changes
-What types of changes does your code introduce to Appium?
+What types of changes does your code introduce to Proxarr ?
_Put an `x` in the boxes that apply_
- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation Update (if none of the other choices apply)
+- [ ] CI/CD or unit tests improvements
## Further comments
diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml
index 7b420cb..75c50cb 100644
--- a/.github/workflows/pr.yml
+++ b/.github/workflows/pr.yml
@@ -48,7 +48,7 @@ jobs:
hide_complexity: true
indicators: true
output: both
- thresholds: '45 45'
+ thresholds: '95 95'
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
diff --git a/src/Proxarr.Api.Tests/Proxarr.Api.Tests.csproj b/src/Proxarr.Api.Tests/Proxarr.Api.Tests.csproj
index 83e5359..450391b 100644
--- a/src/Proxarr.Api.Tests/Proxarr.Api.Tests.csproj
+++ b/src/Proxarr.Api.Tests/Proxarr.Api.Tests.csproj
@@ -6,13 +6,26 @@
enable
false
-
+
+
+
-
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
-
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/src/Proxarr.Api.Tests/QualifierControllerTests.cs b/src/Proxarr.Api.Tests/QualifierControllerTests.cs
index 6633726..c3dea92 100644
--- a/src/Proxarr.Api.Tests/QualifierControllerTests.cs
+++ b/src/Proxarr.Api.Tests/QualifierControllerTests.cs
@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Mvc;
+using FluentAssertions;
+using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Moq;
using Proxarr.Api.Controllers;
@@ -33,7 +34,21 @@ public async Task Qualified_ShouldReturnOk_WhenEventTypeIsTest()
var result = await _controller.Qualified(media, cancellationToken);
// Assert
- Assert.IsType(result);
+ result.Should().BeOfType();
+ }
+
+ [Fact]
+ public async Task Qualified_ShouldReturnOk_WhenEventTypeMovieAdded()
+ {
+ // Arrange
+ var media = new MovieAdded { EventType = "MovieAdded", ApplicationUrl = "http://localhost", Movie=default };
+ var cancellationToken = new CancellationToken();
+
+ // Act
+ var result = await _controller.Qualified(media, cancellationToken);
+
+ // Assert
+ result.Should().BeOfType();
}
[Fact]
@@ -49,7 +64,7 @@ public async Task Qualified_ShouldReturnNotFound_WhenMovieNotFound()
var result = await _controller.Qualified(movie, cancellationToken);
// Assert
- Assert.IsType(result);
+ result.Should().BeOfType();
}
[Fact]
@@ -65,7 +80,7 @@ public async Task Qualified_ShouldReturnNotFound_WhenTvNotFound()
var result = await _controller.Qualified(tvAdded, cancellationToken);
// Assert
- Assert.IsType(result);
+ result.Should().BeOfType();
}
[Fact]
@@ -79,7 +94,7 @@ public async Task Qualified_ShouldReturnBadRequest_WhenMediaIsInvalid()
var result = await _controller.Qualified(media, cancellationToken);
// Assert
- Assert.IsType(result);
+ result.Should().BeOfType();
}
[Fact]
@@ -95,7 +110,7 @@ public async Task Qualified_ShouldReturnOk_WhenMediaIsValid()
var result = await _controller.Qualified(tvAdded, cancellationToken);
// Assert
- Assert.IsType(result);
+ result.Should().BeOfType();
}
}
}
\ No newline at end of file
diff --git a/src/Proxarr.Api.Tests/RadarrServiceTests.cs b/src/Proxarr.Api.Tests/RadarrServiceTests.cs
index 2710b8f..9a3c3cb 100644
--- a/src/Proxarr.Api.Tests/RadarrServiceTests.cs
+++ b/src/Proxarr.Api.Tests/RadarrServiceTests.cs
@@ -10,6 +10,7 @@
using TMDbLib.Objects.General;
using TMDbLib.Objects.Movies;
using Movie = Proxarr.Api.Models.Movie;
+using FluentAssertions;
namespace Proxarr.Api.Tests
{
@@ -32,7 +33,7 @@ public RadarrServiceTests()
var appConfig = new AppConfiguration
{
Clients = [new ClientConfiguration { Application = "Sonarr", BaseUrl = "http://localhost", ApiKey = "fake_api_key" }],
- WatchProviders = "US:Netflix, FR: Amazon Prime Video",
+ WatchProviders = "US:Netflix, FR: Amazon Prime Video, US:Netflix with ads",
};
_appConfigMock.Setup(x => x.Value).Returns(appConfig);
@@ -42,7 +43,14 @@ public RadarrServiceTests()
}
[Fact]
- public async Task Qualify_ShouldReturnNotFound_WhenMovieNotFound()
+ public async Task Ctor_ShouldThrowArgNullEx_WhenAppConfigurationNull()
+ {
+ Action act = () => new RadarrService(null, null, null, null);
+ act.Should().Throw().WithParameterName("appConfiguration");
+ }
+
+ [Fact]
+ public async Task Qualify_ShouldReturnNotFound_WhenMovieNotFoundIntoRadarr()
{
// Arrange
var movieAdded = new MovieAdded
@@ -66,6 +74,31 @@ public async Task Qualify_ShouldReturnNotFound_WhenMovieNotFound()
Assert.Equal("NotFound", result);
}
+ [Fact]
+ public async Task Qualify_ShouldReturnNotFound_WhenMovieNotFoundIntoTMDB()
+ {
+ // Arrange
+ var movieAdded = new MovieAdded
+ {
+ ApplicationUrl = "http://localhost",
+ EventType = "FULL_SCAN",
+ Movie = new Movie { Id = 1, TmdbId = 123, Title = "Test Movie" }
+ };
+ var cancellationToken = new CancellationToken();
+
+ _tmdbClientMock.Setup(x => x.GetMovieAsync(123, MovieMethods.WatchProviders, cancellationToken))
+ .ReturnsAsync((TMDbLib.Objects.Movies.Movie)null);
+
+ _radarrClientMock.Setup(x => x.MovieGET2Async(1, cancellationToken))
+ .ReturnsAsync((MovieResource)null);
+
+ // Act
+ var result = await _radarrService.Qualify(movieAdded, cancellationToken);
+
+ // Assert
+ Assert.Equal("NotFound", result);
+ }
+
[Fact]
public async Task Qualify_ShouldUpdateTags_WhenMovieFound()
{
@@ -82,7 +115,7 @@ public async Task Qualify_ShouldUpdateTags_WhenMovieFound()
{
Results = new Dictionary
{
- { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }] } }
+ { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }], FlatRate = [new WatchProviderItem { ProviderName = "Netflix with Ads" }] } }
}
};
@@ -200,5 +233,44 @@ public async Task Qualify_Should_BeTagged_When_MatchedWatchProvider()
Assert.Single(movieResource.Tags);
Assert.Contains(movieResource.Tags, x => x == _qualifyTag.Id);
}
+
+ [Fact]
+ public async Task Qualify_Should_BeTagged_When_NoWatchProviders()
+ {
+ // Arrange
+ var tvAdded = new MovieAdded
+ {
+ ApplicationUrl = "http://localhost",
+ EventType = "MovieAdded",
+ Movie = new Movie { Id = 1, TmdbId = 123, Title = "Test Movie" },
+ };
+ var cancellationToken = new CancellationToken();
+
+
+ var movieResource = new MovieResource { Id = 1, Title = "Test Series", Tags = [] };
+
+ _tmdbClientMock.Setup(x => x.GetMovieAsync(123, MovieMethods.WatchProviders, cancellationToken))
+ .ReturnsAsync(new TMDbLib.Objects.Movies.Movie());
+
+ _radarrClientMock.Setup(x => x.MovieGET2Async(1, cancellationToken))
+ .ReturnsAsync(movieResource);
+
+ _radarrClientMock.Setup(x => x.TagAllAsync(cancellationToken))
+ .ReturnsAsync([_qualifyTag]);
+
+ var tagResource = new TagResource { Id = 1, Label = "Netflix" };
+
+ _radarrClientMock.Setup(x => x.TagPOSTAsync(It.IsAny(), cancellationToken))
+ .ReturnsAsync(tagResource);
+
+ // Act
+ var result = await _radarrService.Qualify(tvAdded, cancellationToken);
+
+ // Assert
+ _radarrClientMock.Verify(x => x.MoviePUTAsync(false, "1", movieResource, cancellationToken), Times.Once);
+ Assert.Empty(result);
+ Assert.Single(movieResource.Tags);
+ Assert.Contains(movieResource.Tags, x => x == _qualifyTag.Id);
+ }
}
}
\ No newline at end of file
diff --git a/src/Proxarr.Api.Tests/ScheduledServiceExtensionsTests.cs b/src/Proxarr.Api.Tests/ScheduledServiceExtensionsTests.cs
new file mode 100644
index 0000000..195e3d6
--- /dev/null
+++ b/src/Proxarr.Api.Tests/ScheduledServiceExtensionsTests.cs
@@ -0,0 +1,35 @@
+using FluentAssertions;
+using Microsoft.Extensions.DependencyInjection;
+using Moq;
+using Proxarr.Api.Core;
+using Proxarr.Api.HostedServices;
+
+namespace Proxarr.Api.Tests
+{
+ public class ScheduledServiceExtensionsTests
+ {
+ [Fact]
+ public void AddCronJob_ShouldThrowNullException_WhenOptionsNull()
+ {
+ IServiceCollection services = new ServiceCollection();
+ Action act = () => services.AddCronJob(null);
+ act.Should().Throw().WithParameterName("options").WithMessage("Please provide Schedule Configurations. (Parameter 'options')");
+ }
+
+ [Fact]
+ public void AddCronJob_ShouldThrowNullException_WhenCronIsNull()
+ {
+ IServiceCollection services = new ServiceCollection();
+ Action act = () => services.AddCronJob(x => x.CronExpression = string.Empty);
+ act.Should().Throw().WithParameterName("options").WithMessage("Empty Cron Expression is not allowed. (Parameter 'options')");
+ }
+
+ [Fact]
+ public void AddCronJob_ShouldAddHostedService()
+ {
+ IServiceCollection services = new ServiceCollection();
+ Action act = () => services.AddCronJob(x => x.CronExpression = "* * * * *");
+ act.Should().NotThrow();
+ }
+ }
+}
diff --git a/src/Proxarr.Api.Tests/SonarrServiceTests.cs b/src/Proxarr.Api.Tests/SonarrServiceTests.cs
index 94514a4..d3db58e 100644
--- a/src/Proxarr.Api.Tests/SonarrServiceTests.cs
+++ b/src/Proxarr.Api.Tests/SonarrServiceTests.cs
@@ -1,4 +1,5 @@
-using Microsoft.Extensions.Logging;
+using FluentAssertions;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Moq;
using Proxarr.Api.Configuration;
@@ -31,7 +32,7 @@ public SonarrServiceTests()
var appConfig = new AppConfiguration
{
Clients = [new ClientConfiguration { Application = "Sonarr", BaseUrl = "http://localhost", ApiKey = "fake_api_key" }],
- WatchProviders = "US:Netflix, FR: Amazon Prime Video",
+ WatchProviders = "US:Netflix, FR: Amazon Prime Video, US:Netflix with ads",
};
_appConfigMock.Setup(x => x.Value).Returns(appConfig);
@@ -41,7 +42,14 @@ public SonarrServiceTests()
}
[Fact]
- public async Task Qualify_ShouldReturnNotFound_WhenSeriesNotFound()
+ public async Task Ctor_ShouldThrowArgNullEx_WhenAppConfigurationNull()
+ {
+ Action act = () => new SonarrService(null, null, null, null);
+ act.Should().Throw().WithParameterName("appConfiguration");
+ }
+
+ [Fact]
+ public async Task Qualify_ShouldReturnNotFound_WhenSeriesNotFoundIntoSonarr()
{
// Arrange
var tvAdded = new TvAdded
@@ -65,6 +73,31 @@ public async Task Qualify_ShouldReturnNotFound_WhenSeriesNotFound()
Assert.Equal("NotFound", result);
}
+ [Fact]
+ public async Task Qualify_ShouldReturnNotFound_WhenSeriesNotFoundIntoTMDB()
+ {
+ // Arrange
+ var tvAdded = new TvAdded
+ {
+ ApplicationUrl = "http://localhost",
+ EventType = "FULL_SCAN",
+ Series = new Series { Id = 1, TmdbId = 123, Title = "Test Series" }
+ };
+ var cancellationToken = new CancellationToken();
+
+ _tmdbClientMock.Setup(x => x.GetTvShowAsync(123, TvShowMethods.WatchProviders, null, null, cancellationToken))
+ .ReturnsAsync((TvShow)null);
+
+ _sonarrClientMock.Setup(x => x.SeriesGETAsync(1, false, cancellationToken))
+ .ReturnsAsync((SeriesResource)null);
+
+ // Act
+ var result = await _sonarrService.Qualify(tvAdded, cancellationToken);
+
+ // Assert
+ Assert.Equal("NotFound", result);
+ }
+
[Fact]
public async Task Qualify_ShouldUpdateTags_WhenSeriesFound()
{
@@ -81,7 +114,7 @@ public async Task Qualify_ShouldUpdateTags_WhenSeriesFound()
{
Results = new Dictionary
{
- { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }] } }
+ { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }], FlatRate = [new WatchProviderItem { ProviderName = "Netflix with Ads" }] } }
}
};
@@ -123,7 +156,7 @@ public async Task Qualify_Should_NotBeTagged_When_MatchedWatchProvider()
{
Results = new Dictionary
{
- { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }] } }
+ { "US", new WatchProviders { Free = [new WatchProviderItem { ProviderName = "Netflix" }], FlatRate = [new WatchProviderItem { ProviderName = "Netflix with Ads" }] } }
}
};
@@ -196,5 +229,41 @@ public async Task Qualify_Should_BeTagged_When_MatchedWatchProvider()
Assert.Single(seriesResource.Tags);
Assert.Contains(seriesResource.Tags, x => x == _qualifyTag.Id);
}
+
+ [Fact]
+ public async Task Qualify_Should_BeTagged_When_NoWatchProvider()
+ {
+ // Arrange
+ var tvAdded = new TvAdded
+ {
+ ApplicationUrl = "http://localhost",
+ EventType = "SerieAdd",
+ Series = new Series { Id = 1, TmdbId = 123, Title = "Test Series" },
+ };
+ var cancellationToken = new CancellationToken();
+
+ var seriesResource = new SeriesResource { Id = 1, Title = "Test Series", Tags = [] };
+
+ _tmdbClientMock.Setup(x => x.GetTvShowAsync(123, TvShowMethods.WatchProviders, null, null, cancellationToken))
+ .ReturnsAsync(new TvShow ());
+
+ _sonarrClientMock.Setup(x => x.SeriesGETAsync(1, false, cancellationToken))
+ .ReturnsAsync(seriesResource);
+
+ _sonarrClientMock.Setup(x => x.TagAllAsync(cancellationToken))
+ .ReturnsAsync([_qualifyTag]);
+
+ _sonarrClientMock.Setup(x => x.TagPOSTAsync(It.IsAny(), cancellationToken))
+ .ReturnsAsync(new TagResource { Id = 1, Label = "Netflix" });
+
+ // Act
+ var result = await _sonarrService.Qualify(tvAdded, cancellationToken);
+
+ // Assert
+ _sonarrClientMock.Verify(x => x.SeriesPUTAsync(false, "1", seriesResource, cancellationToken), Times.Once);
+ Assert.Empty(result);
+ Assert.Single(seriesResource.Tags);
+ Assert.Contains(seriesResource.Tags, x => x == _qualifyTag.Id);
+ }
}
}
\ No newline at end of file
diff --git a/src/Proxarr.Api/Configuration/AppConfiguration.cs b/src/Proxarr.Api/Configuration/AppConfiguration.cs
index 6033263..e949f22 100644
--- a/src/Proxarr.Api/Configuration/AppConfiguration.cs
+++ b/src/Proxarr.Api/Configuration/AppConfiguration.cs
@@ -54,13 +54,15 @@ private Dictionary InitProviders()
{
throw new FormatException("Malformed WATCH_PROVIDERS! Must follow this format: REGION:WatchProvider, REGION:WatchProvider, ... ex (US:Netflix,FR:Youtube)");
}
- if (!dict.TryGetValue(parts[0], out string[]? value))
+ var key = parts[0].Trim();
+ var val = parts[1].Trim();
+ if (!dict.TryGetValue(key, out string[]? value) || !dict.ContainsKey(key))
{
- dict.Add(parts[0].Trim(), [parts[1].Trim()]);
+ dict.Add(key, [val]);
}
else
{
- dict[parts[0]] = [.. value, parts[1].Trim()];
+ dict[key] = [.. value, val];
}
}
diff --git a/src/Proxarr.Api/Core/CronJobService.cs b/src/Proxarr.Api/Core/CronJobService.cs
index 473e6e3..b939351 100644
--- a/src/Proxarr.Api/Core/CronJobService.cs
+++ b/src/Proxarr.Api/Core/CronJobService.cs
@@ -106,6 +106,7 @@ public interface IScheduleConfig
TimeZoneInfo TimeZoneInfo { get; set; }
}
+ [ExcludeFromCodeCoverage]
public class ScheduleConfig : IScheduleConfig
{
public string CronExpression { get; set; } = string.Empty;
diff --git a/src/Proxarr.Api/Core/Extensions/ArrExtensions.cs b/src/Proxarr.Api/Core/Extensions/ArrExtensions.cs
index 2d08097..c715a7c 100644
--- a/src/Proxarr.Api/Core/Extensions/ArrExtensions.cs
+++ b/src/Proxarr.Api/Core/Extensions/ArrExtensions.cs
@@ -2,7 +2,6 @@
{
public static class ArrExtensions
{
-
public static Radarr.Http.Client.TagResource? Slugify(this Radarr.Http.Client.TagResource tagResource)
{
ArgumentNullException.ThrowIfNull(tagResource);
diff --git a/src/Proxarr.Api/Core/TmdbProxy.cs b/src/Proxarr.Api/Core/TmdbProxy.cs
index 5709a00..96459ba 100644
--- a/src/Proxarr.Api/Core/TmdbProxy.cs
+++ b/src/Proxarr.Api/Core/TmdbProxy.cs
@@ -1,4 +1,5 @@
-using TMDbLib.Client;
+using System.Diagnostics.CodeAnalysis;
+using TMDbLib.Client;
using TMDbLib.Objects.Movies;
using TMDbLib.Objects.TvShows;
@@ -10,13 +11,14 @@ public interface ITmdbProxy
Task GetTvShowAsync(int id, TvShowMethods extraMethods = TvShowMethods.Undefined, string language = null, string includeImageLanguage = null, CancellationToken cancellationToken = default);
}
+ [ExcludeFromCodeCoverage]
public class TmdbProxy : ITmdbProxy
{
private readonly TMDbClient _tMDbClient;
public TmdbProxy(TMDbClient tMDbClient)
{
-
+ ArgumentNullException.ThrowIfNull(tMDbClient);
_tMDbClient = tMDbClient;
}
diff --git a/src/Proxarr.Api/Models/MediaAdded.cs b/src/Proxarr.Api/Models/MediaAdded.cs
index fec6688..0cde547 100644
--- a/src/Proxarr.Api/Models/MediaAdded.cs
+++ b/src/Proxarr.Api/Models/MediaAdded.cs
@@ -1,7 +1,9 @@
-using System.Text.Json.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
namespace Proxarr.Api.Models
{
+ [ExcludeFromCodeCoverage]
public class MediaAdded
{
[JsonPropertyName("eventType")]
diff --git a/src/Proxarr.Api/Models/MovieAdded.cs b/src/Proxarr.Api/Models/MovieAdded.cs
index 9a1d550..b502c53 100644
--- a/src/Proxarr.Api/Models/MovieAdded.cs
+++ b/src/Proxarr.Api/Models/MovieAdded.cs
@@ -1,7 +1,9 @@
-using System.Text.Json.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
namespace Proxarr.Api.Models
{
+ [ExcludeFromCodeCoverage]
public class MovieAdded : MediaAdded
{
[JsonPropertyName("movie")]
@@ -11,6 +13,7 @@ public class MovieAdded : MediaAdded
public string? AddMethod { get; set; }
}
+ [ExcludeFromCodeCoverage]
public class Movie
{
[JsonPropertyName("id")]
diff --git a/src/Proxarr.Api/Models/TvAdded.cs b/src/Proxarr.Api/Models/TvAdded.cs
index c9e9627..ad0edc7 100644
--- a/src/Proxarr.Api/Models/TvAdded.cs
+++ b/src/Proxarr.Api/Models/TvAdded.cs
@@ -1,13 +1,16 @@
-using System.Text.Json.Serialization;
+using System.Diagnostics.CodeAnalysis;
+using System.Text.Json.Serialization;
namespace Proxarr.Api.Models
{
+ [ExcludeFromCodeCoverage]
public class TvAdded : MediaAdded
{
[JsonPropertyName("series")]
public required Series Series { get; set; }
}
+ [ExcludeFromCodeCoverage]
public class Series
{
[JsonPropertyName("id")]
diff --git a/src/Proxarr.Api/Program.cs b/src/Proxarr.Api/Program.cs
index 9936bd0..f8a8d72 100644
--- a/src/Proxarr.Api/Program.cs
+++ b/src/Proxarr.Api/Program.cs
@@ -1,6 +1,5 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http.Features;
-using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
using Polly;
using Proxarr.Api.Configuration;
@@ -12,6 +11,7 @@
using Serilog;
using Sonarr.Http.Client;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Net;
using TMDbLib.Client;
using TMDbLib.Objects.Exceptions;
@@ -155,4 +155,7 @@ Sonarr.Http.Client.ApiException e when (e.StatusCode == StatusCodes.Status404Not
});
-await app.RunAsync();
\ No newline at end of file
+await app.RunAsync();
+
+[ExcludeFromCodeCoverage]
+public partial class Program { }
\ No newline at end of file
diff --git a/src/Proxarr.Api/Services/RadarrService.cs b/src/Proxarr.Api/Services/RadarrService.cs
index 569d65f..7c18515 100644
--- a/src/Proxarr.Api/Services/RadarrService.cs
+++ b/src/Proxarr.Api/Services/RadarrService.cs
@@ -4,6 +4,7 @@
using Proxarr.Api.Core.Extensions;
using Proxarr.Api.Models;
using Radarr.Http.Client;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Proxarr.Api.Services
@@ -27,6 +28,7 @@ public RadarrService(ILogger logger,
}
//
+ [ExcludeFromCodeCoverage(Justification ="Is tested with Qualify function")]
public async Task FullScan(CancellationToken cancellationToken)
{
foreach (var client in _appConfiguration.Clients.Where(x => x.IsRadarr))
@@ -95,7 +97,7 @@ private async Task UpdateTags(TMDbLib.Objects.Movies.Movie tmdbItem,
foreach (var provider in _appConfiguration.WatchProvidersDict)
{
- if (tmdbItem.WatchProviders.Results.TryGetValue(provider.Key, out var matchedProvider))
+ if (tmdbItem.WatchProviders?.Results.TryGetValue(provider.Key, out var matchedProvider) == true)
{
foreach (var pr in provider.Value)
{
@@ -105,14 +107,6 @@ private async Task UpdateTags(TMDbLib.Objects.Movies.Movie tmdbItem,
_logger.LogInformation("Matched Free/FlatRate provider {WatchProvider} for {Title}", pr, movieRadarr.Title);
matched |= await AddTag(movieRadarr, matched, existedTags, pr, cancellationToken).ConfigureAwait(false);
}
- if (matchedProvider.Buy?.Any(x => x.ProviderName.Equals(pr, StringComparison.OrdinalIgnoreCase)) == true)
- {
- _logger.LogInformation("Found buy provider {WatchProvider} for {Title}", pr, movieRadarr.Title);
- }
- if (matchedProvider.Rent?.Any(x => x.ProviderName.Equals(pr, StringComparison.OrdinalIgnoreCase)) == true)
- {
- _logger.LogInformation("Found rent provider {WatchProvider} for {Title}", pr, movieRadarr.Title);
- }
}
}
}
diff --git a/src/Proxarr.Api/Services/SonarrService.cs b/src/Proxarr.Api/Services/SonarrService.cs
index 3eb537e..df31cf8 100644
--- a/src/Proxarr.Api/Services/SonarrService.cs
+++ b/src/Proxarr.Api/Services/SonarrService.cs
@@ -4,6 +4,7 @@
using Proxarr.Api.Core.Extensions;
using Proxarr.Api.Models;
using Sonarr.Http.Client;
+using System.Diagnostics.CodeAnalysis;
using System.Globalization;
namespace Proxarr.Api.Services
@@ -27,6 +28,7 @@ public SonarrService(ILogger logger,
}
//
+ [ExcludeFromCodeCoverage(Justification ="Is tested with Qualify function")]
public async Task FullScan(CancellationToken cancellationToken)
{
foreach (var client in _appConfiguration.Clients.Where(x => x.IsSonarr))
@@ -95,7 +97,7 @@ private async Task UpdateTags(TMDbLib.Objects.TvShows.TvShow tmdbItem,
foreach (var provider in _appConfiguration.WatchProvidersDict)
{
- if (tmdbItem.WatchProviders.Results.TryGetValue(provider.Key, out var matchedProvider))
+ if (tmdbItem.WatchProviders?.Results.TryGetValue(provider.Key, out var matchedProvider) == true)
{
foreach (var pr in provider.Value)
{
@@ -105,14 +107,6 @@ private async Task UpdateTags(TMDbLib.Objects.TvShows.TvShow tmdbItem,
_logger.LogInformation("Matched Free/FlatRate provider {WatchProvider} for {Title}", pr, seriesSonarr.Title);
matched |= await AddTag(seriesSonarr, matched, existedTags, pr, cancellationToken).ConfigureAwait(false);
}
- if (matchedProvider.Buy?.Any(x => x.ProviderName.Equals(pr, StringComparison.OrdinalIgnoreCase)) == true)
- {
- _logger.LogInformation("Found buy provider {WatchProvider} for {Title}", pr, seriesSonarr.Title);
- }
- if (matchedProvider.Rent?.Any(x => x.ProviderName.Equals(pr, StringComparison.OrdinalIgnoreCase)) == true)
- {
- _logger.LogInformation("Found rent provider {WatchProvider} for {Title}", pr, seriesSonarr.Title);
- }
}
}
}