A clean and minimal youtube frontend, without all the ads and whistles
JavaScript
feat: include err when updating and persisting videos
Christian Fei058ebb004a03
diff --git a/lib/update-videos.js b/lib/update-videos.jsindex bf8b692..a683c0a 100644--- a/lib/update-videos.js+++ b/lib/update-videos.js@@ -9,10 +9,12 @@ export async function updateAndPersistVideos (repo, callback = () => {}) {export async function updateAndPersistVideosForChannel (name, repo, callback = () => {}) {let videos = await getVideosFor(name)- if (videos) {+ if (Array.isArray(videos)) {videos = videos.map(v => repo.patchVideo(v))repo.upsertVideos(videos)- callback({ name, videos }) // eslint-disable-line+ callback(null, { name, videos }) // eslint-disable-line+ } else {+ callback(new Error('No videos found'), null)}return videos}diff --git a/server/http.js b/server/http.jsindex f58296a..6935828 100644--- a/server/http.js+++ b/server/http.js@@ -33,7 +33,11 @@ export function createServer (repo = new Repository()) {setInterval(runUpdateVideos, 1000 * 60 * 30, repo, connections)function runUpdateVideos (repo, connections) {console.log('update videos')- updateAndPersistVideos(repo, ({ name, videos }) => {+ updateAndPersistVideos(repo, (err, { name, videos }) => {+ if (err) {+ console.error('Error updating videos', name, err.message)+ return+ }const newVideos = videos.filter(v => v.addedAt > lastAdded).filter(v => repo.filterByExcludedTerms(v))