mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-28 19:49:02 +01:00
Update 'server.js'
This commit is contained in:
parent
4798d8fa04
commit
2f686f7f59
1 changed files with 14 additions and 5 deletions
19
server.js
19
server.js
|
@ -41,6 +41,8 @@ var sha384 = require("js-sha512").sha384;
|
||||||
var sha512_256 = require("js-sha512").sha512_256;
|
var sha512_256 = require("js-sha512").sha512_256;
|
||||||
var sha512_224 = require("js-sha512").sha512_224;
|
var sha512_224 = require("js-sha512").sha512_224;
|
||||||
|
|
||||||
|
const musicInfo = require("music-info");
|
||||||
|
|
||||||
var app = express();
|
var app = express();
|
||||||
app.engine("html", require("ejs").renderFile);
|
app.engine("html", require("ejs").renderFile);
|
||||||
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
|
||||||
|
@ -132,6 +134,7 @@ app.get("/watch", async function (req, res) {
|
||||||
var q = req.query.quality;
|
var q = req.query.quality;
|
||||||
|
|
||||||
const video = await fetch(config.tubeApi + `video?v=${v}`);
|
const video = await fetch(config.tubeApi + `video?v=${v}`);
|
||||||
|
|
||||||
var fetching = await fetcher(v);
|
var fetching = await fetcher(v);
|
||||||
|
|
||||||
const json = fetching.video.Player;
|
const json = fetching.video.Player;
|
||||||
|
@ -147,7 +150,7 @@ app.get("/watch", async function (req, res) {
|
||||||
|
|
||||||
// encryption
|
// encryption
|
||||||
const url_e = url + "?e=" + sha384(json.id) + sha384(json.Title) + sha384(json.Channel.id) + sha384(json.Channel.id) + "Piwik" + sha384(config.t_url);
|
const url_e = url + "?e=" + sha384(json.id) + sha384(json.Title) + sha384(json.Channel.id) + sha384(json.Channel.id) + "Piwik" + sha384(config.t_url);
|
||||||
|
|
||||||
// channel info
|
// channel info
|
||||||
const engagement = fetching.engagement;
|
const engagement = fetching.engagement;
|
||||||
const channel = await fetch(
|
const channel = await fetch(
|
||||||
|
@ -196,6 +199,8 @@ app.get("/music", async function (req, res) {
|
||||||
var r = req.query.r;
|
var r = req.query.r;
|
||||||
var f = req.query.f;
|
var f = req.query.f;
|
||||||
var t = req.query.t;
|
var t = req.query.t;
|
||||||
|
|
||||||
|
if (!v) res.redirect("/");
|
||||||
|
|
||||||
const video = await fetch(config.tubeApi + `video?v=${v}`);
|
const video = await fetch(config.tubeApi + `video?v=${v}`);
|
||||||
var fetching = await fetcher(v);
|
var fetching = await fetcher(v);
|
||||||
|
@ -203,11 +208,11 @@ app.get("/music", async function (req, res) {
|
||||||
const json = fetching.video.Player;
|
const json = fetching.video.Player;
|
||||||
const h = await video.text();
|
const h = await video.text();
|
||||||
const k = JSON.parse(toJson(h));
|
const k = JSON.parse(toJson(h));
|
||||||
if (!v) res.redirect("/");
|
|
||||||
|
|
||||||
if (!json.Channel.Name.endsWith(" - Topic")) {
|
if (!json.Channel.Name.endsWith(" - Topic")) {
|
||||||
res.redirect(`/watch?v=${v}`);
|
res.redirect(`/watch?v=${v}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
//video
|
//video
|
||||||
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`;
|
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`;
|
||||||
|
|
||||||
|
@ -223,10 +228,14 @@ app.get("/music", async function (req, res) {
|
||||||
const tj = JSON.parse(toJson(c));
|
const tj = JSON.parse(toJson(c));
|
||||||
|
|
||||||
// lyrics
|
// lyrics
|
||||||
const lyrics = await lyricsFinder(json.Title);
|
const lyrics = await lyricsFinder(json.Title);
|
||||||
|
|
||||||
|
// info
|
||||||
|
const info = await musicInfo.searchSong({ title: json.Title, artist:json.Channel.Name.replace("- Topic", "")}, 1000)
|
||||||
|
|
||||||
renderTemplate(res, req, "poketube-music.ejs", {
|
renderTemplate(res, req, "poketube-music.ejs", {
|
||||||
url: url_e,
|
url: url_e,
|
||||||
|
info: info,
|
||||||
color: await getColors(
|
color: await getColors(
|
||||||
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
|
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
|
||||||
).then((colors) => colors[0].hex()),
|
).then((colors) => colors[0].hex()),
|
||||||
|
|
Loading…
Reference in a new issue