mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 02:19:01 +01:00
new api url
lighttube.herokuapp.com --> tube.kuylar.dev
This commit is contained in:
parent
75e6339fee
commit
3ab72ec127
1 changed files with 22 additions and 36 deletions
|
@ -16,22 +16,24 @@
|
||||||
along with this program. If not, see https://www.gnu.org/licenses/.
|
along with this program. If not, see https://www.gnu.org/licenses/.
|
||||||
*/
|
*/
|
||||||
const fetch = require("node-fetch"); //2.5.x
|
const fetch = require("node-fetch"); //2.5.x
|
||||||
const { toJson } = require("xml2json")
|
const { toJson } = require("xml2json");
|
||||||
|
|
||||||
var youtube_url = `https://www.youtube.com/watch?v=`;
|
var youtube_url = `https://www.youtube.com/watch?v=`;
|
||||||
var dislike_api = `https://returnyoutubedislikeapi.com/votes?videoId=`
|
var dislike_api = `https://returnyoutubedislikeapi.com/votes?videoId=`;
|
||||||
var new_api_url = `https://lighttube.herokuapp.com/api/player`
|
var new_api_url = `https://tube.kuylar.dev/api/player`;
|
||||||
|
|
||||||
module.exports = async function (video_id) {
|
module.exports = async function (video_id) {
|
||||||
const dislike = await fetch(`${dislike_api}${video_id}`).then((res) => res.json());
|
const dislike = await fetch(`${dislike_api}${video_id}`).then((res) =>
|
||||||
const dislikes = dislike.dislikes || "none"
|
res.json()
|
||||||
|
);
|
||||||
|
const dislikes = dislike.dislikes || "none";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parses and fetches an xml
|
* Parses and fetches an xml
|
||||||
*/
|
*/
|
||||||
async function parsexml(id) {
|
async function parsexml(id) {
|
||||||
const player = await fetch(`${new_api_url}?v=${id}`)
|
const player = await fetch(`${new_api_url}?v=${id}`);
|
||||||
var h = await player.text()
|
var h = await player.text();
|
||||||
var j = toJson(h);
|
var j = toJson(h);
|
||||||
return JSON.parse(j);
|
return JSON.parse(j);
|
||||||
}
|
}
|
||||||
|
@ -41,23 +43,7 @@ const dislikes = dislike.dislikes || "none"
|
||||||
const returner = {
|
const returner = {
|
||||||
video: await parsexml(video_id),
|
video: await parsexml(video_id),
|
||||||
engagement: dislike,
|
engagement: dislike,
|
||||||
video_url_youtube:`${youtube_url}${video_id}`
|
video_url_youtube: `${youtube_url}${video_id}`,
|
||||||
}
|
};
|
||||||
return returner
|
return returner;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.searcher = async function searcher(query,res){
|
|
||||||
const search = await fetch(`https://lighttube.herokuapp.com/api/search?query=${query}`)
|
|
||||||
const text = await search.text()
|
|
||||||
const j = JSON.parse(toJson(text));
|
|
||||||
if(query.length > 2) {
|
|
||||||
for (item of j.Search.Results.Video) {
|
|
||||||
const videoid = item.id;
|
|
||||||
return res.redirect(`/watch?v=${videoid}`);
|
|
||||||
}
|
|
||||||
if(query.length < 2){
|
|
||||||
res.redirect("/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue