Merge branch 'current' into feat/twitch
This commit is contained in:
@@ -16,4 +16,5 @@ export const
|
||||
donations = config.donations,
|
||||
ffmpegArgs = config.ffmpegArgs,
|
||||
supportedAudio = config.supportedAudio,
|
||||
celebrations = config.celebrations
|
||||
celebrations = config.celebrations,
|
||||
links = config.links
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const names = {
|
||||
"🎶": "musical_notes",
|
||||
"🎬": "clapper_board",
|
||||
"💰": "money_bag",
|
||||
"🎉": "party_popper",
|
||||
"❓": "question_mark",
|
||||
"✨": "sparkles",
|
||||
@@ -23,7 +22,8 @@ const names = {
|
||||
"🐦": "bird",
|
||||
"🐙": "octopus",
|
||||
"🔮": "crystal_ball",
|
||||
"💪": "biceps"
|
||||
"💪": "biceps",
|
||||
"💖": "sparkling_heart"
|
||||
}
|
||||
let sizing = {
|
||||
22: 0.4,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { celebrations } from "../config.js";
|
||||
import emoji from "../emoji.js";
|
||||
|
||||
export function switcher(obj) {
|
||||
let items = ``;
|
||||
@@ -11,7 +12,7 @@ export function switcher(obj) {
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.noParent) return `<div class="switches">${items}</div>`;
|
||||
if (obj.noParent) return `<div id="${obj.name}" class="switches">${items}</div>`;
|
||||
return `<div id="${obj.name}-switcher" class="switch-container">
|
||||
${obj.subtitle ? `<div class="subtitle">${obj.subtitle}</div>` : ``}
|
||||
<div class="switches">${items}</div>
|
||||
@@ -130,8 +131,8 @@ export function popupWithBottomButtons(obj) {
|
||||
export function backdropLink(link, text) {
|
||||
return `<a class="text-backdrop italic" href="${link}" target="_blank">${text}</a>`
|
||||
}
|
||||
export function socialLink(emoji, name, handle, url) {
|
||||
return `<div class="cobalt-support-link">${emoji} ${name}: <a class="text-backdrop italic" href="${url}" target="_blank">${handle}</a></div>`
|
||||
export function socialLink(emji, name, handle, url) {
|
||||
return `<div class="cobalt-support-link">${emji} ${name}: <a class="text-backdrop italic" href="${url}" target="_blank">${handle}</a></div>`
|
||||
}
|
||||
export function settingsCategory(obj) {
|
||||
return `<div id="settings-${obj.name}" class="settings-category">
|
||||
@@ -151,12 +152,20 @@ export function footerButtons(obj) {
|
||||
items += `<button id="${obj[i]["name"]}-footer" class="switch footer-button" onclick="${obj[i]["action"]}()" aria-label="${obj[i]["aria"]}">${obj[i]["text"]}</button>`;
|
||||
break;
|
||||
case "popup":
|
||||
let context = obj[i]["context"] ? `, '${obj[i]["context"]}'` : ''
|
||||
let context2 = obj[i+1] && obj[i+1]["context"] ? `, '${obj[i+1]["context"]}'` : ''
|
||||
let buttonName = obj[i]["context"] ? `${obj[i]["name"]}-${obj[i]["context"]}` : obj[i]["name"],
|
||||
context = obj[i]["context"] ? `, '${obj[i]["context"]}'` : '',
|
||||
buttonName2,
|
||||
context2;
|
||||
|
||||
if (obj[i+1]) {
|
||||
buttonName2 = obj[i+1]["context"] ? `${obj[i+1]["name"]}-${obj[i+1]["context"]}` : obj[i+1]["name"];
|
||||
context2 = obj[i+1]["context"] ? `, '${obj[i+1]["context"]}'` : '';
|
||||
}
|
||||
|
||||
items += `
|
||||
<div class="footer-pair">
|
||||
<button id="${obj[i]["name"]}-footer" class="switch footer-button" onclick="popup('${obj[i]["name"]}', 1${context})" aria-label="${obj[i]["aria"]}">${obj[i]["text"]}</button>
|
||||
${obj[i+1] ? `<button id="${obj[i+1]["name"]}-footer" class="switch footer-button" onclick="popup('${obj[i+1]["name"]}', 1${context2})" aria-label="${obj[i+1]["aria"]}">${obj[i+1]["text"]}</button>`: ''}
|
||||
<button id="${buttonName}-footer" class="switch footer-button" onclick="popup('${obj[i]["name"]}', 1${context})" aria-label="${obj[i]["aria"]}">${obj[i]["text"]}</button>
|
||||
${obj[i+1] ? `<button id="${buttonName2}-footer" class="switch footer-button" onclick="popup('${obj[i+1]["name"]}', 1${context2})" aria-label="${obj[i+1]["aria"]}">${obj[i+1]["text"]}</button>`: ''}
|
||||
</div>`;
|
||||
i++;
|
||||
break;
|
||||
@@ -169,7 +178,12 @@ export function explanation(text) {
|
||||
return `<div class="explanation">${text}</div>`
|
||||
}
|
||||
export function celebrationsEmoji() {
|
||||
let n = new Date().toISOString().split('T')[0].split('-');
|
||||
let dm = `${n[1]}-${n[2]}`;
|
||||
return Object.keys(celebrations).includes(dm) ? celebrations[dm] : "🐲";
|
||||
try {
|
||||
let n = new Date().toISOString().split('T')[0].split('-');
|
||||
let dm = `${n[1]}-${n[2]}`;
|
||||
let f = Object.keys(celebrations).includes(dm) ? celebrations[dm] : "🐲";
|
||||
return f != "🐲" ? emoji(f, 22) : false;
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { backdropLink, celebrationsEmoji, checkbox, collapsibleList, explanation, footerButtons, multiPagePopup, popup, popupWithBottomButtons, sep, settingsCategory, switcher, socialLink } from "./elements.js";
|
||||
import { backdropLink, checkbox, collapsibleList, explanation, footerButtons, multiPagePopup, popup, popupWithBottomButtons, sep, settingsCategory, switcher, socialLink } from "./elements.js";
|
||||
import { services as s, appName, authorInfo, version, repo, donations, supportedAudio } from "../config.js";
|
||||
import { getCommitInfo } from "../sub/currentCommit.js";
|
||||
import loc from "../../localization/manager.js";
|
||||
@@ -149,7 +149,7 @@ export default function(obj) {
|
||||
})
|
||||
}, {
|
||||
name: "donate",
|
||||
title: `${emoji("💰")} ${t('DonationsTab')}`,
|
||||
title: `${emoji("💖")} ${t('DonationsTab')}`,
|
||||
content: popup({
|
||||
name: "donate",
|
||||
header: {
|
||||
@@ -392,13 +392,13 @@ export default function(obj) {
|
||||
footerButtons([{
|
||||
name: "about",
|
||||
type: "popup",
|
||||
text: `${emoji(celebrationsEmoji() , 22)} ${t('AboutTab')}`,
|
||||
text: `${emoji("🐲" , 22)} ${t('AboutTab')}`,
|
||||
aria: t('AccessibilityOpenAbout')
|
||||
}, {
|
||||
name: "about",
|
||||
type: "popup",
|
||||
context: "donate",
|
||||
text: `${emoji("💰", 22)} ${t('Donate')}`,
|
||||
text: `${emoji("💖", 22)} ${t('Donate')}`,
|
||||
aria: t('AccessibilityOpenDonate')
|
||||
}, {
|
||||
name: "settings",
|
||||
|
||||
@@ -36,8 +36,7 @@ async function findClientID() {
|
||||
export default async function(obj) {
|
||||
let html;
|
||||
if (!obj.author && !obj.song && obj.shortLink) {
|
||||
html = await fetch(`https://soundcloud.app.goo.gl/${obj.shortLink}/`).then((r) => { return r.status === 404 ? false : r.text() }).catch(() => { return false });
|
||||
if (!html) html = await fetch(`https://on.soundcloud.com/${obj.shortLink}/`).then((r) => { return r.status === 404 ? false : r.text() }).catch(() => { return false })
|
||||
html = await fetch(`https://on.soundcloud.com/${obj.shortLink}/`).then((r) => { return r.status === 404 ? false : r.text() }).catch(() => { return false });
|
||||
}
|
||||
if (obj.author && obj.song) {
|
||||
html = await fetch(`https://soundcloud.com/${obj.author}/${obj.song}${obj.accessKey ? `/s-${obj.accessKey}` : ''}`).then((r) => { return r.text() }).catch(() => { return false });
|
||||
|
||||
@@ -44,7 +44,7 @@ export default async function(o) {
|
||||
if (Number(bestQuality._attributes.id) > Number(quality)) bestQuality = repr[quality];
|
||||
|
||||
url = js.player.params[0][`url${resolutionMatch[bestQuality._attributes[resolutionPick]]}`];
|
||||
filename = `${bestQuality._attributes.width}x${bestQuality._attributes.height}.mp4`
|
||||
filename += `${bestQuality._attributes.width}x${bestQuality._attributes.height}.mp4`
|
||||
|
||||
} else if (js.player.params[0]["url240"]) { // fallback for when video is too old
|
||||
url = js.player.params[0]["url240"];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { existsSync, unlinkSync, appendFileSync } from "fs";
|
||||
import { createInterface } from "readline";
|
||||
import { Cyan, Bright, Green } from "./sub/consoleText.js";
|
||||
import { Cyan, Bright } from "./sub/consoleText.js";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
let envPath = './.env';
|
||||
@@ -42,7 +42,7 @@ rl.question(q, r1 => {
|
||||
if (r2) ob['port'] = r2
|
||||
if (!r1 && r2) ob['selfURL'] = `http://localhost:${r2}/`
|
||||
|
||||
console.log(Bright("\nWould you like to enable CORS? It allows other websites and extensions to use your instance's API.\n y/n (n)"))
|
||||
console.log(Bright("\nWould you like to enable CORS? It allows other websites and extensions to use your instance's API.\ny/n (n)"))
|
||||
|
||||
rl.question(q, r3 => {
|
||||
if (r3.toLowerCase() !== 'y') ob['cors'] = '0'
|
||||
|
||||
@@ -2,7 +2,7 @@ import { spawn } from "child_process";
|
||||
import ffmpeg from "ffmpeg-static";
|
||||
import got from "got";
|
||||
import { ffmpegArgs, genericUserAgent } from "../config.js";
|
||||
import { metadataManager, msToTime } from "../sub/utils.js";
|
||||
import { getThreads, metadataManager, msToTime } from "../sub/utils.js";
|
||||
|
||||
export function streamDefault(streamInfo, res) {
|
||||
try {
|
||||
@@ -35,9 +35,9 @@ export function streamLiveRender(streamInfo, res) {
|
||||
return;
|
||||
}
|
||||
let audio = got.get(streamInfo.urls[1], { isStream: true });
|
||||
|
||||
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
|
||||
'-loglevel', '-8',
|
||||
'-threads', `${getThreads()}`,
|
||||
'-i', streamInfo.urls[0],
|
||||
'-i', 'pipe:3',
|
||||
'-map', '0:v',
|
||||
@@ -95,6 +95,7 @@ export function streamAudioOnly(streamInfo, res) {
|
||||
try {
|
||||
let args = [
|
||||
'-loglevel', '-8',
|
||||
'-threads', `${getThreads()}`,
|
||||
'-i', streamInfo.urls
|
||||
]
|
||||
if (streamInfo.metadata) {
|
||||
@@ -141,6 +142,7 @@ export function streamVideoOnly(streamInfo, res) {
|
||||
try {
|
||||
let format = streamInfo.filename.split('.')[streamInfo.filename.split('.').length - 1], args = [
|
||||
'-loglevel', '-8',
|
||||
'-threads', `${getThreads()}`,
|
||||
'-i', streamInfo.urls,
|
||||
'-c', 'copy'
|
||||
]
|
||||
|
||||
@@ -142,3 +142,15 @@ export function checkJSONPost(obj) {
|
||||
export function getIP(req) {
|
||||
return req.header('cf-connecting-ip') ? req.header('cf-connecting-ip') : req.ip;
|
||||
}
|
||||
export function getThreads() {
|
||||
try {
|
||||
if (process.env.ffmpegThreads && process.env.ffmpegThreads.length <= 3
|
||||
&& (Number(process.env.ffmpegThreads) >= 0 && Number(process.env.ffmpegThreads) <= 256)) {
|
||||
return process.env.ffmpegThreads
|
||||
} else {
|
||||
return '0'
|
||||
}
|
||||
} catch (e) {
|
||||
return '0'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user