104 lines
3.6 KiB
C#
104 lines
3.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace TransmissionRssManager.Core
|
|
{
|
|
public class RssFeedItem
|
|
{
|
|
public string Id { get; set; }
|
|
public string Title { get; set; }
|
|
public string Link { get; set; }
|
|
public string Description { get; set; }
|
|
public DateTime PublishDate { get; set; }
|
|
public string TorrentUrl { get; set; }
|
|
public bool IsDownloaded { get; set; }
|
|
public bool IsMatched { get; set; }
|
|
public string MatchedRule { get; set; }
|
|
}
|
|
|
|
public class TorrentInfo
|
|
{
|
|
public int Id { get; set; }
|
|
public string Name { get; set; }
|
|
public string Status { get; set; }
|
|
public double PercentDone { get; set; }
|
|
public long TotalSize { get; set; }
|
|
public string DownloadDir { get; set; }
|
|
public bool IsFinished => PercentDone >= 1.0;
|
|
}
|
|
|
|
public class RssFeed
|
|
{
|
|
public string Id { get; set; }
|
|
public string Url { get; set; }
|
|
public string Name { get; set; }
|
|
public List<string> Rules { get; set; } = new List<string>();
|
|
public bool AutoDownload { get; set; }
|
|
public DateTime LastChecked { get; set; }
|
|
}
|
|
|
|
public class AppConfig
|
|
{
|
|
public TransmissionConfig Transmission { get; set; } = new TransmissionConfig();
|
|
public List<RssFeed> Feeds { get; set; } = new List<RssFeed>();
|
|
public bool AutoDownloadEnabled { get; set; }
|
|
public int CheckIntervalMinutes { get; set; } = 30;
|
|
public string DownloadDirectory { get; set; }
|
|
public string MediaLibraryPath { get; set; }
|
|
public PostProcessingConfig PostProcessing { get; set; } = new PostProcessingConfig();
|
|
}
|
|
|
|
public class TransmissionConfig
|
|
{
|
|
public string Host { get; set; } = "localhost";
|
|
public int Port { get; set; } = 9091;
|
|
public string Username { get; set; }
|
|
public string Password { get; set; }
|
|
public bool UseHttps { get; set; } = false;
|
|
public string Url => $"{(UseHttps ? "https" : "http")}://{Host}:{Port}/transmission/rpc";
|
|
}
|
|
|
|
public class PostProcessingConfig
|
|
{
|
|
public bool Enabled { get; set; } = false;
|
|
public bool ExtractArchives { get; set; } = true;
|
|
public bool OrganizeMedia { get; set; } = true;
|
|
public int MinimumSeedRatio { get; set; } = 1;
|
|
public List<string> MediaExtensions { get; set; } = new List<string> { ".mp4", ".mkv", ".avi" };
|
|
}
|
|
|
|
public interface IConfigService
|
|
{
|
|
AppConfig GetConfiguration();
|
|
Task SaveConfigurationAsync(AppConfig config);
|
|
}
|
|
|
|
public interface ITransmissionClient
|
|
{
|
|
Task<List<TorrentInfo>> GetTorrentsAsync();
|
|
Task<int> AddTorrentAsync(string torrentUrl, string downloadDir);
|
|
Task RemoveTorrentAsync(int id, bool deleteLocalData);
|
|
Task StartTorrentAsync(int id);
|
|
Task StopTorrentAsync(int id);
|
|
}
|
|
|
|
public interface IRssFeedManager
|
|
{
|
|
Task<List<RssFeedItem>> GetAllItemsAsync();
|
|
Task<List<RssFeedItem>> GetMatchedItemsAsync();
|
|
Task<List<RssFeed>> GetFeedsAsync();
|
|
Task AddFeedAsync(RssFeed feed);
|
|
Task RemoveFeedAsync(string feedId);
|
|
Task UpdateFeedAsync(RssFeed feed);
|
|
Task RefreshFeedsAsync(CancellationToken cancellationToken);
|
|
Task MarkItemAsDownloadedAsync(string itemId);
|
|
}
|
|
|
|
public interface IPostProcessor
|
|
{
|
|
Task ProcessCompletedDownloadsAsync(CancellationToken cancellationToken);
|
|
Task ProcessTorrentAsync(TorrentInfo torrent);
|
|
}
|
|
} |