mirror of
https://codeberg.org/ashley/poke.git
synced 2024-12-01 07:37:24 +01:00
Create search.js
This commit is contained in:
parent
5d27724f34
commit
5698d435a7
1 changed files with 17 additions and 0 deletions
17
sdk/src/search.js
Normal file
17
sdk/src/search.js
Normal 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
|
Loading…
Reference in a new issue