fix: copy stream url bug (#69)

This commit is contained in:
Technomancer702
2026-01-31 11:09:39 -08:00
parent 4e116d864b
commit 80d2c4bfb3
3 changed files with 47 additions and 27 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
"packages": {
"": {
"name": "nodecast-tv",
"version": "2.0.0",
"version": "2.1.4",
"license": "GPL-3.0-only",
"dependencies": {
"@ffprobe-installer/ffprobe": "^2.1.2",
+23 -13
View File
@@ -476,20 +476,30 @@ class VideoPlayer {
streamUrl = window.location.origin + streamUrl;
}
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('btn-copy-url');
if (btn) {
const originalText = btn.textContent;
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[Player] Stream URL copied:', streamUrl);
}).catch(() => {
const showPromptFallback = () => {
prompt('Copy this URL:', streamUrl);
});
};
// navigator.clipboard is only available in secure contexts (HTTPS/localhost)
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('btn-copy-url');
if (btn) {
const originalText = btn.textContent;
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[Player] Stream URL copied:', streamUrl);
}).catch(() => {
showPromptFallback();
});
} else {
// Fallback for insecure contexts (HTTP)
showPromptFallback();
}
}
+22 -12
View File
@@ -740,19 +740,29 @@ class WatchPage {
streamUrl = window.location.origin + streamUrl;
}
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('watch-copy-url');
if (btn) {
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[WatchPage] Stream URL copied:', streamUrl);
}).catch(() => {
const showPromptFallback = () => {
prompt('Copy this URL:', streamUrl);
});
};
// navigator.clipboard is only available in secure contexts (HTTPS/localhost)
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(streamUrl).then(() => {
// Show brief feedback
const btn = document.getElementById('watch-copy-url');
if (btn) {
btn.textContent = '✓ Copied!';
setTimeout(() => {
btn.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="icon"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg> Copy Stream URL`;
}, 1500);
}
console.log('[WatchPage] Stream URL copied:', streamUrl);
}).catch(() => {
showPromptFallback();
});
} else {
// Fallback for insecure contexts (HTTP)
showPromptFallback();
}
}
// === UI Updates ===