Update src/libpoketube/init/pages-video.js
This commit is contained in:
parent
f132b158b3
commit
e13e9ec7ce
@ -402,151 +402,5 @@ module.exports = function (app, config, renderTemplate) {
|
||||
});
|
||||
|
||||
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 info = await modules.fetch("http://ip-api.com/json/");
|
||||
const n = await info.text();
|
||||
const ip = JSON.parse(n);
|
||||
|
||||
if (!v) {
|
||||
res.redirect("/discover?tab=music");
|
||||
} else {
|
||||
var fetching = await fetcher(v);
|
||||
|
||||
const json = fetching.video.Player;
|
||||
|
||||
const video = await modules.fetch(config.tubeApi + `video?v=${v}`);
|
||||
|
||||
const h = await video.text();
|
||||
const k = JSON.parse(modules.toJson(h));
|
||||
|
||||
if (!json.Channel.Name.endsWith(" - Topic")) {
|
||||
res.redirect(`/watch?v=${v}`);
|
||||
}
|
||||
|
||||
if (req.useragent.isMobile) {
|
||||
res.redirect(`/watch?v=${v}`);
|
||||
}
|
||||
|
||||
//video
|
||||
var url = `https://tube.kuylar.dev/proxy/media/${v}/22`;
|
||||
|
||||
// encryption
|
||||
var url_e =
|
||||
url +
|
||||
"?e=" +
|
||||
sha384(k.Video.Channel.id) +
|
||||
sha384(k.Video.Channel.id) +
|
||||
"Piwik" +
|
||||
sha384(config.t_url);
|
||||
|
||||
const stringed = toObject(atmos);
|
||||
|
||||
const search = (what) => atmos.find((element) => element.id === what);
|
||||
const mos = search(v);
|
||||
|
||||
/*
|
||||
this is only for the alac codec being used
|
||||
|
||||
* Copyright (c) 2023 Apple Inc. All rights reserved.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_START@
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* @APPLE_APACHE_LICENSE_HEADER_END@
|
||||
*/
|
||||
|
||||
if (mos) {
|
||||
var url_e =
|
||||
mos.url +
|
||||
"?e=" +
|
||||
sha384(k.Video.Channel.id) +
|
||||
sha384(k.Video.Channel.id) +
|
||||
"Piwik" +
|
||||
sha384(config.t_url);
|
||||
} else {
|
||||
}
|
||||
|
||||
// channel info
|
||||
const engagement = fetching.engagement;
|
||||
const channel = await modules.fetch(
|
||||
config.tubeApi + `channel?id=${k.Video.Channel.id}&tab=videos`
|
||||
);
|
||||
const c = await channel.text();
|
||||
const tj = JSON.parse(modules.toJson(c));
|
||||
|
||||
try {
|
||||
// info
|
||||
const song = await musicInfo.searchSong(
|
||||
{
|
||||
title: k.Video.Title,
|
||||
artist: json.Channel.Name.replace("- Topic", ""),
|
||||
},
|
||||
1000
|
||||
);
|
||||
|
||||
if (!song) {
|
||||
res.redirect(`/watch?v=${v}`);
|
||||
}
|
||||
|
||||
const lyrics = await lyricsFinder(song.artist + song.title);
|
||||
if (lyrics == undefined)
|
||||
ly = "This Is Where I'd Put The songs lyrics. IF IT HAD ONE ";
|
||||
|
||||
var ly = "";
|
||||
if (lyrics) {
|
||||
ly = lyrics.replace(/\n/g, " <br> ");
|
||||
}
|
||||
|
||||
renderTemplate(res, req, "poketube-music.ejs", {
|
||||
url: url_e,
|
||||
info: song,
|
||||
color: await modules
|
||||
.getColors(song.artwork)
|
||||
.then((colors) => colors[0].hex()),
|
||||
engagement: engagement,
|
||||
process: process,
|
||||
ip: ip,
|
||||
video: json,
|
||||
date: modules.moment(k.Video.uploadDate).format("LL"),
|
||||
e: e,
|
||||
k: k,
|
||||
sha384: sha384,
|
||||
isMobile: req.useragent.isMobile,
|
||||
tj: tj,
|
||||
r: r,
|
||||
f: f,
|
||||
t: config.t_url,
|
||||
optout: t,
|
||||
lyrics: ly,
|
||||
});
|
||||
} catch {
|
||||
return res.redirect("/?fromerror=43");
|
||||
}
|
||||
}
|
||||
});
|
||||
return res.json("o7")
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user