diff --git a/package.json b/package.json
index 48e987d6..034ca7aa 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "cobalt",
"description": "save what you love",
- "version": "7.1.1",
+ "version": "7.1.2",
"author": "wukko",
"exports": "./src/cobalt.js",
"type": "module",
diff --git a/src/modules/pageRender/page.js b/src/modules/pageRender/page.js
index 69aba62a..67a93168 100644
--- a/src/modules/pageRender/page.js
+++ b/src/modules/pageRender/page.js
@@ -9,9 +9,7 @@ let com = getCommitInfo();
let defaultApiURL = process.env.apiURL ? process.env.apiURL.slice(0, -1) : '';
-let enabledServices = Object.keys(s).filter((p) => {
- if (s[p].enabled) return true;
-}).sort().map((p) => {
+let enabledServices = Object.keys(s).filter(p => s[p].enabled).sort().map((p) => {
return `
• ${s[p].alias ? s[p].alias : p}`
}).join('').substring(4)
diff --git a/src/modules/processing/hostOverrides.js b/src/modules/processing/hostOverrides.js
index 7fc7b67f..211cd2af 100644
--- a/src/modules/processing/hostOverrides.js
+++ b/src/modules/processing/hostOverrides.js
@@ -9,12 +9,6 @@ export default function (inHost, inURL) {
url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`;
}
break;
- case "goo":
- if (url.startsWith("https://soundcloud.app.goo.gl/")) {
- host = "soundcloud";
- url = `https://soundcloud.com/${url.replace("https://soundcloud.app.goo.gl/", "").split('/')[0]}`
- }
- break;
case "vxtwitter":
case "x":
if (url.startsWith("https://x.com/")) {
@@ -33,7 +27,6 @@ export default function (inHost, inURL) {
}
break;
}
-
return {
host: host,
url: url
diff --git a/src/modules/processing/services/bilibili.js b/src/modules/processing/services/bilibili.js
index b9690aad..0194ee46 100644
--- a/src/modules/processing/services/bilibili.js
+++ b/src/modules/processing/services/bilibili.js
@@ -11,13 +11,13 @@ export default async function(obj) {
let streamData = JSON.parse(html.split('')[0]);
if (streamData.data.timelength > maxVideoDuration) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
- let video = streamData["data"]["dash"]["video"].filter((v) => {
- if (!v["baseUrl"].includes("https://upos-sz-mirrorcosov.bilivideo.com/")) return true;
- }).sort((a, b) => Number(b.bandwidth) - Number(a.bandwidth));
+ let video = streamData["data"]["dash"]["video"].filter(v =>
+ !v["baseUrl"].includes("https://upos-sz-mirrorcosov.bilivideo.com/")
+ ).sort((a, b) => Number(b.bandwidth) - Number(a.bandwidth));
- let audio = streamData["data"]["dash"]["audio"].filter((a) => {
- if (!a["baseUrl"].includes("https://upos-sz-mirrorcosov.bilivideo.com/")) return true;
- }).sort((a, b) => Number(b.bandwidth) - Number(a.bandwidth));
+ let audio = streamData["data"]["dash"]["audio"].filter(a =>
+ !a["baseUrl"].includes("https://upos-sz-mirrorcosov.bilivideo.com/")
+ ).sort((a, b) => Number(b.bandwidth) - Number(a.bandwidth));
return {
urls: [video[0]["baseUrl"], audio[0]["baseUrl"]],
diff --git a/src/modules/processing/services/soundcloud.js b/src/modules/processing/services/soundcloud.js
index 2edaad22..99c812e1 100644
--- a/src/modules/processing/services/soundcloud.js
+++ b/src/modules/processing/services/soundcloud.js
@@ -35,31 +35,31 @@ async function findClientID() {
}
export default async function(obj) {
- let html;
- if (!obj.author && !obj.song && obj.shortLink) {
- 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 });
- }
- if (!html) return { error: 'ErrorCouldntFetch' };
- if (!(html.includes('')[0]);
- if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
-
let clientId = await findClientID();
if (!clientId) return { error: 'ErrorSoundCloudNoClientId' };
- let fileUrlBase = json.media.transcodings.filter((v) => { if (v["format"]["mime_type"].startsWith("audio/ogg")) return true })[0]["url"],
+ let link;
+ if (obj.shortLink && !obj.author && !obj.song) {
+ link = await fetch(`https://on.soundcloud.com/${obj.shortLink}/`, { redirect: "manual" }).then((r) => {
+ if (r.status === 302 && r.headers.get("location").startsWith("https://soundcloud.com/")) {
+ return r.headers.get("location").split('?', 1)[0]
+ }
+ return false
+ }).catch(() => { return false });
+ }
+ if (!link && obj.author && obj.song) {
+ link = `https://soundcloud.com/${obj.author}/${obj.song}${obj.accessKey ? `/s-${obj.accessKey}` : ''}`
+ }
+ if (!link) return { error: 'ErrorCouldntFetch' };
+
+ let json = await fetch(`https://api-v2.soundcloud.com/resolve?url=${link}&client_id=${clientId}`).then((r) => {
+ return r.status === 200 ? r.json() : false
+ }).catch(() => { return false });
+ if (!json) return { error: 'ErrorCouldntFetch' };
+
+ if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
+
+ let fileUrlBase = json.media.transcodings.filter(v => v.preset === "opus_0_0")[0]["url"],
fileUrl = `${fileUrlBase}${fileUrlBase.includes("?") ? "&" : "?"}client_id=${clientId}&track_authorization=${json.track_authorization}`;
if (fileUrl.substring(0, 54) !== "https://api-v2.soundcloud.com/media/soundcloud:tracks:") return { error: 'ErrorEmptyDownload' };
diff --git a/src/modules/processing/services/tiktok.js b/src/modules/processing/services/tiktok.js
index 05a9c8d5..bd925b56 100644
--- a/src/modules/processing/services/tiktok.js
+++ b/src/modules/processing/services/tiktok.js
@@ -17,7 +17,7 @@ function selector(j, h, id) {
let t;
switch (h) {
case "tiktok":
- t = j["aweme_list"].filter((v) => { if (v["aweme_id"] === id) return true })[0];
+ t = j["aweme_list"].filter(v => v["aweme_id"] === id)[0];
break;
case "douyin":
t = j['aweme_detail'];
@@ -92,7 +92,7 @@ export default async function(obj) {
let imageLinks = [];
for (let i in images) {
let sel = obj.host === "tiktok" ? images[i]["display_image"]["url_list"] : images[i]["url_list"];
- sel = sel.filter((p) => { if (p.includes(".jpeg?")) return true; })
+ sel = sel.filter(p => p.includes(".jpeg?"))
imageLinks.push({url: sel[0]})
}
return {
diff --git a/src/modules/processing/services/twitter.js b/src/modules/processing/services/twitter.js
index 189a0c88..487032a8 100644
--- a/src/modules/processing/services/twitter.js
+++ b/src/modules/processing/services/twitter.js
@@ -1,7 +1,7 @@
import { genericUserAgent } from "../../config.js";
function bestQuality(arr) {
- return arr.filter((v) => { if (v["content_type"] === "video/mp4") return true }).sort((a, b) => Number(b.bitrate) - Number(a.bitrate))[0]["url"]
+ return arr.filter(v => v["content_type"] === "video/mp4").sort((a, b) => Number(b.bitrate) - Number(a.bitrate))[0]["url"]
}
export default async function(obj) {
diff --git a/src/modules/processing/services/vimeo.js b/src/modules/processing/services/vimeo.js
index a1c951a5..3765b64e 100644
--- a/src/modules/processing/services/vimeo.js
+++ b/src/modules/processing/services/vimeo.js
@@ -64,7 +64,7 @@ export default async function(obj) {
let videoUrl, audioUrl, baseUrl = masterJSONURL.split("/sep/")[0];
switch (type) {
case "parcel":
- let masterJSON_Audio = masterJSON.audio.sort((a, b) => Number(b.bitrate) - Number(a.bitrate)).filter((a) => { if (a['mime_type'] === "audio/mp4") return true }),
+ let masterJSON_Audio = masterJSON.audio.sort((a, b) => Number(b.bitrate) - Number(a.bitrate)).filter(a => a['mime_type'] === "audio/mp4"),
bestAudio = masterJSON_Audio[0];
videoUrl = `${baseUrl}/parcel/video/${bestVideo.index_segment.split('?')[0]}`,
audioUrl = `${baseUrl}/parcel/audio/${bestAudio.index_segment.split('?')[0]}`;
diff --git a/src/modules/processing/services/youtube.js b/src/modules/processing/services/youtube.js
index a8beca06..38da4103 100644
--- a/src/modules/processing/services/youtube.js
+++ b/src/modules/processing/services/youtube.js
@@ -39,9 +39,9 @@ export default async function(o) {
if (info.playability_status.status !== 'OK') return { error: 'ErrorYTUnavailable' };
if (info.basic_info.is_live) return { error: 'ErrorLiveVideo' };
- let bestQuality, hasAudio, adaptive_formats = info.streaming_data.adaptive_formats.filter((e) => {
- if (e["mime_type"].includes(c[o.format].codec) || e["mime_type"].includes(c[o.format].aCodec)) return true
- }).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
+ let bestQuality, hasAudio, adaptive_formats = info.streaming_data.adaptive_formats.filter(e =>
+ e["mime_type"].includes(c[o.format].codec) || e["mime_type"].includes(c[o.format].aCodec)
+ ).sort((a, b) => Number(b.bitrate) - Number(a.bitrate));
bestQuality = adaptive_formats.find(i => i["has_video"]);
hasAudio = adaptive_formats.find(i => i["has_audio"]);