diff --git a/src/vimeo-scripts/getAllVideosFromFolder.ts b/src/vimeo-scripts/getAllVideosFromFolder.ts index c190a9c..30afda1 100644 --- a/src/vimeo-scripts/getAllVideosFromFolder.ts +++ b/src/vimeo-scripts/getAllVideosFromFolder.ts @@ -66,24 +66,23 @@ export async function getSQLfromVideos() { .then(async (response) => { for (const video of response.data.data) { if (!isNaN(video.name)) { - let index = Number(video.name) - 1; - results[index]['video_url'] = video.link.replace( - 'https://vimeo.com/', - 'https://player.vimeo.com/video/' - ); - results[index]['duration_in_seconds'] = video.duration; - - const res = await axios.post( - 'https://api.codante.io/api/get-unused-slug', - { - lesson_name: results[index].name, - } - ); - - results[index]['slug'] = res.data.slug; + let index = Number(video.name) - 1; + if(index !== -1) { + results[index]['video_url'] = video.link.replace( + 'https://vimeo.com/', + 'https://player.vimeo.com/video/' + ); + results[index]['duration_in_seconds'] = video.duration; + const res = await axios.post( + 'https://api.codante.io/api/get-unused-slug', + { + lesson_name: results[index].name, + } + ); + results[index]['slug'] = res.data.slug; + } } } - generateSQL(); }) .catch((error) => {