From 1eac396f86324ec1c945f950922a64565b7da1b1 Mon Sep 17 00:00:00 2001 From: vidyagirl <67607376+vidyagirl@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:12:38 -0300 Subject: [PATCH] remove unnecesary require()s --- server.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/server.js b/server.js index 21f0d185..54ae5810 100644 --- a/server.js +++ b/server.js @@ -12,20 +12,18 @@ const renderTemplate = async (res, req, template, data = {}) => { ); }; -const ytSearch = require('youtube-search'); +const search = require('youtube-search'); const fetch = require('node-fetch'); app.get("/watch", function(req, res) { var url = req.query.v; var uu = `https://www.youtube.com/watch?v=${url}`; - var search = require("youtube-search"); var opts = { maxResults: 1, key: process.env.yt }; - - const fetch = require("node-fetch"); + search(uu, opts, function(err, results) { var i = results[0].id; fetch(`https://yt-proxy-api.herokuapp.com/get_player_info?v=${i}`) @@ -64,8 +62,7 @@ if(err) return app.get('/youtube/ara', async (req, res) => { - var url = req.query.query; - var search = require("youtube-search"); + var url = req.query.query; if (!req.query.query) { return res.redirect(`/`);