using System.ComponentModel.DataAnnotations;

public class TorrentInfo
{
    public string FileName { get; set; }
    public string AnnounceUrl { get; set; }
    public string ScrapeUrl { get; set; }
    public string InfoHash { get; set; }
    public byte[] InfoHashBytes { get; set; }
    public long Size { get; set; }
    public int Seeders { get; set; } = 0;
    public int Leechers { get; set; } = 0;
    public int Completed { get; set; } = 0;
    public bool HasTrackerData { get; set; } = false;
    public string ErrorMessage { get; set; }

}
public class TrackerInfo
{
    public string Name { get; set; }
    public bool SupportsScraping { get; set; }
    public bool RequiresAuth { get; set; }
    public bool IsPrivate { get; set; }
    public string Notes { get; set; }
}

public class TorrentUploadViewModel
{
    public IFormFile TorrentFile { get; set; }
    public TorrentInfo TorrentInfo { get; set; }
    public bool ShowResults { get; set; } = false;
}

public class RssFeed
{
    public int Id { get; set; }
    public string Url { get; set; }
    public string Name { get; set; }
    public DateTime LastChecked { get; set; }
    public bool IsActive { get; set; }
}
public class TorrentItem
{
    public int Id { get; set; }

    [Required]
    public string Title { get; set; } = string.Empty;

    public string? MagnetLink { get; set; }
    public string? InfoHash { get; set; }
    public DateTime PublishDate { get; set; }
    public long Size { get; set; } = 0;
    public int Seeders { get; set; } = 0;
    public int Leechers { get; set; } = 0;
    public int Completed { get; set; } = 0;
    public TorrentStatus Status { get; set; } = TorrentStatus.New;
    public string? Category { get; set; }
    public DateTime CreatedAt { get; set; } = DateTime.UtcNow;

    [Required]
    public string RssSource { get; set; } = string.Empty;

    public string Description { get; set; } = string.Empty;
    public string? TorrentUrl { get; set; }
    public string? MovieName { get; set; }
    public int? Year { get; set; }
    public string? DownloadKey { get; set; }
    public string? Token { get; set; }

    public MovieMetadata? Metadata { get; set; }
    public bool IsDownloaded { get; set; }

}

public class MovieMetadata
{
    public string Title { get; set; } = string.Empty; // required
    public string? Year { get; set; }
    public string? Poster { get; set; }
    public string? ImdbRating { get; set; }
    public string? Genre { get; set; }
    public string? Plot { get; set; }
    public string? Director { get; set; }
    public string? Actors { get; set; }
    public string? Runtime { get; set; }
    public string? ImdbID { get; set; }
    public string? Providers { get; set; }
}

public class TorrentListViewModel
{
    public List<TorrentListItemViewModel> Items { get; set; } = new();
    public int CurrentPage { get; set; }
    public int TotalPages { get; set; }
    public string CurrentSort { get; set; } = "date";
    public string CurrentRange { get; set; } = "all";
    public string CurrentPeriod { get; set; } = "all"; // day/week/month/all
}
public class TorrentListItemViewModel
{
    public string InfoHash { get; set; } = string.Empty;
    public string Title { get; set; } = string.Empty;
    public string MovieName { get; set; } = string.Empty;
    public DateTime PublishDate { get; set; }
    public int Seeders { get; set; }
    public int Leechers { get; set; }
    public string? TorrentUrl { get; set; }
    public MovieMetadata? Metadata { get; set; }
    public bool IsNew { get; set; } = false;
    public List<string> AvailableOn { get; set; } = new();
    public bool IsDownloaded { get; set; }
}
public class JustWatchResponse
{
    public Data data { get; set; }
}

public class Data
{
    public SearchTitles searchTitles { get; set; }
}

public class SearchTitles
{
    public List<Edge> edges { get; set; }
}

public class Edge
{
    public Node node { get; set; }
}

public class Node
{
    public string id { get; set; }
    public string title { get; set; }
    public int? releaseYear { get; set; }
    public Content content { get; set; }
    public List<Offer> offers { get; set; }
}

public class Content
{
    public string imdbId { get; set; }
}

public class Offer
{
    public Provider provider { get; set; }
    public string monetizationType { get; set; }  // FLATRATE, RENT, BUY
}

public class Provider
{
    public int id { get; set; }
    public string clearName { get; set; }
}

public enum TorrentStatus
{
    New,
    Downloaded,
    Processing,
    Completed,
    Failed,
    Ignored
}
public class DownloadRule
{
    public int Id { get; set; }
    public string KeywordFilter { get; set; }
    public string CategoryFilter { get; set; }
    public int MinSeeders { get; set; }
    public long MaxSize { get; set; }
    public bool AutoDownload { get; set; }
}

public class UserTorrentSeen
{
    public int Id { get; set; }
    public string UserId { get; set; } = null!;
    public string InfoHash { get; set; } = null!; // unikt för torrent
    public DateTime SeenDate { get; set; } = DateTime.UtcNow;
}