This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
<PackageReference Include="BencodeNET" Version="5.0.0" />
|
||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.67" />
|
||||
<PackageReference Include="Lib.Net.Http.WebPush" Version="3.3.1" />
|
||||
<PackageReference Include="MessagePack" Version="3.1.4" />
|
||||
|
||||
<!-- Entity Framework Core 6 -->
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.36" />
|
||||
@@ -43,7 +44,10 @@
|
||||
<!-- Övrigt -->
|
||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.15.1" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.18" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.9" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.12" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Text.Json" Version="10.0.2" />
|
||||
<PackageReference Include="System.Text.RegularExpressions" Version="4.3.1" />
|
||||
<PackageReference Include="WebPush" Version="1.0.12" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ public class RssController : Controller
|
||||
Leechers = t.Leechers,
|
||||
TorrentUrl = t.TorrentUrl,
|
||||
Metadata = t.Metadata,
|
||||
IsDownloaded = t.IsDownloaded,
|
||||
IsNew = t.InfoHash != null && !seenHashes.Contains(t.InfoHash),
|
||||
AvailableOn = !string.IsNullOrEmpty(t.Metadata?.Providers)
|
||||
? t.Metadata.Providers.Split(',').ToList()
|
||||
@@ -144,7 +145,7 @@ public class RssController : Controller
|
||||
}
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
_logger.LogInformation("SavedChanges to torrents");
|
||||
return Json(new
|
||||
{
|
||||
success = true,
|
||||
|
||||
@@ -56,7 +56,16 @@ namespace Aberwyn.Data
|
||||
var payload = new
|
||||
{
|
||||
method = "core.add_torrent_url",
|
||||
@params = new object[] { torrentUrl, new { } },
|
||||
@params = new object[]
|
||||
{
|
||||
torrentUrl,
|
||||
new
|
||||
{
|
||||
download_location = "/download/incomplete",
|
||||
move_completed = true,
|
||||
move_completed_path = "/media/Movies",
|
||||
}
|
||||
},
|
||||
id = 3
|
||||
};
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ public class TorrentListItemViewModel
|
||||
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
|
||||
{
|
||||
|
||||
@@ -92,10 +92,18 @@
|
||||
<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="torrentUrl" value="@main.TorrentUrl" />
|
||||
@if (main.IsDownloaded)
|
||||
{
|
||||
<span class="downloaded">✔ Nedladdad</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<form class="download-form"
|
||||
data-url="@Url.Action("Add", "Rss")"
|
||||
data-torrent="@main.TorrentUrl">
|
||||
<button type="submit" class="btn-add btn-small">➕ Ladda ner</button>
|
||||
</form>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -155,7 +163,67 @@
|
||||
url.searchParams.set('sort', field);
|
||||
window.location = url;
|
||||
}
|
||||
function confirmDownload(title) {
|
||||
return confirm(`Vill du ladda ner "${title}"?`);
|
||||
}
|
||||
|
||||
</script>
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
document.querySelectorAll(".download-form").forEach(form => {
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault(); // 🔥 STOPPAR ALL REFRESH – ALLTID
|
||||
|
||||
console.log("form:", form);
|
||||
const button = form.querySelector("button");
|
||||
console.log("button:", button);
|
||||
|
||||
const torrentUrl = form.dataset.torrent;
|
||||
const postUrl = form.dataset.url;
|
||||
|
||||
if (!torrentUrl || !postUrl) {
|
||||
console.error("Saknar data-attribut");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!confirm("Vill du ladda ner denna torrent?"))
|
||||
return;
|
||||
|
||||
if (button) {
|
||||
button.disabled = true;
|
||||
button.innerText = "⏳ Laddar...";
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(postUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: new URLSearchParams({ torrentUrl })
|
||||
});
|
||||
|
||||
const text = await response.text();
|
||||
console.log("Raw response:", text);
|
||||
|
||||
const result = JSON.parse(text);
|
||||
|
||||
if (result.success) {
|
||||
form.innerHTML = `<span class="downloaded">✔ Tillagd</span>`;
|
||||
} else {
|
||||
throw new Error(result.message || "Misslyckades");
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
console.error("JS error:", err);
|
||||
|
||||
if (button) {
|
||||
button.disabled = false;
|
||||
button.innerText = "➕ Ladda ner";
|
||||
}
|
||||
|
||||
alert("Ett fel uppstod");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ const urlsToCache = [
|
||||
'/',
|
||||
'/css/site.css',
|
||||
'/images/lewel-icon.png',
|
||||
'/manifest.json'
|
||||
'/manifest-v2.json'
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
@@ -14,7 +14,7 @@ self.addEventListener('install', event => {
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", function (event) {
|
||||
/*self.addEventListener("fetch", function (event) {
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
// Hoppa över root / om du inte vill cachea den
|
||||
@@ -28,8 +28,29 @@ self.addEventListener("fetch", function (event) {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});*/
|
||||
|
||||
self.addEventListener("fetch", event => {
|
||||
// 🔴 Ignorera allt som inte är GET (POST, PUT, DELETE etc)
|
||||
if (event.request.method !== "GET") {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
// Hoppa över root om du vill
|
||||
if (url.pathname === "/") {
|
||||
return;
|
||||
}
|
||||
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(response => {
|
||||
return response || fetch(event.request);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
self.addEventListener('push', function (event) {
|
||||
console.log("📨 Push event mottagen!", event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user