mirror of
https://github.com/Cleanuparr/Cleanuparr.git
synced 2026-01-01 02:18:36 -05:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
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 => new Uri(x.Announce!).Host.EndsWith(value, StringComparison.InvariantCultureIgnoreCase));
|
|
|
|
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));
|
|
}
|
|
} |