Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions listenarr.api/Controllers/ConfigurationController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using Listenarr.Domain.Models;
using Listenarr.Api.Services;
using Listenarr.Api.Hubs;
using Microsoft.AspNetCore.Mvc;
using System.Linq;
using System.Text.Json;
using Microsoft.AspNetCore.SignalR;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Controllers
{
Expand Down
3 changes: 1 addition & 2 deletions listenarr.api/Services/Adapters/DownloadClientUriBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down
5 changes: 1 addition & 4 deletions listenarr.api/Services/Adapters/IDownloadClientAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down
19 changes: 5 additions & 14 deletions listenarr.api/Services/Adapters/NzbgetAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Services;
using Listenarr.Domain.Models;
using Microsoft.Extensions.Logging;
using System.IO;
using System.Xml.Linq;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down Expand Up @@ -386,7 +377,7 @@ public async Task<List<QueueItem>> GetQueueAsync(DownloadClientConfiguration cli
var items = new List<QueueItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var category = client.GetCategory();

try
{
Expand All @@ -409,7 +400,7 @@ public async Task<List<QueueItem>> GetQueueAsync(DownloadClientConfiguration cli
.FirstOrDefault(m => string.Equals(m.Element("name")?.Value, "Category", StringComparison.Ordinal))?
.Element("value")?.Elements().FirstOrDefault()?.Value ?? string.Empty;

if (!DownloadClientCategoryFilter.Matches(configuredCategory, groupCategory))
if (!category.Matches(groupCategory))
{
continue;
}
Expand Down Expand Up @@ -488,7 +479,7 @@ public async Task<List<DownloadClientItem>> GetItemsAsync(DownloadClientConfigur
var items = new List<DownloadClientItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var category = client.GetCategory();

try
{
Expand All @@ -511,7 +502,7 @@ public async Task<List<DownloadClientItem>> GetItemsAsync(DownloadClientConfigur
.FirstOrDefault(m => string.Equals(m.Element("name")?.Value, "Category", StringComparison.Ordinal))?
.Element("value")?.Elements().FirstOrDefault()?.Value ?? string.Empty;

if (!DownloadClientCategoryFilter.Matches(configuredCategory, groupCategory))
if (!category.Matches(groupCategory))
{
continue;
}
Expand Down
11 changes: 1 addition & 10 deletions listenarr.api/Services/Adapters/QbittorrentAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Services;
using Listenarr.Domain.Models;
using Microsoft.Extensions.Logging;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down
20 changes: 6 additions & 14 deletions listenarr.api/Services/Adapters/SabnzbdAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Services;
using Listenarr.Domain.Models;
using Microsoft.Extensions.Logging;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down Expand Up @@ -293,7 +285,7 @@ public async Task<List<QueueItem>> GetQueueAsync(DownloadClientConfiguration cli
var items = new List<QueueItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var configuredCategory = client.GetCategory();

try
{
Expand Down Expand Up @@ -361,7 +353,7 @@ double ParseNumericValue(JsonElement element)
var timeLeft = slot.TryGetProperty("timeleft", out var time) ? time.GetString() ?? "0:00:00" : "0:00:00";
var category = slot.TryGetProperty("cat", out var cat) ? cat.GetString() ?? "" : "";

if (!DownloadClientCategoryFilter.Matches(configuredCategory, category))
if (!configuredCategory.Matches(category))
{
continue;
}
Expand Down Expand Up @@ -469,7 +461,7 @@ double ParseNumericValue(JsonElement element)
var histBytes = slot.TryGetProperty("bytes", out var hb) && hb.TryGetInt64(out var hbl) ? hbl : 0L;
var storagePath = slot.TryGetProperty("storage", out var sp) ? sp.GetString() ?? "" : "";

if (!DownloadClientCategoryFilter.Matches(configuredCategory, histCategory))
if (!configuredCategory.Matches(histCategory))
continue;

var mappedStatus = histStatus.ToLower() switch
Expand Down Expand Up @@ -586,7 +578,7 @@ public async Task<List<DownloadClientItem>> GetItemsAsync(DownloadClientConfigur
var items = new List<DownloadClientItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var configuredCategory = client.GetCategory();

try
{
Expand Down Expand Up @@ -657,7 +649,7 @@ double ParseNumericValue(JsonElement element)
var timeLeft = slot.TryGetProperty("timeleft", out var time) ? time.GetString() ?? "0:00:00" : "0:00:00";
var category = slot.TryGetProperty("cat", out var cat) ? cat.GetString() ?? "" : "";

if (!DownloadClientCategoryFilter.Matches(configuredCategory, category))
if (!configuredCategory.Matches(category))
{
continue;
}
Expand Down
19 changes: 5 additions & 14 deletions listenarr.api/Services/Adapters/TransmissionAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Services;
using Listenarr.Domain.Models;
using Microsoft.Extensions.Logging;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services.Adapters
{
Expand Down Expand Up @@ -316,7 +308,7 @@ public async Task<List<QueueItem>> GetQueueAsync(DownloadClientConfiguration cli
var items = new List<QueueItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var category = client.GetCategory();

// Use old format for compatibility with Transmission < 4.1.0
var payload = new
Expand Down Expand Up @@ -346,7 +338,7 @@ public async Task<List<QueueItem>> GetQueueAsync(DownloadClientConfiguration cli
try
{
var labels = ExtractLabels(torrent);
if (!DownloadClientCategoryFilter.MatchesAny(configuredCategory, labels))
if (!category.MatchesAny(labels))
{
continue;
}
Expand Down Expand Up @@ -380,7 +372,7 @@ public async Task<List<DownloadClientItem>> GetItemsAsync(DownloadClientConfigur
var items = new List<DownloadClientItem>();
if (client == null) return items;

var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
var category = client.GetCategory();

// Fetch session-level seed config for Sonarr-parity seed limit evaluation
bool sessionSeedRatioLimited = false;
Expand Down Expand Up @@ -433,8 +425,7 @@ public async Task<List<DownloadClientItem>> GetItemsAsync(DownloadClientConfigur
{
try
{
var labels = ExtractLabels(torrent);
if (!DownloadClientCategoryFilter.MatchesAny(configuredCategory, labels))
if (!category.MatchesAny(ExtractLabels(torrent)))
{
continue;
}
Expand Down
3 changes: 1 addition & 2 deletions listenarr.api/Services/ApiResponseRedactor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Linq;
using System.Text.Json;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services;

Expand Down
1 change: 1 addition & 0 deletions listenarr.api/Services/CompletedDownloadHandlingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using Listenarr.Domain.Models.Configurations;
using Listenarr.Infrastructure.Models;
using Microsoft.EntityFrameworkCore;

Expand Down
1 change: 1 addition & 0 deletions listenarr.api/Services/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

using System.Text.Json;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;
using Listenarr.Infrastructure.Models;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.EntityFrameworkCore;
Expand Down
43 changes: 0 additions & 43 deletions listenarr.api/Services/DownloadClientCategoryFilter.cs

This file was deleted.

7 changes: 1 addition & 6 deletions listenarr.api/Services/DownloadClientGateway.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Domain.Models;
using Listenarr.Api.Services.Adapters;
using Microsoft.Extensions.Logging;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services
{
Expand Down
8 changes: 1 addition & 7 deletions listenarr.api/Services/DownloadHashRetrievalService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Services.Adapters;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;
using Listenarr.Infrastructure.Repositories;
using Microsoft.Extensions.Logging;

namespace Listenarr.Api.Services
{
Expand Down
11 changes: 5 additions & 6 deletions listenarr.api/Services/DownloadMonitorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,11 @@
using System.Security.Principal;
using System.Runtime.InteropServices;
using Listenarr.Api.Hubs;
using Listenarr.Domain.Models;
using System.Text.Json;
using System.Text.Encodings.Web;
using Microsoft.Extensions.Caching.Memory;
using Listenarr.Application.Services;
using Listenarr.Api.Services.Adapters;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services
{
Expand Down Expand Up @@ -893,12 +892,12 @@ private Task PollQBittorrentAsync(
}
else
{
var configuredCategory = DownloadClientCategoryFilter.GetConfiguredCategory(client);
if (!string.IsNullOrWhiteSpace(configuredCategory))
var category = client.GetCategory();
if (!string.IsNullOrWhiteSpace(category.Value))
{
var cat = Uri.EscapeDataString(configuredCategory);
var cat = Uri.EscapeDataString(category.Value);
var query = $"?category={cat}&fields={Uri.EscapeDataString(fields)}";
_logger.LogDebug("Querying qBittorrent by category: {Category}", configuredCategory);
_logger.LogDebug("Querying qBittorrent by category: {Category}", category);

using var torrentsResp = await http.GetAsync($"{baseUrl}/api/v2/torrents/info{query}", cancellationToken);
if (!torrentsResp.IsSuccessStatusCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
*/

using System.Runtime.InteropServices;
using Listenarr.Domain.Models;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using Listenarr.Infrastructure.Models;
using Listenarr.Domain.Models.Configurations;

namespace Listenarr.Api.Services
{
Expand Down
8 changes: 1 addition & 7 deletions listenarr.api/Services/DownloadQueueService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.Json;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using Listenarr.Api.Repositories;
using Listenarr.Domain.Models;
using Listenarr.Domain.Models.Configurations;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Logging;

namespace Listenarr.Api.Services
{
Expand Down
Loading
Loading