Merge branch 'develop' into master

This commit is contained in:
Jonas F
2025-01-13 18:48:49 +01:00
committed by GitHub
7 changed files with 49 additions and 34 deletions

View File

@@ -13,7 +13,7 @@ namespace UmlautAdaptarr.Controllers
[HttpGet] [HttpGet]
public async Task<IActionResult> Caps([FromRoute] string options, [FromRoute] string domain, [FromQuery] string? apikey) public async Task<IActionResult> Caps([FromRoute] string options, [FromRoute] string domain, [FromQuery] string? apikey)
{ {
if (!UrlUtilities.IsValidDomain(domain)) if (!domain.StartsWith("localhost") && !UrlUtilities.IsValidDomain(domain))
{ {
return NotFound($"{domain} is not a valid URL."); return NotFound($"{domain} is not a valid URL.");
} }

View File

@@ -1,12 +1,13 @@
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System.Text; using System.Text;
using UmlautAdaptarr.Models; using UmlautAdaptarr.Models;
using UmlautAdaptarr.Providers;
using UmlautAdaptarr.Services; using UmlautAdaptarr.Services;
using UmlautAdaptarr.Utilities; using UmlautAdaptarr.Utilities;
namespace UmlautAdaptarr.Controllers namespace UmlautAdaptarr.Controllers
{ {
public abstract class SearchControllerBase(ProxyRequestService proxyRequestService, TitleMatchingService titleMatchingService) : ControllerBase public abstract class SearchControllerBase(ProxyRequestService proxyRequestService, TitleMatchingService titleMatchingService, ILogger<SearchControllerBase> logger) : ControllerBase
{ {
// TODO evaluate if this should be set to true by default // TODO evaluate if this should be set to true by default
private readonly bool TODO_FORCE_TEXT_SEARCH_ORIGINAL_TITLE = true; private readonly bool TODO_FORCE_TEXT_SEARCH_ORIGINAL_TITLE = true;
@@ -109,9 +110,17 @@ namespace UmlautAdaptarr.Controllers
private string ProcessContent(string content, SearchItem? searchItem) private string ProcessContent(string content, SearchItem? searchItem)
{
try
{ {
return titleMatchingService.RenameTitlesInContent(content, searchItem); return titleMatchingService.RenameTitlesInContent(content, searchItem);
} }
catch (Exception ex)
{
logger.LogError($"Error at ProcessContent: {ex.Message}{Environment.NewLine}Content:{Environment.NewLine}{content}");
}
return null;
}
public async Task<AggregatedSearchResult> AggregateSearchResults( public async Task<AggregatedSearchResult> AggregateSearchResults(
string domain, string domain,
@@ -154,7 +163,8 @@ namespace UmlautAdaptarr.Controllers
public class SearchController(ProxyRequestService proxyRequestService, public class SearchController(ProxyRequestService proxyRequestService,
TitleMatchingService titleMatchingService, TitleMatchingService titleMatchingService,
SearchItemLookupService searchItemLookupService) : SearchControllerBase(proxyRequestService, titleMatchingService) SearchItemLookupService searchItemLookupService,
ILogger<SearchControllerBase> logger) : SearchControllerBase(proxyRequestService, titleMatchingService, logger)
{ {
public readonly string[] LIDARR_CATEGORY_IDS = ["3000", "3010", "3020", "3040", "3050"]; public readonly string[] LIDARR_CATEGORY_IDS = ["3000", "3010", "3020", "3040", "3050"];
public readonly string[] READARR_CATEGORY_IDS = ["3030", "3130", "7000", "7010", "7020", "7030", "7100", "7110", "7120", "7130"]; public readonly string[] READARR_CATEGORY_IDS = ["3030", "3130", "7000", "7010", "7020", "7030", "7100", "7110", "7120", "7130"];

View File

@@ -52,7 +52,7 @@ namespace UmlautAdaptarr.Services.Factory
} }
catch (Exception e) catch (Exception e)
{ {
_logger.LogError("Error while Register ArrFactory. This might be a Config Problem", e.Message); _logger.LogError("Error while registering ArrFactory. This is most likely a config problem, please check your environment variables.", e.Message);
throw; throw;
} }
} }

View File

@@ -5,7 +5,8 @@ namespace UmlautAdaptarr.Utilities
{ {
public partial class UrlUtilities public partial class UrlUtilities
{ {
[GeneratedRegex(@"^(?!http:\/\/)([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+.*)$")] [GeneratedRegex(@"^(?!http:\/\/)([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+(:\d+)?(/.*)?)$")]
private static partial Regex UrlMatchingRegex(); private static partial Regex UrlMatchingRegex();
public static bool IsValidDomain(string domain) public static bool IsValidDomain(string domain)
{ {

View File

@@ -46,19 +46,23 @@ public class GlobalInstanceOptionsValidator : AbstractValidator<GlobalInstanceOp
try try
{ {
using var response = await httpClient.GetAsync(url, cancellationToken); using var response = await httpClient.GetAsync(url, cancellationToken);
reachable = response.StatusCode == HttpStatusCode.OK;
if (response.IsSuccessStatusCode) if (response.IsSuccessStatusCode)
{ {
reachable = true;
break; break;
} }
} else
catch
{ {
Console.WriteLine($"Reachable check got unexpected status code {response.StatusCode}.");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
} }
// Wait for 15 seconds for next try // Wait for 15 seconds for next try
Console.WriteLine($"The URL \"{opts.Host}\" is not reachable. Next attempt in 15 seconds..."); Console.WriteLine($"The URL \"{opts.Host}/api?apikey=[REDACTED]\" is not reachable. Next attempt in 15 seconds...");
Thread.Sleep(15000); Thread.Sleep(15000);
} }

View File

@@ -67,7 +67,7 @@
}, },
"IpLeakTest": { "IpLeakTest": {
// Docker Environment Variables: // Docker Environment Variables:
// - IpLeakTest: false (set to true to enable) // - IpLeakTest__Enabled: false (set to true to enable)
"Enabled": false "Enabled": false
} }
} }

View File

@@ -23,7 +23,7 @@ services:
- LIDARR__ENABLED=false - LIDARR__ENABLED=false
- LIDARR__HOST=http://localhost:8686 - LIDARR__HOST=http://localhost:8686
- LIDARR__APIKEY=APIKEY - LIDARR__APIKEY=APIKEY
#- IpLeakTest=false # uncomment and set to true to enable IP leak test #- IpLeakTest__Enabled=false # uncomment and set to true to enable IP leak test
### example for multiple instances of same type ### example for multiple instances of same type
#- SONARR__0__NAME=NAME 1 (optional) #- SONARR__0__NAME=NAME 1 (optional)
#- SONARR__0__ENABLED=false #- SONARR__0__ENABLED=false