best way to save what you love
Svelte collaborationdownloaderinstagramjavascriptmusicredditsocial-mediasoundcloudsveltetiktoktwittertypescriptvideovimeovkwebappyoutubeyoutube-downloader
fix small issues
wukkof70128f4fc88
diff --git a/src/cobalt.js b/src/cobalt.jsindex 6694b53a..04c70516 100644--- a/src/cobalt.js+++ b/src/cobalt.js@@ -96,10 +96,10 @@ if (fs.existsSync('./.env')) {res.status(500).json({ 'status': 'error', 'text': 'something went wrong.' })}});- app.get("/api", async (req, res) => {+ app.get("/api", (req, res) => {res.redirect('/api/json')});- app.get("/", async (req, res) => {+ app.get("/", (req, res) => {// redirect masochists to a page where they can install a proper browserif (req.header("user-agent") && req.header("user-agent").includes("Trident")) {if (internetExplorerRedirect.newNT.includes(req.header("user-agent").split('NT ')[1].split(';')[0])) {@@ -118,10 +118,10 @@ if (fs.existsSync('./.env')) {}))}});- app.get("/favicon.ico", async (req, res) => {+ app.get("/favicon.ico", (req, res) => {res.redirect('/icons/favicon.ico');});- app.get("/*", async (req, res) => {+ app.get("/*", (req, res) => {res.redirect('/')});app.listen(process.env.port, () => {diff --git a/src/front/cobalt.js b/src/front/cobalt.jsindex 0e044d4a..7599553f 100644--- a/src/front/cobalt.js+++ b/src/front/cobalt.js@@ -185,15 +185,6 @@ function loadSettings() {changeSwitcher(i, sGet(i))}}-function checkbox(action) {- if (eid(action).checked) {- sSet(action, "true");- if (action == "alwaysVisibleButton") button();- } else {- sSet(action, "false");- if (action == "alwaysVisibleButton") button();- }-}function toggle(toggle) {let state = sGet(toggle);if (state) {diff --git a/src/localization/manager.js b/src/localization/manager.jsindex 996be019..4c16ae9a 100644--- a/src/localization/manager.js+++ b/src/localization/manager.js@@ -6,7 +6,7 @@ const locPath = './src/localization/languages'let loc = {}-export async function loadLoc() {+export function loadLoc() {fs.readdir(locPath, (err, files) => {files.forEach(file => {loc[file.split('.')[0]] = loadJson(`${locPath}/${file}`)diff --git a/src/modules/pageRender/elements.js b/src/modules/pageRender/elements.jsindex 082fe36b..f6d5fd6b 100644--- a/src/modules/pageRender/elements.js+++ b/src/modules/pageRender/elements.js@@ -32,7 +32,7 @@ export function popup(obj) {if (Array.isArray(obj.body)) {body = ``for (let i = 0; i < obj.body.length; i++) {- let classes = obj.body[i]["classes"] ? obj.body[i]["classes"] : []+ classes = obj.body[i]["classes"] ? obj.body[i]["classes"] : []if (i != obj.body.length - 1 && !obj.body[i]["nopadding"]) {classes.push("desc-padding")}diff --git a/src/modules/services/vimeo.js b/src/modules/services/vimeo.jsindex 220c9f63..5b887d5b 100644--- a/src/modules/services/vimeo.js+++ b/src/modules/services/vimeo.js@@ -16,9 +16,9 @@ export default async function(obj) {let best = all[0]try {if (obj.quality != "max") {- let pref = parseInt(quality[obj.quality])+ let pref = parseInt(quality[obj.quality], 10)for (let i in all) {- let currQuality = parseInt(all[i]["quality"].replace('p', ''))+ let currQuality = parseInt(all[i]["quality"].replace('p', ''), 10)if (currQuality < pref) {break;} else if (currQuality == pref) {diff --git a/src/modules/servicesPatternTesters.js b/src/modules/servicesPatternTesters.jsindex 01b4500e..d2cbd9ec 100644--- a/src/modules/servicesPatternTesters.js+++ b/src/modules/servicesPatternTesters.js@@ -1,4 +1,4 @@-export let testers = {+export const testers = {"twitter": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length < 20),"vk": (patternMatch) => (patternMatch["userId"] && patternMatch["videoId"] &&diff --git a/src/modules/setup.js b/src/modules/setup.jsindex 401eb0f8..4aa98a91 100644--- a/src/modules/setup.js+++ b/src/modules/setup.js@@ -9,6 +9,22 @@ let q = `${Cyan('?')} \x1b[1m`;let ob = { streamSalt: randomBytes(64).toString('hex') }let rl = createInterface({ input: process.stdin, output: process.stdout });+let final = () => {+ if (existsSync(envPath)) {+ unlinkSync(envPath)+ }+ for (let i in ob) {+ appendFileSync(envPath, `${i}=${ob[i]}\n`)+ }+ console.log(Bright("\nI've created a .env file with selfURL, port, and stream salt."))+ console.log(`${Bright("Now I'll run")} ${Cyan("npm install")} ${Bright("to install all dependencies. It shouldn't take long.\n\n")}`)+ execSync('npm install', { stdio: [0, 1, 2] });+ console.log(`\n\n${Green("All done!\n")}`)+ console.log("You can re-run this script any time to update the configuration.")+ console.log("\nYou're now ready to start the main project.\nHave fun!")+ rl.close()+}+console.log(`${Cyan("Welcome to cobalt!")}\n${Bright("We'll get you up and running in no time.\nLet's start by creating a ")}${Cyan(".env")}${Bright(" file. You can always change it later.")}`)@@ -36,19 +52,3 @@ rl.question(q, r1 => {final()});})--let final = () => {- if (existsSync(envPath)) {- unlinkSync(envPath)- }- for (let i in ob) {- appendFileSync(envPath, `${i}=${ob[i]}\n`)- }- console.log(Bright("\nI've created a .env file with selfURL, port, and stream salt."))- console.log(`${Bright("Now I'll run")} ${Cyan("npm install")} ${Bright("to install all dependencies. It shouldn't take long.\n\n")}`)- execSync('npm install', { stdio: [0, 1, 2] });- console.log(`\n\n${Green("All done!\n")}`)- console.log("You can re-run this script any time to update the configuration.")- console.log("\nYou're now ready to start the main project.\nHave fun!")- rl.close()-}diff --git a/src/modules/stream/selectQuality.js b/src/modules/stream/selectQuality.jsindex bfe2001e..d21a5f23 100644--- a/src/modules/stream/selectQuality.js+++ b/src/modules/stream/selectQuality.js@@ -9,8 +9,8 @@ function closest(goal, array) {export default function(service, quality, maxQuality) {if (quality == "max") return maxQuality;- quality = parseInt(mq[quality])- maxQuality = parseInt(maxQuality)+ quality = parseInt(mq[quality], 10)+ maxQuality = parseInt(maxQuality, 10)if (quality >= maxQuality || quality == maxQuality) return maxQuality;diff --git a/src/modules/stream/stream.js b/src/modules/stream/stream.jsindex a575ad2f..ee847df0 100644--- a/src/modules/stream/stream.js+++ b/src/modules/stream/stream.js@@ -22,6 +22,6 @@ export default function(res, ip, id, hmac, exp) {res.status(streamInfo.status).json(apiJSON(0, { t: streamInfo.error }).body);}} catch (e) {- internalError(res)+ res.status(500).json({ status: "error", text: "Internal Server Error" });}}diff --git a/src/modules/stream/types.js b/src/modules/stream/types.jsindex e2ca5322..3cc7d563 100644--- a/src/modules/stream/types.js+++ b/src/modules/stream/types.js@@ -4,7 +4,7 @@ import got from "got";import { ffmpegArgs, genericUserAgent } from "../config.js";import { msToTime } from "../sub/utils.js";-export async function streamDefault(streamInfo, res) {+export function streamDefault(streamInfo, res) {try {res.setHeader('Content-disposition', `attachment; filename="${streamInfo.isAudioOnly ? `${streamInfo.filename}.${streamInfo.audioFormat}` : streamInfo.filename}"`);const stream = got.get(streamInfo.urls, {@@ -23,7 +23,7 @@ export async function streamDefault(streamInfo, res) {res.end();}}-export async function streamLiveRender(streamInfo, res) {+export function streamLiveRender(streamInfo, res) {try {if (streamInfo.urls.length == 2) {let headers = {};@@ -79,7 +79,7 @@ export async function streamLiveRender(streamInfo, res) {res.end();}}-export async function streamAudioOnly(streamInfo, res) {+export function streamAudioOnly(streamInfo, res) {try {let headers = {};if (streamInfo.service == "bilibili") {diff --git a/src/modules/sub/utils.js b/src/modules/sub/utils.jsindex 2981c739..ceb4b2a7 100644--- a/src/modules/sub/utils.js+++ b/src/modules/sub/utils.js@@ -21,17 +21,17 @@ export function apiJSON(type, obj) {}}export function msToTime(d) {- let milliseconds = parseInt((d % 1000) / 100),- seconds = parseInt((d / 1000) % 60),- minutes = parseInt((d / (1000 * 60)) % 60),- hours = parseInt((d / (1000 * 60 * 60)) % 24),+ let milliseconds = parseInt((d % 1000) / 100, 10),+ seconds = parseInt((d / 1000) % 60, 10),+ minutes = parseInt((d / (1000 * 60)) % 60, 10),+ hours = parseInt((d / (1000 * 60 * 60)) % 24, 10),r;- hours = (hours < 10) ? "0" + hours : hours;- minutes = (minutes < 10) ? "0" + minutes : minutes;- seconds = (seconds < 10) ? "0" + seconds : seconds;- r = hours + ":" + minutes + ":" + seconds;- milliseconds ? r += "." + milliseconds : r += "";+ hours = (hours < 10) ? `0${hours}` : hours;+ minutes = (minutes < 10) ? `0${minutes}` : minutes;+ seconds = (seconds < 10) ? `0${seconds}` : seconds;+ r = `${hours}:${minutes}:${seconds}`;+ if (milliseconds) r += `.${milliseconds}`;return r;}export function cleanURL(url, host) {