Budget copy fix
This commit is contained in:
@@ -9,6 +9,10 @@
|
||||
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Views\Rss\_RssListPartial.cshtml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AngularJS.Core" Version="1.8.2" />
|
||||
<PackageReference Include="BencodeNET" Version="5.0.0" />
|
||||
|
||||
@@ -533,7 +533,7 @@ namespace Aberwyn.Controllers
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
[HttpPost("copy/{year:int}/{month:int}")]
|
||||
/*[HttpPost("copy/{year:int}/{month:int}")]
|
||||
public async Task<IActionResult> CopyFromPreviousMonth(int year, int month)
|
||||
{
|
||||
var targetPeriod = await _context.BudgetPeriods
|
||||
@@ -579,7 +579,7 @@ namespace Aberwyn.Controllers
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Aberwyn.Data;
|
||||
using BencodeNET.Torrents;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
@@ -106,20 +107,62 @@ public class RssController : Controller
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> Add(string torrentUrl)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await _deluge.LoginAsync("deluge1"))
|
||||
{
|
||||
var success = await _deluge.AddTorrentUrlAsync(torrentUrl);
|
||||
|
||||
if (success)
|
||||
{
|
||||
TempData["Message"] = "Torrent tillagd i Deluge!";
|
||||
return RedirectToAction("Index");
|
||||
// Hämta torrenten baserat på TorrentUrl
|
||||
var torrent = await _context.Set<TorrentItem>()
|
||||
.FirstOrDefaultAsync(t => t.TorrentUrl == torrentUrl);
|
||||
|
||||
if (torrent != null)
|
||||
{
|
||||
// Markera som nerladdad
|
||||
torrent.IsDownloaded = true;
|
||||
torrent.Status = TorrentStatus.Downloaded;
|
||||
_context.Update(torrent);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Skapa ny post om den inte finns
|
||||
var newTorrent = new TorrentItem
|
||||
{
|
||||
Title = torrentUrl, // byt till korrekt namnkälla om du har
|
||||
TorrentUrl = torrentUrl,
|
||||
PublishDate = DateTime.UtcNow,
|
||||
Status = TorrentStatus.Downloaded,
|
||||
IsDownloaded = true,
|
||||
RssSource = "Manuell", // eller sätt rätt källa
|
||||
};
|
||||
|
||||
_context.Add(newTorrent);
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
message = "Torrent tillagd i Deluge och markerad som nerladdad."
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
TempData["Error"] = "Misslyckades att lägga till torrent.";
|
||||
return RedirectToAction("Index");
|
||||
return Json(new { success = false, message = "Misslyckades att lägga till torrent i Deluge." });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Fel vid tillägg av torrent");
|
||||
return Json(new { success = false, message = "Ett fel uppstod vid tillägg av torrent." });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
|
||||
1365
Aberwyn/Migrations/20251027205014_AddTorrentItemTable.Designer.cs
generated
Normal file
1365
Aberwyn/Migrations/20251027205014_AddTorrentItemTable.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
Aberwyn/Migrations/20251027205014_AddTorrentItemTable.cs
Normal file
26
Aberwyn/Migrations/20251027205014_AddTorrentItemTable.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Aberwyn.Migrations
|
||||
{
|
||||
public partial class AddTorrentItemTable : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<bool>(
|
||||
name: "IsDownloaded",
|
||||
table: "TorrentItems",
|
||||
type: "tinyint(1)",
|
||||
nullable: false,
|
||||
defaultValue: false);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "IsDownloaded",
|
||||
table: "TorrentItems");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -986,6 +986,9 @@ namespace Aberwyn.Migrations
|
||||
b.Property<string>("InfoHash")
|
||||
.HasColumnType("varchar(255)");
|
||||
|
||||
b.Property<bool>("IsDownloaded")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<int>("Leechers")
|
||||
.HasColumnType("int");
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ public class TorrentItem
|
||||
public string? Token { get; set; }
|
||||
|
||||
public MovieMetadata? Metadata { get; set; }
|
||||
public bool IsDownloaded { get; set; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
118
Aberwyn/Views/Rss/_RssListPartial.cshtml
Normal file
118
Aberwyn/Views/Rss/_RssListPartial.cshtml
Normal file
@@ -0,0 +1,118 @@
|
||||
@model RssListViewModel
|
||||
|
||||
<div class="rss-list">
|
||||
<div class="rss-header">
|
||||
<div onclick="sortBy('title')" class="@(Model.CurrentSort == "title" ? "active" : "")">Titel</div>
|
||||
<div onclick="sortBy('date')" class="@(Model.CurrentSort == "date" ? "active" : "")">Tid / Datum</div>
|
||||
<div onclick="sortBy('seeders')" class="@(Model.CurrentSort == "seeders" ? "active" : "")">Seeders</div>
|
||||
<div onclick="sortBy('leechers')" class="@(Model.CurrentSort == "leechers" ? "active" : "")">Leechers</div>
|
||||
<div>Åtgärd</div>
|
||||
</div>
|
||||
|
||||
@foreach (var group in Model.Items
|
||||
.GroupBy(t => new { t.MovieName, t.Metadata?.Year })
|
||||
.Select(g => new
|
||||
{
|
||||
MovieName = g.Key.MovieName,
|
||||
Year = g.Key.Year,
|
||||
Versions = g.OrderByDescending(t => t.Title.Contains("Fix") || t.Title.Contains("Repack"))
|
||||
.ThenByDescending(t => t.Seeders)
|
||||
.ToList()
|
||||
}))
|
||||
{
|
||||
var main = group.Versions.First();
|
||||
var lastVersion = group.Versions.Last();
|
||||
|
||||
<!-- Huvudrad -->
|
||||
<div class="rss-row rss-group-title @(group.Versions.Count == 1 ? "last-row" : "")">
|
||||
<div class="col-title">
|
||||
@if (!string.IsNullOrEmpty(main.Metadata?.Poster) && main.Metadata.Poster != "N/A")
|
||||
{
|
||||
<a href="@main.Metadata.Poster" class="glightbox">
|
||||
<img src="@main.Metadata.Poster"
|
||||
alt="@main.MovieName"
|
||||
class="poster"
|
||||
onerror="this.onerror=null; this.src='/images/fallback.jpg';" />
|
||||
</a>
|
||||
}
|
||||
else
|
||||
{
|
||||
<img src="/images/fallback.jpg" alt="@main.MovieName" class="poster placeholder" />
|
||||
}
|
||||
|
||||
<div class="title-info">
|
||||
<strong>@(main.Metadata?.Title ?? group.MovieName) (@group.Year)</strong>
|
||||
|
||||
@if (main.IsNew)
|
||||
{
|
||||
<img src="/images/new.png" alt="New" class="badge" />
|
||||
}
|
||||
|
||||
<div class="meta">
|
||||
@if (!string.IsNullOrEmpty(main.Metadata?.Genre))
|
||||
{
|
||||
<span class="genre">@main.Metadata.Genre</span>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(main.Metadata?.ImdbID))
|
||||
{
|
||||
<a class="imdb" href="https://www.imdb.com/title/@main.Metadata.ImdbID" target="_blank">
|
||||
⭐ @main.Metadata.ImdbRating
|
||||
</a>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-date">
|
||||
<div class="time">@main.PublishDate.ToString("HH:mm")</div>
|
||||
<div class="date">@main.PublishDate.ToString("yyyy-MM-dd")</div>
|
||||
</div>
|
||||
<div class="col-center @(main.Seeders > 40 ? "highlight-green" : "")">@main.Seeders</div>
|
||||
<div class="col-center highlight-red">@main.Leechers</div>
|
||||
<div class="col-action">
|
||||
<form asp-controller="RSS" asp-action="Add" method="post" onsubmit="return confirmDownload('@main.Title')">
|
||||
<input type="hidden" name="rssUrl" value="@main.RssUrl" />
|
||||
<button type="submit" class="btn-add btn-small">➕ Lägg till</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Versioner -->
|
||||
@if (group.Versions.Count > 1)
|
||||
{
|
||||
foreach (var version in group.Versions.Skip(1))
|
||||
{
|
||||
var isLast = version == lastVersion;
|
||||
<div class="rss-row rss-version @(isLast ? "last-version" : "")" title="@version.Title">
|
||||
<div class="col-title">
|
||||
<strong>@version.Title</strong>
|
||||
</div>
|
||||
<div>@version.PublishDate.ToString("HH:mm yyyy-MM-dd")</div>
|
||||
<div class="@(version.Seeders > 40 ? "highlight-green" : "")">@version.Seeders</div>
|
||||
<div class="highlight-red">@version.Leechers</div>
|
||||
<div class="col-action">
|
||||
<form asp-controller="RSS" asp-action="Add" method="post" onsubmit="return confirmDownload('@version.Title')">
|
||||
<input type="hidden" name="rssUrl" value="@version.RssUrl" />
|
||||
<button type="submit" class="btn-add btn-small">➕</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
<!-- Pagination -->
|
||||
<div class="pagination">
|
||||
@for (int i = 1; i <= Model.TotalPages; i++)
|
||||
{
|
||||
if (i == Model.CurrentPage)
|
||||
{
|
||||
<span class="current">@i</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<a href="javascript:void(0)" onclick="loadRss('?page=@i')">@i</a>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user