Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7cfae00511 | ||
|
|
cac920ae88 | ||
|
|
bab60771a4 | ||
|
|
828faae486 | ||
|
|
333a18ecd5 |
@@ -38,15 +38,15 @@ Einige Beispiele findet ihr unter Features.
|
|||||||
|
|
||||||
| Feature | Status |
|
| Feature | Status |
|
||||||
|-------------------------------------------------------------------|---------------|
|
|-------------------------------------------------------------------|---------------|
|
||||||
| Prowlarr Support | ✓|
|
| Prowlarr & NZB Hydra Support | ✓|
|
||||||
| Sonarr Support | ✓ |
|
| Sonarr Support | ✓ |
|
||||||
| Lidarr Support | ✓|
|
| Lidarr Support | ✓|
|
||||||
|
| Readarr Support | ✓ |
|
||||||
| Releases mit deutschem Titel werden erkannt | ✓ |
|
| Releases mit deutschem Titel werden erkannt | ✓ |
|
||||||
| Releases mit TVDB-Alias Titel werden erkannt | ✓ |
|
| Releases mit TVDB-Alias Titel werden erkannt | ✓ |
|
||||||
| Korrekte Suche und Erkennung von Titel mit Umlauten | ✓ |
|
| Korrekte Suche und Erkennung von Titel mit Umlauten | ✓ |
|
||||||
| Anfragen-Caching für 5 Minuten zur Reduzierung der API-Zugriffe | ✓ |
|
| Anfragen-Caching für 5 Minuten zur Reduzierung der API-Zugriffe | ✓ |
|
||||||
| Radarr Support | Geplant |
|
| Radarr Support | Geplant |
|
||||||
| Readarr Support | Geplant |
|
|
||||||
| Prowlarr Unterstützung für "DE" SceneNZBs Kategorien | Geplant |
|
| Prowlarr Unterstützung für "DE" SceneNZBs Kategorien | Geplant |
|
||||||
| Unterstützung weiterer Sprachen neben Deutsch | Geplant |
|
| Unterstützung weiterer Sprachen neben Deutsch | Geplant |
|
||||||
| Wünsche? | Vorschläge? |
|
| Wünsche? | Vorschläge? |
|
||||||
|
|||||||
@@ -185,7 +185,6 @@ namespace UmlautAdaptarr.Controllers
|
|||||||
if (categories.Split(',').Any(category => READARR_CATEGORY_IDS.Contains(category)))
|
if (categories.Split(',').Any(category => READARR_CATEGORY_IDS.Contains(category)))
|
||||||
{
|
{
|
||||||
var mediaType = "book";
|
var mediaType = "book";
|
||||||
// TODO rename function or use own
|
|
||||||
searchItem = await searchItemLookupService.GetOrFetchSearchItemByExternalId(mediaType, title.GetReadarrTitleForExternalId());
|
searchItem = await searchItemLookupService.GetOrFetchSearchItemByExternalId(mediaType, title.GetReadarrTitleForExternalId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ namespace UmlautAdaptarr.Providers
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var sonarrUrl = $"{_sonarrHost}/api/v3/series?includeSeasonImages=false&apikey={_sonarrApiKey}";
|
var sonarrUrl = $"{_sonarrHost}/api/v3/series?includeSeasonImages=false&apikey={_sonarrApiKey}";
|
||||||
logger.LogInformation($"Fetching all items from Sonarr: {UrlUtilities.RedactApiKey(sonarrUrl)}");
|
logger.LogInformation($"Fetching all items from Sonarr: {UrlUtilities.RedactApiKey(sonarrUrl)}");
|
||||||
var response = await httpClient.GetStringAsync(sonarrUrl);
|
var response = await httpClient.GetStringAsync(sonarrUrl);
|
||||||
|
|||||||
@@ -20,6 +20,20 @@ namespace UmlautAdaptarr.Services
|
|||||||
_cache = cache;
|
_cache = cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static async Task EnsureMinimumDelayAsync(string targetUri)
|
||||||
|
{
|
||||||
|
var host = new Uri(targetUri).Host;
|
||||||
|
if (_lastRequestTimes.TryGetValue(host, out var lastRequestTime))
|
||||||
|
{
|
||||||
|
var timeSinceLastRequest = DateTimeOffset.Now - lastRequestTime;
|
||||||
|
if (timeSinceLastRequest < TimeSpan.FromMilliseconds(1500))
|
||||||
|
{
|
||||||
|
await Task.Delay(TimeSpan.FromMilliseconds(1500) - timeSinceLastRequest);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_lastRequestTimes[host] = DateTimeOffset.Now;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<HttpResponseMessage> ProxyRequestAsync(HttpContext context, string targetUri)
|
public async Task<HttpResponseMessage> ProxyRequestAsync(HttpContext context, string targetUri)
|
||||||
{
|
{
|
||||||
if (!HttpMethods.IsGet(context.Request.Method))
|
if (!HttpMethods.IsGet(context.Request.Method))
|
||||||
@@ -27,18 +41,6 @@ namespace UmlautAdaptarr.Services
|
|||||||
throw new ArgumentException("Only GET requests are supported", context.Request.Method);
|
throw new ArgumentException("Only GET requests are supported", context.Request.Method);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Throttling mechanism
|
|
||||||
var host = new Uri(targetUri).Host;
|
|
||||||
if (_lastRequestTimes.TryGetValue(host, out var lastRequestTime))
|
|
||||||
{
|
|
||||||
var timeSinceLastRequest = DateTimeOffset.Now - lastRequestTime;
|
|
||||||
if (timeSinceLastRequest < TimeSpan.FromSeconds(3))
|
|
||||||
{
|
|
||||||
await Task.Delay(TimeSpan.FromSeconds(3) - timeSinceLastRequest);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_lastRequestTimes[host] = DateTimeOffset.Now;
|
|
||||||
|
|
||||||
// Check cache
|
// Check cache
|
||||||
if (_cache.TryGetValue(targetUri, out HttpResponseMessage cachedResponse))
|
if (_cache.TryGetValue(targetUri, out HttpResponseMessage cachedResponse))
|
||||||
{
|
{
|
||||||
@@ -46,6 +48,8 @@ namespace UmlautAdaptarr.Services
|
|||||||
return cachedResponse!;
|
return cachedResponse!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await EnsureMinimumDelayAsync(targetUri);
|
||||||
|
|
||||||
var requestMessage = new HttpRequestMessage
|
var requestMessage = new HttpRequestMessage
|
||||||
{
|
{
|
||||||
RequestUri = new Uri(targetUri),
|
RequestUri = new Uri(targetUri),
|
||||||
|
|||||||
@@ -35,12 +35,14 @@ namespace UmlautAdaptarr.Services
|
|||||||
if (_lidarrEnabled)
|
if (_lidarrEnabled)
|
||||||
{
|
{
|
||||||
fetchedItem = await lidarrClient.FetchItemByExternalIdAsync(externalId);
|
fetchedItem = await lidarrClient.FetchItemByExternalIdAsync(externalId);
|
||||||
|
fetchedItem = cacheService.GetSearchItemByExternalId(mediaType, externalId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "book":
|
case "book":
|
||||||
if (_readarrEnabled)
|
if (_readarrEnabled)
|
||||||
{
|
{
|
||||||
fetchedItem = await readarrClient.FetchItemByExternalIdAsync(externalId);
|
await readarrClient.FetchItemByExternalIdAsync(externalId);
|
||||||
|
fetchedItem = cacheService.GetSearchItemByExternalId(mediaType, externalId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,13 +13,14 @@ namespace UmlautAdaptarr.Services
|
|||||||
private async Task EnsureMinimumDelayAsync()
|
private async Task EnsureMinimumDelayAsync()
|
||||||
{
|
{
|
||||||
var sinceLastRequest = DateTime.Now - lastRequestTime;
|
var sinceLastRequest = DateTime.Now - lastRequestTime;
|
||||||
if (sinceLastRequest < TimeSpan.FromSeconds(2))
|
if (sinceLastRequest < TimeSpan.FromSeconds(1))
|
||||||
{
|
{
|
||||||
await Task.Delay(TimeSpan.FromSeconds(2) - sinceLastRequest);
|
await Task.Delay(TimeSpan.FromSeconds(1) - sinceLastRequest);
|
||||||
}
|
}
|
||||||
lastRequestTime = DateTime.Now;
|
lastRequestTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add cache, TODO add bulk request
|
||||||
public async Task<(string? germanTitle, string[]? aliases)> FetchGermanTitleAndAliasesByExternalIdAsync(string mediaType, string externalId)
|
public async Task<(string? germanTitle, string[]? aliases)> FetchGermanTitleAndAliasesByExternalIdAsync(string mediaType, string externalId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user