Throw on invalid data

This commit is contained in:
Chocobozzz 2020-06-08 15:50:20 +02:00
parent a9d49c41ee
commit 8d2fd71f61
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 4 additions and 0 deletions

View File

@ -41,6 +41,10 @@ async function getVideos (host: string, start: number): Promise<IndexableVideo[]
json: true
}, REQUESTS.MAX_RETRIES, REQUESTS.WAIT)
if (!res.body || !Array.isArray(res.body.data)) {
throw new Error('Invalid video data from ' + url)
}
return res.body.data.map(v => prepareVideoForDB(v, host))
}