Initial commit of auto-adding torrent system

This commit is contained in:
2026-10-11 12:25:32 -04:00
parent 57b2d8835d
commit 32aca8b197
9 changed files with 159 additions and 65 deletions
+12 -1
View File
@@ -35,7 +35,7 @@
<div class="airing-list">
@foreach (var show in Model.AiringShows)
{
<article class="airing-row @(show.IsFuture ? "is-upcoming" : "is-aired")">
<article id="show-@show.ShowID" class="airing-row @(show.IsFuture ? "is-upcoming" : "is-aired")">
@if (!string.IsNullOrWhiteSpace(show.HeroImageUrl))
{
<div class="airing-backdrop" style="background-image: url('@show.HeroImageUrl');" aria-hidden="true"></div>
@@ -169,6 +169,17 @@
{
<a href="@show.AnilistUrl" target="_blank" rel="noopener noreferrer" class="btn btn-sm btn-outline-info">AniList</a>
}
@if (show.Download)
{
<span class="btn btn-sm btn-success disabled" aria-disabled="true">✓ Marked for download</span>
}
else
{
<form method="post" asp-page-handler="Download" class="d-inline">
<input type="hidden" name="showId" value="@show.ShowID" />
<button type="submit" class="btn btn-sm btn-outline-success">⬇ Download</button>
</form>
}
@if (show.SecondaryImages.Count > 0)
{
+21
View File
@@ -1,6 +1,7 @@
using System.Net;
using System.Text.RegularExpressions;
using AnimeAnnouncer.Cache;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace AnimeAnnouncer.Web.Pages;
@@ -95,6 +96,25 @@ public class IndexModel : PageModel
}
}
public async Task<IActionResult> OnPostDownloadAsync(int showId)
{
if (_tmdbCache == null)
return StatusCode(StatusCodes.Status503ServiceUnavailable);
try
{
if (!await _tmdbCache.SetDownload(showId, true))
_logger.LogWarning("Download requested for show {ShowID}, which is not in the airing list", showId);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to flag show {ShowID} for download", showId);
}
// Post/redirect/get, landing back on the row that was clicked.
return RedirectToPage(null, null, null, $"show-{showId}");
}
public class ShowImage
{
public required string Url { get; set; }
@@ -112,6 +132,7 @@ public class IndexModel : PageModel
public string Title => AiringSoon.Title;
public int ShowID => AiringSoon.ShowID;
public bool Download => AiringSoon.Download;
public DateTime? EffectiveLastAirDate => AiringSoon.LastAirDate ?? CachedDetails?.LastAirDate;
public int LatestEpisodeNumber => AiringSoon.LatestEpisodeNumber > 0
? AiringSoon.LatestEpisodeNumber