Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

log new videos

Christian Fei9eae2bca2cd5
diff --git a/lib/server.js b/lib/server.js
index 6406486..ab97932 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -16,9 +16,12 @@ export function createServer ({repo, connections = []}) {
console.log('update videos')
updateAndPersistVideos(repo, ({name, videos}) => {
const newVideos = videos.filter(v => v.addedAt > lastAdded)
- broadcastSSE(JSON.stringify({type: 'new-videos', name, videos: newVideos}), connections)
+ if (newVideos.length > 0) {
+ console.log('new videos for channel', name, newVideos.length)
+ broadcastSSE(JSON.stringify({type: 'new-videos', name, videos: newVideos}), connections)
+ }
})
- }, 1000 * 60 * 1)
+ }, 1000 * 60 * 10)
return http.createServer(async (req, res) => {
const url = new URL(req.url, `http://${req.headers.host}`)