diff --git a/docs/API.md b/docs/API.md
index 9801a553..7bbdd725 100644
--- a/docs/API.md
+++ b/docs/API.md
@@ -45,12 +45,12 @@ Item type: ``object``
Content live render streaming endpoint.
### 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.
diff --git a/package.json b/package.json
index 00e6cf73..079cb651 100644
--- a/package.json
+++ b/package.json
@@ -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",
diff --git a/src/cobalt.js b/src/cobalt.js
index 82f4bb9c..74004f91 100644
--- a/src/cobalt.js
+++ b/src/cobalt.js
@@ -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();
@@ -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 {
@@ -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.' });
diff --git a/src/config.json b/src/config.json
index d42baf27..2d800fe6 100644
--- a/src/config.json
+++ b/src/config.json
@@ -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",
@@ -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"]
}
}
diff --git a/src/front/cobalt.css b/src/front/cobalt.css
index a4068ada..283da7cf 100644
--- a/src/front/cobalt.css
+++ b/src/front/cobalt.css
@@ -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: "";
@@ -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;
@@ -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);
@@ -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);
@@ -509,6 +512,9 @@ input[type="checkbox"] {
position: relative;
width: 100%;
}
+.popup-tabs {
+ margin-top: 0.5rem;
+}
.emoji {
margin-right: 0.4rem;
}
@@ -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 {
@@ -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 {
diff --git a/src/front/cobalt.js b/src/front/cobalt.js
index 0c57be82..7086ec8a 100644
--- a/src/front/cobalt.js
+++ b/src/front/cobalt.js
@@ -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 = `
`
diff --git a/src/front/updateBanners/bettertogether.webp b/src/front/updateBanners/bettertogether.webp
new file mode 100644
index 00000000..a1e03806
Binary files /dev/null and b/src/front/updateBanners/bettertogether.webp differ
diff --git a/src/localization/languages/en.json b/src/localization/languages/en.json
index c364fc46..57a8a2d1 100644
--- a/src/localization/languages/en.json
+++ b/src/localization/languages/en.json
@@ -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": ">> report issues and check out the source code on github",
"LinkGitHubChanges": ">> 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",
@@ -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",
@@ -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 completely free to use. 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 hire me.",
"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}."
}
diff --git a/src/localization/languages/ru.json b/src/localization/languages/ru.json
index 8c76ae2f..b6816d1d 100644
--- a/src/localization/languages/ru.json
+++ b/src/localization/languages/ru.json
@@ -52,11 +52,11 @@
"SettingsEnableDownloadPopup": "спрашивать, что делать при скачивании",
"AccessibilityEnableDownloadPopup": "спрашивать, что делать с загрузками",
"SettingsFormatDescription": "выбирай webm, если хочешь максимальное качество. у webm видео битрейт обычно выше, но устройства на ios не могут проигрывать их без сторонних приложений.",
- "SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.\nесли ты хочешь опубликовать видео с youtube где-то в соц. сетях, то выбирай комбинацию из mp4 и 720p. у таких видео кодек обычно не av1, поэтому они должны работать практически везде.",
+ "SettingsQualityDescription": "если выбранное качество недоступно, то выбирается ближайшее к нему.\nесли ты хочешь опубликовать видео с youtube где-то в соц. сетях, то выбирай комбинацию из mp4 и 720p.",
"LinkGitHubIssues": ">> сообщай о проблемах и смотри исходный код на github",
"LinkGitHubChanges": ">> смотри предыдущие изменения на github",
"NoScriptMessage": "{appName} использует javascript для обработки ссылок и интерактивного интерфейса. ты должен разрешить использование javascript, чтобы пользоваться сайтом. тут нет никаких трекеров или рекламы, обещаю.",
- "DownloadPopupDescriptionIOS": "так как у тебя устройство на ios, тебе нужно зажать кнопку \"скачать\", затем скрыть превью видео и выбрать \"загрузить файл по ссылке\" в появившемся окне.",
+ "DownloadPopupDescriptionIOS": "зажми кнопку \"скачать\", затем скрой превью видео и выбери \"загрузить файл по ссылке\" в появившемся окне.",
"DownloadPopupDescription": "кнопка скачивания открывает новое окно с файлом. ты можешь отключить выбор метода сохранения файла в настройках.",
"DownloadPopupWayToSave": "выбери, как сохранить",
"ClickToCopy": "нажми, чтобы скопировать",
@@ -72,7 +72,7 @@
"AccessibilityModeToggle": "переключить режим скачивания",
"DonateLinksDescription": "ссылки на донаты открываются в новой вкладке. это наилучший способ отправить донат, если ты хочешь, чтобы я получил его напрямую.",
"SettingsAudioFormatBest": "лучший",
- "SettingsAudioFormatDescription": "когда выбран \"лучший\" формат, ты получишь аудио максимально возможного качества, так как оно останется в оригинальном формате. если же выбрано что-то другое, то аудио будет немного сжато.",
+ "SettingsAudioFormatDescription": "когда выбран \"лучший\" формат, ты получишь аудио лучшего качества, так как оно не будет сконвертировано. если же выбрано что-то другое, то аудио будет немного сжато.",
"Keyphrase": "сохраняй то, что любишь",
"SettingsRemoveWatermark": "убрать ватермарку",
"ErrorPopupCloseButton": "ясно",
@@ -108,7 +108,7 @@
"DonateVia": "открыть",
"DonateHireMe": "или же ты можешь пригласить меня на работу.",
"SettingsVideoMute": "отключить аудио",
- "SettingsVideoMuteExplanation": "убирает аудио при загрузке видео, когда это возможно. ты получишь исходное видео напрямую от сервиса, если видео и аудио каналы разбиты по файлам. игнорируется если включен режим аудио или сервис поддерживает только аудио загрузки.",
+ "SettingsVideoMuteExplanation": "убирает аудио при загрузке видео, когда это возможно. игнорируется если включен режим аудио или сервис поддерживает только аудио загрузки.",
"SettingsVideoGeneral": "основные",
"ErrorSoundCloudNoClientId": "мне не удалось достать client_id, который необходим для получения аудио из soundcloud. попробуй ещё раз, но если так и не получится, {ContactLink}."
}
diff --git a/src/localization/manager.js b/src/localization/manager.js
index 497c1bcb..2db07745 100644
--- a/src/localization/manager.js
+++ b/src/localization/manager.js
@@ -15,7 +15,7 @@ export function loadLoc() {
}
loadLoc();
export function replaceBase(s) {
- return s.replace(/\n/g, ' ').replace(/{appName}/g, appName).replace(/{repo}/g, repo)// .replace(/{discord}/g, socials.discord)
+ return s.replace(/\n/g, ' ').replace(/{appName}/g, appName).replace(/{repo}/g, repo).replace(/{bS}/g, '
').replace(/{bE}/g, '
').replace(/\*;/g, "•");
}
export function replaceAll(lang, str, string, replacement) {
let s = replaceBase(str[string])
diff --git a/src/modules/changelog/changelog.json b/src/modules/changelog/changelog.json
index 1fc86d2e..1394a638 100644
--- a/src/modules/changelog/changelog.json
+++ b/src/modules/changelog/changelog.json
@@ -1,15 +1,20 @@
{
"current": {
+ "version": "4.7",
+ "title": "we're better together! thank you for bug reports.",
+ "banner": "bettertogether.webp",
+ "content": "this update includes a bunch of improvements, many of which were made thanks to the community :D\n\nservice-related improvements:\n*; private soundcloud links are now supported (#68);\n*; tiktok usernames with dots in them no longer confuse cobalt (#71);\n*; .ogg files no longer wrongfully include a video channel (#67);\n*; fixed an issue that caused cobalt to freak out when user attempted to download an audio from audio-only service with \"mute video\" option enabled.\n\nui improvements:\n*; all buttons are now of even size and are displayed without any padding issues across all modern browsers and devices;\n*; checkbox is no longer crippled on ios;\n*; many explanation texts have been simplified to get rid of unnecessary bloat (no bullshit, remember?);\n*; moved tiktok section in video settings higher due to higher priority.\n\nstability improvements:\n*; fixed a memory leak that was caused by misconfigured stream information caching (#63).\n\ninternal improvements:\n*; requested streams are now stored in cache for 2 minutes instead of 1000 hours (yes, 1000 hours, i fucked up);\n*; cached data is now reused if user requests same content within 2 minutes;\n*; page render module is now even cleaner than before;\n*; proper support for bullet-points in loc strings.\n\nyou can suggest features or report bugs either on github or twitter.\nboth work just fine, use whichever you're more comfortable with.\n\nthank you for using cobalt, and thank you for reading this changelog.\n\nyou're amazing, keep it up :)"
+ },
+ "history": [{
"version": "4.6",
"title": "mute videos and proper soundcloud support",
"banner": "shutup.png",
- "content": "i've been longing to implement both of these things, and here they finally are.\n\nservice-related improvements:\n
• you now can download videos with no audio! simply enable the \"mute audio\" option in settings > audio.\n• soundcloud module has been updated, and downloads should no longer break after some time.
\nvisual improvements:\n
• moved some things around in settings popup, and added separators where separation is needed.\n• updated some texts in english and russian.\n• version and commit hash have been joined together, now they're a single unit.
\ninternal improvements:\n
• updated api documentation to include isAudioMuted.\n• simplified the startup message.\n• created render elements for separator and explanation due to high duplication of them in the page.\n• fully deprecated GET method for API requests.\n• fixed some code quirks.
\nhere's how soundcloud downloads got fixed:\n\npreviously, client_id was (stupidly) hardcoded. that means cobalt wasn't able to fetch song data if soundcloud web app got updated.\nnow, cobalt tries to find the up-to-date client_id, caches it in memory, and checks if web app version has changed to update the id accordingly. you can see this change for yourself on github."
- },
- "history": [{
+ "content": "i've been longing to implement both of these things, and here they finally are.\n\nservice-related improvements:\n{bS}*; you now can download videos with no audio! simply enable the \"mute audio\" option in settings > audio.\n*; soundcloud module has been updated, and downloads should no longer break after some time.{bE}\nvisual improvements:\n{bS}*; moved some things around in settings popup, and added separators where separation is needed.\n*; updated some texts in english and russian.\n*; version and commit hash have been joined together, now they're a single unit.{bE}\ninternal improvements:\n{bS}*; updated api documentation to include isAudioMuted.\n*; simplified the startup message.\n*; created render elements for separator and explanation due to high duplication of them in the page.\n*; fully deprecated GET method for API requests.\n*; fixed some code quirks.{bE}\nhere's how soundcloud downloads got fixed:\n\npreviously, client_id was (stupidly) hardcoded. that means cobalt wasn't able to fetch song data if soundcloud web app got updated.\nnow, cobalt tries to find the up-to-date client_id, caches it in memory, and checks if web app version has changed to update the id accordingly. you can see this change for yourself on github."
+ }, {
"version": "4.5",
"title": "better, faster, stronger, stable",
"banner": "meowthstrong.webp",
- "content": "your favorite social media downloader just got even better! this update includes a ton of imporvements and fixes.\n\nin fact, there are so many changes, i had to split them in sections.\n\nservice-related improvements:\n
• vimeo module has been revamped, all sorts of videos should now be supported.\n• vimeo audio downloads! you now can download audios from more recent videos.\n• {appName} now supports all sorts of tumblr links. (even those scary ones from the mobile app)\n• vk clips support has been fixed. they rolled back the separation of videos and clips, so i had to do the same.\n• youtube videos with community warnings should now be possible to download.
\nuser interface improvements:\n
• list of supported services is now MUCH easier to read.\n• banners in changelog history should no longer overlap each other.\n• bullet points! they have a bit of extra padding, so it makes them stand out of the rest of text.
\ninternal improvements:\n
• cobalt will now match the link to regex when using ?u= query for autopasting it into input area.\n• better rate limiting: limiting now is done per minute, not per 20 minutes. this ensures less waiting and less attack area for request spammers.\n• moved to my own fork of ytdl-core, cause main project seems to have been abandoned. go check it out on github or npm!\n• ALL user inputs are now properly sanitized on the server. that includes variables for POST api method, too.\n• \"got\" package has been (mostly) replaced by native fetch api. this should greately reduce ram usage.\n• all unnecessary duplications of module imports have been gotten rid of. no more error passing strings from inside of service modules. you don't make mistakes only if you don't do anything, right?\n• other code optimizations. there's less clutter overall.
\nhuge update, right? seems like everything's fixed now?\n\nnope, one issue still persists: sometimes youtube server drops packets for an audio file while cobalt's rendering the video for you. this results in abrupt cuts of audio. if you want to help solving this issue, please feel free to do it on github!\n\nthank you for reading this, and thank you for sticking with cobalt and me."
+ "content": "your favorite social media downloader just got even better! this update includes a ton of imporvements and fixes.\n\nin fact, there are so many changes, i had to split them in sections.\n\nservice-related improvements:\n{bS}*; vimeo module has been revamped, all sorts of videos should now be supported.\n*; vimeo audio downloads! you now can download audios from more recent videos.\n*; {appName} now supports all sorts of tumblr links. (even those scary ones from the mobile app)\n*; vk clips support has been fixed. they rolled back the separation of videos and clips, so i had to do the same.\n*; youtube videos with community warnings should now be possible to download.{bE}\nuser interface improvements:\n{bS}*; list of supported services is now MUCH easier to read.\n*; banners in changelog history should no longer overlap each other.\n*; bullet points! they have a bit of extra padding, so it makes them stand out of the rest of text.{bE}\ninternal improvements:\n{bS}*; cobalt will now match the link to regex when using ?u= query for autopasting it into input area.\n*; better rate limiting: limiting now is done per minute, not per 20 minutes. this ensures less waiting and less attack area for request spammers.\n*; moved to my own fork of ytdl-core, cause main project seems to have been abandoned. go check it out on github or npm!\n*; ALL user inputs are now properly sanitized on the server. that includes variables for POST api method, too.\n*; \"got\" package has been (mostly) replaced by native fetch api. this should greately reduce ram usage.\n*; all unnecessary duplications of module imports have been gotten rid of. no more error passing strings from inside of service modules. you don't make mistakes only if you don't do anything, right?\n*; other code optimizations. there's less clutter overall.{bE}\nhuge update, right? seems like everything's fixed now?\n\nnope, one issue still persists: sometimes youtube server drops packets for an audio file while cobalt's rendering the video for you. this results in abrupt cuts of audio. if you want to help solving this issue, please feel free to do it on github!\n\nthank you for reading this, and thank you for sticking with cobalt and me."
}, {
"version": "4.4",
"title": "over 1 million monthly requests. thank you.",
diff --git a/src/modules/pageRender/page.js b/src/modules/pageRender/page.js
index 938f3b0a..3616cbc9 100644
--- a/src/modules/pageRender/page.js
+++ b/src/modules/pageRender/page.js
@@ -27,11 +27,14 @@ for (let i in donations["crypto"]) {
donate += `