Skip to content

armgit / my-yt

Public Imported from GitHub
0

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

JavaScript

fix: handle error when fail to fetch videos

Christian Feie51223b85a86
diff --git a/lib/update-videos.js b/lib/update-videos.js
index a683c0a..661cd16 100644
--- a/lib/update-videos.js
+++ b/lib/update-videos.js
@@ -12,9 +12,9 @@ export async function updateAndPersistVideosForChannel (name, repo, callback = (
if (Array.isArray(videos)) {
videos = videos.map(v => repo.patchVideo(v))
repo.upsertVideos(videos)
- callback(null, { name, videos }) // eslint-disable-line
+ callback(null, { name, videos })
} else {
- callback(new Error('No videos found'), null)
+ callback(new Error(`Failed to fetch videos for channel "${name}"`))
}
return videos
}
diff --git a/server/http.js b/server/http.js
index 6935828..8d21c5a 100644
--- a/server/http.js
+++ b/server/http.js
@@ -33,11 +33,12 @@ export function createServer (repo = new Repository()) {
setInterval(runUpdateVideos, 1000 * 60 * 30, repo, connections)
function runUpdateVideos (repo, connections) {
console.log('update videos')
- updateAndPersistVideos(repo, (err, { name, videos }) => {
+ updateAndPersistVideos(repo, (err, data) => {
if (err) {
- console.error('Error updating videos', name, err.message)
+ console.error(err)
return
}
+ const { name, videos } = data
const newVideos = videos
.filter(v => v.addedAt > lastAdded)
.filter(v => repo.filterByExcludedTerms(v))