Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

refactor: move exclude logic to update-videos

Christian Fei563452466ba1
diff --git a/lib/update-videos.js b/lib/update-videos.js
index 661cd16..b63fc48 100644
--- a/lib/update-videos.js
+++ b/lib/update-videos.js
@@ -12,6 +12,9 @@ export async function updateAndPersistVideosForChannel (name, repo, callback = (
if (Array.isArray(videos)) {
videos = videos.map(v => repo.patchVideo(v))
repo.upsertVideos(videos)
+ videos = videos
+ .filter(v => !v.ignored)
+ .filter(v => repo.filterByExcludedTerms(v))
callback(null, { name, videos })
} else {
callback(new Error(`Failed to fetch videos for channel "${name}"`))
diff --git a/server/http.js b/server/http.js
index c7b8bdd..aaad40d 100644
--- a/server/http.js
+++ b/server/http.js
@@ -39,10 +39,7 @@ export function createServer (repo = new Repository()) {
return
}
const { name, videos } = data
- const newVideos = videos
- .filter(v => !v.ignored)
- .filter(v => v.addedAt > lastAdded)
- .filter(v => repo.filterByExcludedTerms(v))
+ const newVideos = videos.filter(v => v.addedAt > lastAdded)
lastAdded = Date.now()
if (newVideos.length > 0) {
console.log('new videos for channel', name, newVideos.length)