mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-03-14 23:07:30 +00:00
Merge pull request #71 from PR0M3TH3AN/codex/fix-data-attributes-for-url-and-magnet
Fix playback dataset handling for raw magnets
This commit is contained in:
@@ -984,7 +984,7 @@ class bitvidApp {
|
||||
|
||||
const handler = async (event) => {
|
||||
const trigger = event.target.closest(
|
||||
"[data-play-url], [data-play-magnet]"
|
||||
"[data-play-magnet],[data-play-url]"
|
||||
);
|
||||
if (!trigger) {
|
||||
return;
|
||||
@@ -1012,13 +1012,13 @@ class bitvidApp {
|
||||
}
|
||||
}
|
||||
|
||||
const magnet = safeDecodeMagnet(rawMagnetValue) || rawMagnetValue;
|
||||
const magnet = typeof rawMagnetValue === "string" ? rawMagnetValue : "";
|
||||
const eventId = trigger.getAttribute("data-video-id");
|
||||
|
||||
if (eventId) {
|
||||
await this.playVideoByEventId(eventId);
|
||||
} else {
|
||||
await this.playVideoWithoutEvent({ url, magnet });
|
||||
await this.playVideoWithFallback({ url, magnet });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -338,15 +338,14 @@ async function loadUserVideos(pubkey) {
|
||||
"duration-300"
|
||||
);
|
||||
|
||||
const trimmedMagnet =
|
||||
typeof video.magnet === "string" ? video.magnet.trim() : "";
|
||||
const rawMagnet =
|
||||
typeof video.magnet === "string" ? video.magnet : "";
|
||||
const legacyInfoHash =
|
||||
typeof video.infoHash === "string" ? video.infoHash.trim() : "";
|
||||
const magnetCandidate = trimmedMagnet || legacyInfoHash;
|
||||
const playbackUrl =
|
||||
typeof video.url === "string" ? video.url : "";
|
||||
const trimmedUrl = playbackUrl ? playbackUrl.trim() : "";
|
||||
const playbackMagnet = magnetCandidate || "";
|
||||
const playbackMagnet = rawMagnet || legacyInfoHash || "";
|
||||
const urlStatusHtml = trimmedUrl
|
||||
? app.getUrlHealthPlaceholderMarkup()
|
||||
: "";
|
||||
@@ -396,7 +395,13 @@ async function loadUserVideos(pubkey) {
|
||||
const interactiveEls = cardEl.querySelectorAll("[data-video-id]");
|
||||
interactiveEls.forEach((el) => {
|
||||
if (!el.dataset) return;
|
||||
el.dataset.playUrl = encodeURIComponent(playbackUrl || "");
|
||||
|
||||
if (trimmedUrl) {
|
||||
el.dataset.playUrl = encodeURIComponent(trimmedUrl);
|
||||
} else {
|
||||
delete el.dataset.playUrl;
|
||||
}
|
||||
|
||||
el.dataset.playMagnet = playbackMagnet || "";
|
||||
});
|
||||
|
||||
|
||||
@@ -419,7 +419,13 @@ class SubscriptionsManager {
|
||||
const interactiveEls = cardEl.querySelectorAll("[data-video-id]");
|
||||
interactiveEls.forEach((el) => {
|
||||
if (!el.dataset) return;
|
||||
el.dataset.playUrl = encodeURIComponent(playbackUrl || "");
|
||||
|
||||
if (trimmedUrl) {
|
||||
el.dataset.playUrl = encodeURIComponent(trimmedUrl);
|
||||
} else {
|
||||
delete el.dataset.playUrl;
|
||||
}
|
||||
|
||||
el.dataset.playMagnet = playbackMagnet || "";
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user