music owo

This commit is contained in:
Ashley 2022-08-16 18:32:45 +02:00
parent 96908b3701
commit 3296caae1a

150
server.js
View file

@ -34,15 +34,14 @@ const templateDir = path.resolve(`${process.cwd()}${path.sep}html`);
var express = require("express");
var useragent = require("express-useragent");
// hash
var sha512 = require('js-sha512').sha512;
var sha384 = require('js-sha512').sha384;
var sha512 = require("js-sha512").sha512;
var sha384 = require("js-sha512").sha384;
var sha512_256 = require('js-sha512').sha512_256;
var sha512_224 = require('js-sha512').sha512_224;
var sha512_256 = require("js-sha512").sha512_256;
var sha512_224 = require("js-sha512").sha512_224;
var app = express();
var app = express();
app.engine("html", require("ejs").renderFile);
app.use(express.urlencoded({ extended: true })); // for parsing application/x-www-form-urlencoded
app.use(useragent.express());
@ -79,7 +78,6 @@ const config = {
// pages
app.get("/encryption", async function (req, res) {
var v = req.query.v;
const video = await fetch(config.tubeApi + `video?v=${v}`);
@ -98,23 +96,22 @@ app.get("/encryption", async function (req, res) {
// json response
const re = {
main:{
video_id:sha384(json.id),
channel:sha384(json.Channel.Name),
title:sha384(json.Title),
date:sha384(btoa(Date.now()).toString())
main: {
video_id: sha384(json.id),
channel: sha384(json.Channel.Name),
title: sha384(json.Title),
date: sha384(btoa(Date.now()).toString()),
},
info:{
desc:sha384(json.Description)
info: {
desc: sha384(json.Description),
},
video:{
title:sha384(json.Title),
url:sha384(url)
}
}
res.json(re)
video: {
title: sha384(json.Title),
url: sha384(url),
},
};
res.json(re);
});
app.get("/watch", async function (req, res) {
@ -134,7 +131,6 @@ app.get("/watch", async function (req, res) {
var t = req.query.t;
var q = req.query.quality;
const video = await fetch(config.tubeApi + `video?v=${v}`);
var fetching = await fetcher(v);
@ -144,39 +140,105 @@ app.get("/watch", async function (req, res) {
if (!v) res.redirect("/");
//video
if(!q) url = `https://tube.kuylar.dev/proxy/media/${v}/22`
if(q === "medium") {
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`
if (!q) url = `https://tube.kuylar.dev/proxy/media/${v}/22`;
if (q === "medium") {
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`;
}
// 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
const engagement = fetching.engagement;
const channel = await fetch(config.tubeApi + `channel?id=${json.Channel.id}&tab=videos`);
const channel = await fetch(
config.tubeApi + `channel?id=${json.Channel.id}&tab=videos`
);
const c = await channel.text();
const tj = JSON.parse(toJson(c));
// lyrics
const lyrics = await lyricsFinder(json.Title);
renderTemplate(res, req, "poketube.ejs", {
url: url_e,
color: await getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`).then((colors) => colors[0].hex()),
color: await getColors(
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
).then((colors) => colors[0].hex()),
engagement: engagement,
video: json,
date: moment(k.Video.uploadDate).format("LL"),
e: e,
k: k,
sha384:sha384,
isMobile:req.useragent.isMobile,
sha384: sha384,
isMobile: req.useragent.isMobile,
tj: tj,
r: r,
qua: q,
f: f,
t: config.t_url,
optout: t,
lyrics: lyrics.replace(/\n/g, " <br> "),
});
});
app.get("/music", async function (req, res) {
/*
* QUERYS
* v = Video ID
* e = Embed
* r = Recommended videos
* f = Recent videos from channel
* t = Piwik OptOut
* q = quality obv
*/
var v = req.query.v;
var e = req.query.e;
var r = req.query.r;
var f = req.query.f;
var t = req.query.t;
const video = await fetch(config.tubeApi + `video?v=${v}`);
var fetching = await fetcher(v);
const json = fetching.video.Player;
const h = await video.text();
const k = JSON.parse(toJson(h));
if (!v) res.redirect("/");
if (!json.Channel.Name.endsWith(" - Topic")) {
res.redirect(`/watch?v=${v}`);
}
//video
var url = `https://tube.kuylar.dev/proxy/media/${v}/18`;
// 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);
// channel info
const engagement = fetching.engagement;
const channel = await fetch(
config.tubeApi + `channel?id=${json.Channel.id}&tab=videos`
);
const c = await channel.text();
const tj = JSON.parse(toJson(c));
// lyrics
const lyrics = await lyricsFinder(json.Title);
renderTemplate(res, req, "poketube-music.ejs", {
url: url_e,
color: await getColors(
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
).then((colors) => colors[0].hex()),
engagement: engagement,
video: json,
date: moment(k.Video.uploadDate).format("LL"),
e: e,
k: k,
sha384: sha384,
isMobile: req.useragent.isMobile,
tj: tj,
r: r,
qua:q,
f: f,
t: config.t_url,
optout: t,
@ -209,7 +271,9 @@ app.get("/download", async function (req, res) {
k: k,
video: json,
date: k.Video.uploadDate,
color: await getColors(`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`).then((colors) => colors[0].hex())
color: await getColors(
`https://i.ytimg.com/vi/${v}/maxresdefault.jpg`
).then((colors) => colors[0].hex()),
});
});
@ -245,8 +309,7 @@ app.get("/discover", async function (req, res) {
const k = JSON.parse(toJson(h));
renderTemplate(res, req, "main.ejs", {
k: k,
isMobile:req.useragent.isMobile
isMobile: req.useragent.isMobile,
});
});
@ -305,7 +368,9 @@ app.get("/api/search", async (req, res) => {
app.get("/search", async (req, res) => {
const { toJson } = require("xml2json");
const query = req.query.query;
const search = await fetch(`https://tube.kuylar.dev/api/search?query=${query}` );
const search = await fetch(
`https://tube.kuylar.dev/api/search?query=${query}`
);
const text = await search.text();
const j = JSON.parse(toJson(text));
@ -339,20 +404,19 @@ app.get("/", async function (req, res) {
app.get("/api/video/download", async function (req, res) {
var v = req.query.v;
var format = "mp4"
var format = "mp4";
var q = "22";
if (req.query.q) q = req.query.q;
if( req.query.f) {
var format = "mp3"
if (req.query.f) {
var format = "mp3";
}
var fetching = await fetcher(v);
const json = fetching.video.Player;
const url = `https://tube.kuylar.dev/proxy/download/${v}/${q}/${json.Title}.${format}`;
res.redirect(url)
res.redirect(url);
});
app.get("/api/video/downloadjson", async function (req, res) {