Create search.js

This commit is contained in:
Ashley 2022-03-25 20:46:07 +03:00 committed by GitHub
parent 5ba735766d
commit 68535a7321

17
sdk/src/search.js Normal file
View file

@ -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