Skip to content

Commit

Permalink
4.7
Browse files Browse the repository at this point in the history
fixes #63, #67, #68, and #71, among other issues
  • Loading branch information
wukko committed Jan 13, 2023
1 parent 1a1a453 commit 3b5bf51
Show file tree
Hide file tree
Showing 19 changed files with 216 additions and 189 deletions.
12 changes: 6 additions & 6 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ Item type: ``object``
Content live render streaming endpoint.<br>

### Request Query Variables
| key | variables | description |
|:----|:-----------------|:------------------------------------------------------------------------------------------------------------------------------|
| p | ``1`` | Used for checking the rate limit. |
| t | Stream UUID | Unique stream identificator by which cobalt finds stored stream info data. |
| h | HMAC | Hashed combination of: (hashed) ip address, stream uuid, expiry timestamp, and service name. Used for verification of stream. |
| e | Expiry timestamp | |
| key | variables | description |
|:----|:-----------------|:-------------------------------------------------------------------------------------------------------------------------------|
| p | ``1`` | Used for checking the rate limit. |
| t | Stream token | Unique stream identificator which is used for retrieving cached stream info data. |
| h | HMAC | Hashed combination of: (hashed) ip address, stream token, expiry timestamp, and service name. Used for verification of stream. |
| e | Expiry timestamp | |

## GET: ``/api/onDemand``
On-demand website element loading. Currently used only for older changelogs.<br>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cobalt",
"description": "save what you love",
"version": "4.6.1",
"version": "4.7",
"author": "wukko",
"exports": "./src/cobalt.js",
"type": "module",
Expand Down
6 changes: 3 additions & 3 deletions src/cobalt.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import stream from "./modules/stream/stream.js";
import loc from "./localization/manager.js";
import { buildFront } from "./modules/build.js";
import { changelogHistory } from "./modules/pageRender/onDemand.js";
import { encrypt } from "./modules/sub/crypto.js";
import { sha256 } from "./modules/sub/crypto.js";

