mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-27 02:38:13 +01:00
Update server.js
This commit is contained in:
parent
594dbdccaa
commit
7abf17e92b
1 changed files with 30 additions and 9 deletions
35
server.js
35
server.js
|
@ -12,6 +12,9 @@ const renderTemplate = async (res, req, template, data = {}) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const ytSearch = require('youtube-search');
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
app.get("/watch", function(req, res) {
|
app.get("/watch", function(req, res) {
|
||||||
var url = req.query.v;
|
var url = req.query.v;
|
||||||
var uu = `https://www.youtube.com/watch?v=${url}`;
|
var uu = `https://www.youtube.com/watch?v=${url}`;
|
||||||
|
@ -25,24 +28,42 @@ app.get("/watch", function(req, res) {
|
||||||
const fetch = require("node-fetch");
|
const fetch = require("node-fetch");
|
||||||
search(uu, opts, function(err, results) {
|
search(uu, opts, function(err, results) {
|
||||||
var i = results[0].id;
|
var i = results[0].id;
|
||||||
fetch(`https://poketalebot.com/api/ytdl/dowlands/fromurl/get/json?url=${i}`)
|
fetch(`https://yt-proxy-api.herokuapp.com/get_player_info?v=${i}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(json => {
|
.then(json => {
|
||||||
var video = results[0];
|
var video = results[0];
|
||||||
if (!video) return;
|
if (!video) return;
|
||||||
if (err) console.log(err);
|
if (err) console.log(err);
|
||||||
|
const tarih = json.upload_date
|
||||||
var h = json.url;
|
var h = json.formats[1].url;
|
||||||
renderTemplate(res, req, "youtube.ejs", { url: h, title: video });
|
renderTemplate(res, req, "youtube.ejs", { url: h, title: video,video:json,date:tarih });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/", function(req, res) {
|
app.get("/", function(req, res) {
|
||||||
renderTemplate(res, req, "ytmain.ejs");
|
var url = req.query.url;
|
||||||
|
var search = require("youtube-search");
|
||||||
|
|
||||||
|
if(url){
|
||||||
|
var opts = {
|
||||||
|
maxResults: 1,
|
||||||
|
key: process.env.yt
|
||||||
|
};
|
||||||
|
|
||||||
|
search(url, opts, function(err, results) {
|
||||||
|
var h = results[0].id;
|
||||||
|
var lmao = results[0];
|
||||||
|
if(err) return
|
||||||
|
res.redirect(`/watch?v=${h}&title=${lmao.title}&channel=${lmao.channelTitle}&searchquery=${url}&data=${mythe2}${mythe}${mythe3}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if(!url){
|
||||||
|
renderTemplate(res, req, "ytmain.ejs")
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/api/search", function(req, res) {
|
|
||||||
|
app.get('/youtube/ara', async (req, res) => {
|
||||||
var url = req.query.query;
|
var url = req.query.query;
|
||||||
var search = require("youtube-search");
|
var search = require("youtube-search");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue