From 5698d435a710a6a5e1ce70c88685beaaa59aab98 Mon Sep 17 00:00:00 2001 From: Ashley Date: Fri, 25 Mar 2022 20:46:07 +0300 Subject: [PATCH] Create search.js --- sdk/src/search.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 sdk/src/search.js diff --git a/sdk/src/search.js b/sdk/src/search.js new file mode 100644 index 00000000..060d9c2e --- /dev/null +++ b/sdk/src/search.js @@ -0,0 +1,17 @@ +const fetch = require("node-fetch"); +const xmltojson = require("xml2json") +const url = require("../config.json") + +class Search{ + static async SearchVideo(query){ + const search = await fetch(`https://lighttube.herokuapp.com/api/search?query=${query}`) + const text = await search.text() + const j = JSON.parse(xmltojson.toJson(text)); + for (item of j.Search.Results.Video) { + const videoid = item; + return item; + } + } +} + +module.exports = Search