const commitHash = shortCommit();
const app = express();
Expand Down Expand Up @@ -71,7 +71,7 @@ if (fs.existsSync('./.env') && process.env.selfURL && process.env.streamSalt &&
}));
app.post('/api/:type', cors({ origin: process.env.selfURL, optionsSuccessStatus: 200 }), async (req, res) => {
try {
let ip = encrypt(req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip.replace('::ffff:', ''), process.env.streamSalt);
let ip = sha256(req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip.replace('::ffff:', ''), process.env.streamSalt);
switch (req.params.type) {
case 'json':
try {
Expand Down Expand Up @@ -103,7 +103,7 @@ if (fs.existsSync('./.env') && process.env.selfURL && process.env.streamSalt &&
});
app.get('/api/:type', cors({ origin: process.env.selfURL, optionsSuccessStatus: 200 }), (req, res) => {
try {
let ip = encrypt(req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip.replace('::ffff:', ''), process.env.streamSalt);
let ip = sha256(req.header('x-forwarded-for') ? req.header('x-forwarded-for') : req.ip.replace('::ffff:', ''), process.env.streamSalt);
switch (req.params.type) {
case 'json':
res.status(405).json({ 'status': 'error', 'text': 'GET method for this request has been deprecated. see https://github.com/wukko/cobalt/blob/current/docs/API.md for up-to-date API documentation.' });
Expand Down
4 changes: 2 additions & 2 deletions src/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"streamLifespan": 3600000,
"streamLifespan": 120000,
"maxVideoDuration": 7500000,
"maxAudioDuration": 7500000,
"genericUserAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36",
Expand Down Expand Up @@ -59,7 +59,7 @@
"webm": ["-c:v", "copy", "-c:a", "copy"],
"mp4": ["-c:v", "copy", "-c:a", "copy", "-movflags", "faststart+frag_keyframe+empty_moov"],
"copy": ["-c:a", "copy"],
"audio": ["-ar", "48000", "-ac", "2", "-b:a", "320k"],
"audio": ["-vn", "-ar", "48000", "-ac", "2", "-b:a", "320k"],
"m4a": ["-movflags", "frag_keyframe+empty_moov"]
}
}
25 changes: 14 additions & 11 deletions src/front/cobalt.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ a {
:focus-visible {
outline: var(--border-15);
}
[type=checkbox] {
margin-right: 0.8rem;
}
[type="checkbox"] {
-webkit-appearance: none;
margin-right: 0.8rem;
appearance: none;
margin-right: 1rem;
z-index: 0;
border: 0;
height: 15px;
}
[type="checkbox"]::before {
content: "";
Expand All @@ -91,9 +91,12 @@ a {
position: relative;
}
[type="checkbox"]:checked::before {
box-shadow: inset 0 0 0 0.2rem var(--accent-button-bg);
box-shadow: inset 0 0 0 0.14rem var(--accent-button-bg);
background-color: var(--accent);
}
.checkbox span {
margin-top: 0.21rem;
}
button {
background: none;
border: none;
Expand Down Expand Up @@ -421,7 +424,7 @@ input[type="checkbox"] {
flex-direction: row;
flex-wrap: nowrap;
align-content: center;
padding: 0.6rem 1rem 0.6rem 0.6rem;
padding: 0.55rem 1rem 0.8rem 0.7rem;
width: auto;
margin: 0 0.5rem 0.5rem 0;
background: var(--accent-button-bg);
Expand Down Expand Up @@ -454,7 +457,7 @@ input[type="checkbox"] {
color: var(--accent-unhover-2);
}
.switch {
padding: 0.8rem;
padding: 0.7rem;
width: 100%;
text-align: center;
color: var(--accent);
Expand Down Expand Up @@ -509,6 +512,9 @@ input[type="checkbox"] {
position: relative;
width: 100%;
}
.popup-tabs {
margin-top: 0.5rem;
}
.emoji {
margin-right: 0.4rem;
}
Expand Down Expand Up @@ -573,9 +579,6 @@ input[type="checkbox"] {
margin-top: 0!important;
margin-bottom: 1rem;
}
.popup-tabs {
padding-top: 0.5rem;
}
/* adapt the page according to screen size */
@media screen and (min-width: 2300px) {
html {
Expand Down Expand Up @@ -754,7 +757,7 @@ input[type="checkbox"] {
.popup, .popup.scrollable, .popup.small {
border: none;
width: 90%;
height: 90%;
height: 92%;
max-height: 100%;
}
.bottom-link {
Expand Down
2 changes: 1 addition & 1 deletion src/front/cobalt.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
let ua = navigator.userAgent.toLowerCase();
let isIOS = ua.match("iphone os");
let isMobile = ua.match("android") || ua.match("iphone os");
let version = 20;
let version = 21;
let regex = new RegExp(/https:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/);
let notification = `<div class="notification-dot"></div>`

Expand Down
Binary file added src/front/updateBanners/bettertogether.webp
Binary file not shown.
10 changes: 5 additions & 5 deletions src/localization/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"SettingsEnableDownloadPopup": "ask for a way to save",
"AccessibilityEnableDownloadPopup": "ask what to do with downloads",
"SettingsFormatDescription": "select webm if you want max quality available. webm videos are usually higher bitrate, but ios devices can't play them natively.",
"SettingsQualityDescription": "if selected quality isn't available, closest one gets picked instead.\nif you want to post a youtube video on social media, then select a combination of mp4 and 720p. those videos are usually not in av1 codec, so they should play just fine basically everywhere.",
"SettingsQualityDescription": "if selected quality isn't available, closest one gets picked instead.\nif you want to post a youtube video on social media, select a combination of mp4 and 720p.",
"LinkGitHubIssues": "&gt;&gt; report issues and check out the source code on github",
"LinkGitHubChanges": "&gt;&gt; see previous commits and contribute on github",
"NoScriptMessage": "{appName} uses javascript for api requests and interactive interface. you have to allow javascript to use this site. i don't have any ads or trackers, pinky promise.",
"DownloadPopupDescriptionIOS": "on ios devices, you have to press and hold the download button, hide the video preview, and then select \"download linked file\" in appeared popup to save the video. this will be required for as long as apple forces safari webview upon all browser developers on ios.",
"DownloadPopupDescriptionIOS": "press and hold the download button, hide the video preview, and then select \"download linked file\" to save.",
"DownloadPopupDescription": "download button opens a new tab with requested file. you can disable this popup in settings.",
"DownloadPopupWayToSave": "pick a way to save",
"ClickToCopy": "press to copy",
Expand All @@ -72,7 +72,7 @@
"AccessibilityModeToggle": "toggle download mode",
"DonateLinksDescription": "donation links open in a new tab. this is the best way to donate if you want me to receive your donation directly.",
"SettingsAudioFormatBest": "best",
"SettingsAudioFormatDescription": "when best format is selected, you get audio in best quality available, because audio is kept in its original format. if you select anything other than that, you'll get a slightly compressed file.",
"SettingsAudioFormatDescription": "when best format is selected, you get audio in best quality available, because it's not re-encoded. everything else will be re-encoded.",
"Keyphrase": "save what you love",
"SettingsRemoveWatermark": "disable watermark",
"ErrorPopupCloseButton": "got it",
Expand Down Expand Up @@ -101,14 +101,14 @@
"MediaPickerExplanationPhoneIOS": "press and hold, hide the preview, and then select \"download linked file\" to save.",
"TwitterSpaceWasntRecorded": "this twitter space wasn't recorded, so there's nothing to download. try another one!",
"ErrorCantProcess": "i couldn't process your request :(\nyou can try again, but if issue persists, please {ContactLink}.",
"ChangelogPressToHide": "press to hide",
"ChangelogPressToHide": "press to collapse",
"Donate": "donate",
"DonateSub": "help me keep it up",
"DonateExplanation": "{appName} does not (and will never) serve ads or sell your data, therefore it's <span class=\"text-backdrop\">completely free to use</span>. but hey! turns out keeping up a web service used by hundreds of thousands of people is somewhat costly.\n\nif you ever found {appName} useful and want to keep it online, or simply want to thank the developer, consider chipping in! each and every cent helps and is VERY appreciated.",
"DonateVia": "donate via",
"DonateHireMe": "or, as an alternative, you can <a class=\"text-backdrop\" href=\"{s}\" target=\"_blank\">hire me</a>.",
"SettingsVideoMute": "mute audio",
"SettingsVideoMuteExplanation": "disables audio in downloaded video when possible. you'll get the source video file if video and audio channels are served in two files by the origin service. ignored when audio mode is on or service only supports audio.",
"SettingsVideoMuteExplanation": "disables audio in downloaded video when possible. ignored when audio mode is on or service only supports audio.",
"SettingsVideoGeneral": "general",
"ErrorSoundCloudNoClientId": "couldn't find client_id that is required to fetch audio data from soundcloud. try again, and if issue persists, {ContactLink}."
}
Expand Down
8 changes: 4 additions & 4 deletions src/localization/languages/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@
"SettingsEnableDownloadPopup": "спрашивать, что делать при скачивании",
"AccessibilityEnableDownloadPopup": "спрашивать, что делать с загрузками",
"SettingsFormatDescription": "выбирай webm, если хочешь максимальное качество. у webm видео битрейт обычно выше, но устройства на ios не могут проигрывать их без сторонних приложений.",
"SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.\nесли ты хочешь опубликовать видео с youtube где-то в соц. сетях, то выбирай комбинацию из mp4 и 720p. у таких видео кодек обычно не av1, поэтому они должны работать практически везде.",
"SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.\nесли ты хочешь опубликовать видео с youtube где-то в соц. сетях, то выбирай комбинацию из mp4 и 720p.",
"LinkGitHubIssues": "&gt;&gt; сообщай о проблемах и смотри исходный код на github",
"LinkGitHubChanges": "&gt;&gt; смотри предыдущие изменения на github",
"NoScriptMessage": "{appName} использует javascript для обработки ссылок и интерактивного интерфейса. ты должен разрешить использование javascript, чтобы пользоваться сайтом. тут нет никаких трекеров или рекламы, обещаю.",
"DownloadPopupDescriptionIOS": "так как у тебя устройство на ios, тебе нужно зажать кнопку \"скачать\", затем скрыть превью видео и выбрать \"загрузить файл по ссылке\" в появившемся окне.",
"DownloadPopupDescriptionIOS": "зажми кнопку \"скачать\", затем скрой превью видео и выбери \"загрузить файл по ссылке\" в появившемся окне.",
"DownloadPopupDescription": "кнопка скачивания открывает новое окно с файлом. ты можешь отключить выбор метода сохранения файла в настройках.",
"DownloadPopupWayToSave": "выбери, как сохранить",
"ClickToCopy": "нажми, чтобы скопировать",
Expand All @@ -72,7 +72,7 @@
"AccessibilityModeToggle": "переключить режим скачивания",
"DonateLinksDescription": "ссылки на донаты открываются в новой вкладке. это наилучший способ отправить донат, если ты хочешь, чтобы я получил его напрямую.",
"SettingsAudioFormatBest": "лучший",
"SettingsAudioFormatDescription": "когда выбран \"лучший\" формат, ты получишь аудио максимально возможного качества, так как оно останется в оригинальном формате. если же выбрано что-то другое, то аудио будет немного сжато.",
"SettingsAudioFormatDescription": "когда выбран \"лучший\" формат, ты получишь аудио лучшего качества, так как оно не будет сконвертировано. если же выбрано что-то другое, то аудио будет немного сжато.",
"Keyphrase": "сохраняй то, что любишь",
"SettingsRemoveWatermark": "убрать ватермарку",
"ErrorPopupCloseButton": "ясно",
Expand Down Expand Up @@ -108,7 +108,7 @@
"DonateVia": "открыть",
"DonateHireMe": "или же ты можешь <a class=\"text-backdrop\" href=\"{s}\" target=\"_blank\">пригласить меня на работу</a>.",
"SettingsVideoMute": "отключить аудио",
"SettingsVideoMuteExplanation": "убирает аудио при загрузке видео, когда это возможно. ты получишь исходное видео напрямую от сервиса, если видео и аудио каналы разбиты по файлам. игнорируется если включен режим аудио или сервис поддерживает только аудио загрузки.",
"SettingsVideoMuteExplanation": "убирает аудио при загрузке видео, когда это возможно. игнорируется если включен режим аудио или сервис поддерживает только аудио загрузки.",
"SettingsVideoGeneral": "основные",
"ErrorSoundCloudNoClientId": "мне не удалось достать client_id, который необходим для получения аудио из soundcloud. попробуй ещё раз, но если так и не получится, {ContactLink}."
}
Expand Down
2 changes: 1 addition & 1 deletion src/localization/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function loadLoc() {
}
loadLoc();
export function replaceBase(s) {
return s.replace(/\n/g, '<br/>').replace(/{appName}/g, appName).replace(/{repo}/g, repo)// .replace(/{discord}/g, socials.discord)
return s.replace(/\n/g, '<br/>').replace(/{appName}/g, appName).replace(/{repo}/g, repo).replace(/{bS}/g, '<div class=\"bullpadding\">').replace(/{bE}/g, '</div>').replace(/\*;/g, "&bull;");
}
export function replaceAll(lang, str, string, replacement) {
let s = replaceBase(str[string])
Expand Down
Loading

0 comments on commit 3b5bf51

Please sign in to comment.