From 594afe76582bbff4386f346b9579a5e13b8a0865 Mon Sep 17 00:00:00 2001 From: Afsha10 Date: Tue, 19 Dec 2023 17:12:19 +0000 Subject: [PATCH] Create a shell script for getting the videos from the command line Create a shell script for getting the videos from the command line to create cron job so that we can have the database running daily --- get-videos | 3 +++ server/server.js | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100755 get-videos diff --git a/get-videos b/get-videos new file mode 100755 index 0000000000..4fa0620112 --- /dev/null +++ b/get-videos @@ -0,0 +1,3 @@ +#!/bin/bash + +curl https://video-storage.onrender.com/videos diff --git a/server/server.js b/server/server.js index be0466418b..f132daed77 100644 --- a/server/server.js +++ b/server/server.js @@ -79,7 +79,6 @@ app.post("/videos", (req, res) => { !url.startsWith("https://m.youtube.com") && !url.startsWith("https://youtube.com/")) ) { - res.status(400).json({ result: "failure", message: "Video could not be saved", @@ -88,7 +87,7 @@ app.post("/videos", (req, res) => { const query = `INSERT INTO videos (title, url, rating, createdAt) VALUES ($1, $2, 0, now());`; -// converting mobile YouTube links like this https://youtu.be/n3JNtfi4Vb0?si=dRx5CJJctB6P_yVR to this https://www.youtube.com/watch?v=n3JNtfi4Vb0 + // converting mobile YouTube links like this https://youtu.be/n3JNtfi4Vb0?si=dRx5CJJctB6P_yVR to this https://www.youtube.com/watch?v=n3JNtfi4Vb0 let formattedUrl; if (url.startsWith("https://youtu.be")) {