mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-15 09:19:01 -05:00
43 lines
1.2 KiB
C#
43 lines
1.2 KiB
C#
using Infrastructure.Helpers;
|
|
using Transmission.API.RPC.Entity;
|
|
|
|
namespace Infrastructure.Extensions;
|
|
|
|
public static class TransmissionExtensions
|
|
{
|
|
public static bool ShouldIgnore(this TorrentInfo download, IReadOnlyList<string> ignoredDownloads)
|
|
{
|
|
foreach (string value in ignoredDownloads)
|
|
{
|
|
if (download.HashString?.Equals(value, StringComparison.InvariantCultureIgnoreCase) ?? false)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (download.GetCategory().Equals(value, StringComparison.InvariantCultureIgnoreCase))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
bool? hasIgnoredTracker = download.Trackers?
|
|
.Any(x => UriService.GetDomain(x.Announce)?.EndsWith(value, StringComparison.InvariantCultureIgnoreCase) ?? false);
|
|
|
|
if (hasIgnoredTracker is true)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static string GetCategory(this TorrentInfo download)
|
|
{
|
|
if (string.IsNullOrEmpty(download.DownloadDir))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
return Path.GetFileName(Path.TrimEndingDirectorySeparator(download.DownloadDir));
|
|
}
|
|
} |