Skip to content

armgit / my-yt

Public Imported from GitHub
0

A clean and minimal youtube frontend, without all the ads and whistles

JavaScript

broadcast and rerender on summary-error

Christian Fei2eecc31cb5a0
diff --git a/client/main.js b/client/main.js
index 2a26654..db00e5d 100644
--- a/client/main.js
+++ b/client/main.js
@@ -55,6 +55,10 @@ eventSource.onmessage = (message) => {
// }
// })
}
+ if (data.type === 'summary-error' && data.videoId) {
+ const $videoElement = document.querySelector(`[data-video-id="${data.videoId}"]`)
+ $videoElement && $videoElement.render && $videoElement.render()
+ }
if (data.type === 'summary' && data.videoId && data.summary && data.transcript) {
;[...document.querySelectorAll(`[data-video-id="${data.videoId}"]`)].forEach($video => {
if (!$video.dataset['data']) return
diff --git a/lib/server.js b/lib/server.js
index 7c07a4b..ea5aa75 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -118,8 +118,10 @@ export function createServer ({repo, connections = []}) {
broadcastSSE(JSON.stringify({type: 'download-log-line', line}), connections))
.then(({summary, transcript}) =>
broadcastSSE(JSON.stringify({type: 'summary', summary, transcript, videoId: id}), connections))
- .catch((error) =>
- broadcastSSE(JSON.stringify({type: 'download-log-line', line: error.stderr}), connections))
+ .catch((error) => {
+ broadcastSSE(JSON.stringify({type: 'download-log-line', line: error.message}), connections)
+ broadcastSSE(JSON.stringify({type: 'summary-error', videoId: id}), connections)
+ })
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('Download started')