mirror of
https://github.com/imputnet/cobalt.git
synced 2025-07-16 18:28:29 +00:00
clean up all arrow function expressions
This commit is contained in:
parent
b56edfc193
commit
c766948811
@ -75,7 +75,7 @@ function changeDownloadButton(action, text) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
document.addEventListener("keydown", (event) => {
|
document.addEventListener("keydown", event => {
|
||||||
if (event.key === "Tab") {
|
if (event.key === "Tab") {
|
||||||
eid("download-button").value = '>>'
|
eid("download-button").value = '>>'
|
||||||
eid("download-button").style.padding = '0 1rem'
|
eid("download-button").style.padding = '0 1rem'
|
||||||
@ -381,7 +381,7 @@ async function download(url) {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify(req),
|
body: JSON.stringify(req),
|
||||||
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
|
headers: { 'Accept': 'application/json', 'Content-Type': 'application/json' }
|
||||||
}).then((r) => { return r.json() }).catch((e) => { return false });
|
}).then(r => r.json()).catch(() => false);
|
||||||
if (!j) {
|
if (!j) {
|
||||||
internetError();
|
internetError();
|
||||||
return
|
return
|
||||||
@ -414,7 +414,7 @@ async function download(url) {
|
|||||||
break;
|
break;
|
||||||
case "stream":
|
case "stream":
|
||||||
changeDownloadButton(2, '?..')
|
changeDownloadButton(2, '?..')
|
||||||
fetch(`${j.url}&p=1`).then(async (res) => {
|
fetch(`${j.url}&p=1`).then(async res => {
|
||||||
let jp = await res.json();
|
let jp = await res.json();
|
||||||
if (jp.status === "continue") {
|
if (jp.status === "continue") {
|
||||||
changeDownloadButton(2, '>>>');
|
changeDownloadButton(2, '>>>');
|
||||||
@ -425,7 +425,7 @@ async function download(url) {
|
|||||||
} else {
|
} else {
|
||||||
changeButton(0, jp.text);
|
changeButton(0, jp.text);
|
||||||
}
|
}
|
||||||
}).catch((error) => internetError());
|
}).catch(() => internetError());
|
||||||
break;
|
break;
|
||||||
case "success":
|
case "success":
|
||||||
changeButton(2, j.text);
|
changeButton(2, j.text);
|
||||||
@ -441,7 +441,7 @@ async function download(url) {
|
|||||||
async function loadCelebrationsEmoji() {
|
async function loadCelebrationsEmoji() {
|
||||||
let bac = eid("about-footer").innerHTML;
|
let bac = eid("about-footer").innerHTML;
|
||||||
try {
|
try {
|
||||||
let j = await fetch(`/onDemand?blockId=1`).then((r) => { if (r.status === 200) { return r.json() } else { return false } }).catch(() => { return false });
|
let j = await fetch(`/onDemand?blockId=1`).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
if (j && j.status === "success" && j.text) {
|
if (j && j.status === "success" && j.text) {
|
||||||
eid("about-footer").innerHTML = eid("about-footer").innerHTML.replace('<img class="emoji" draggable="false" height="22" width="22" alt="🐲" src="emoji/dragon_face.svg" loading="lazy">', j.text);
|
eid("about-footer").innerHTML = eid("about-footer").innerHTML.replace('<img class="emoji" draggable="false" height="22" width="22" alt="🐲" src="emoji/dragon_face.svg" loading="lazy">', j.text);
|
||||||
}
|
}
|
||||||
@ -458,7 +458,7 @@ async function loadOnDemand(elementId, blockId) {
|
|||||||
if (store.historyContent) {
|
if (store.historyContent) {
|
||||||
j = store.historyContent;
|
j = store.historyContent;
|
||||||
} else {
|
} else {
|
||||||
await fetch(`/onDemand?blockId=${blockId}`).then(async(r) => {
|
await fetch(`/onDemand?blockId=${blockId}`).then(async r => {
|
||||||
j = await r.json();
|
j = await r.json();
|
||||||
if (j && j.status === "success") {
|
if (j && j.status === "success") {
|
||||||
store.historyContent = j;
|
store.historyContent = j;
|
||||||
@ -497,13 +497,13 @@ window.onload = () => {
|
|||||||
button();
|
button();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eid("url-input-area").addEventListener("keydown", (e) => {
|
eid("url-input-area").addEventListener("keydown", () => {
|
||||||
button();
|
button();
|
||||||
})
|
})
|
||||||
eid("url-input-area").addEventListener("keyup", (e) => {
|
eid("url-input-area").addEventListener("keyup", e => {
|
||||||
if (e.key === 'Enter') eid("download-button").click();
|
if (e.key === 'Enter') eid("download-button").click();
|
||||||
})
|
})
|
||||||
document.onkeydown = (e) => {
|
document.onkeydown = e => {
|
||||||
if (!store.isPopupOpen) {
|
if (!store.isPopupOpen) {
|
||||||
if (e.ctrlKey || e.key === "/") eid("url-input-area").focus();
|
if (e.ctrlKey || e.key === "/") eid("url-input-area").focus();
|
||||||
if (e.key === "Escape" || e.key === "Clear") clearInput();
|
if (e.key === "Escape" || e.key === "Clear") clearInput();
|
||||||
|
@ -8,7 +8,7 @@ let loc = {}
|
|||||||
let languages = [];
|
let languages = [];
|
||||||
|
|
||||||
export async function loadLoc() {
|
export async function loadLoc() {
|
||||||
const files = await fs.promises.readdir(locPath).catch((e) => { return [] });
|
const files = await fs.promises.readdir(locPath).catch(() => { return [] });
|
||||||
files.forEach(file => {
|
files.forEach(file => {
|
||||||
loc[file.split('.')[0]] = loadJson(`${locPath}/${file}`);
|
loc[file.split('.')[0]] = loadJson(`${locPath}/${file}`);
|
||||||
languages.push(file.split('.')[0])
|
languages.push(file.split('.')[0])
|
||||||
|
@ -21,7 +21,7 @@ export default function(string) {
|
|||||||
case "content":
|
case "content":
|
||||||
return replaceBase(changelog["current"]["content"]);
|
return replaceBase(changelog["current"]["content"]);
|
||||||
case "history":
|
case "history":
|
||||||
return changelog["history"].map((i) => {
|
return changelog["history"].map(i => {
|
||||||
return {
|
return {
|
||||||
title: replaceBase(i["title"]),
|
title: replaceBase(i["title"]),
|
||||||
version: `<span class="text-backdrop changelog-tag-version">v.${i["version"]}</span>${
|
version: `<span class="text-backdrop changelog-tag-version">v.${i["version"]}</span>${
|
||||||
|
@ -13,7 +13,7 @@ let enabledServices = Object.keys(s).filter(p => s[p].enabled).sort().map((p) =>
|
|||||||
|
|
||||||
let donate = ``
|
let donate = ``
|
||||||
let donateLinks = ``
|
let donateLinks = ``
|
||||||
let audioFormats = supportedAudio.map((p) => {
|
let audioFormats = supportedAudio.map(p => {
|
||||||
return { "action": p }
|
return { "action": p }
|
||||||
})
|
})
|
||||||
audioFormats.unshift({ "action": "best" })
|
audioFormats.unshift({ "action": "best" })
|
||||||
|
@ -4,7 +4,7 @@ import { genericUserAgent, maxVideoDuration } from "../../config.js";
|
|||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let html = await fetch(`https://bilibili.com/video/${obj.id}`, {
|
let html = await fetch(`https://bilibili.com/video/${obj.id}`, {
|
||||||
headers: { "user-agent": genericUserAgent }
|
headers: { "user-agent": genericUserAgent }
|
||||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
}).then(r => r.text()).catch(() => false );
|
||||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||||
if (!(html.includes('<script>window.__playinfo__=') && html.includes('"video_codecid"'))) return { error: 'ErrorEmptyDownload' };
|
if (!(html.includes('<script>window.__playinfo__=') && html.includes('"video_codecid"'))) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ export default async function(obj) {
|
|||||||
field_set_key: "unauth_react_main_pin",
|
field_set_key: "unauth_react_main_pin",
|
||||||
id: pinId
|
id: pinId
|
||||||
}
|
}
|
||||||
}))}`).then((r) => { return r.json() }).catch(() => { return false });
|
}))}`).then(r => r.json()).catch(() => false );
|
||||||
if (!data) return { error: 'ErrorCouldntFetch' };
|
if (!data) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
data = data["resource_response"]["data"];
|
data = data["resource_response"]["data"];
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { maxVideoDuration } from "../../config.js";
|
import { maxVideoDuration } from "../../config.js";
|
||||||
|
|
||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let data = await fetch(`https://www.reddit.com/r/${obj.sub}/comments/${obj.id}/${obj.name}.json`).then((r) => { return r.json() }).catch(() => { return false });
|
let data = await fetch(`https://www.reddit.com/r/${obj.sub}/comments/${obj.id}/${obj.name}.json`).then(r => r.json()).catch(() => false);
|
||||||
if (!data) return { error: 'ErrorCouldntFetch' };
|
if (!data) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
data = data[0]["data"]["children"][0]["data"];
|
data = data[0]["data"]["children"][0]["data"];
|
||||||
@ -15,12 +15,12 @@ export default async function(obj) {
|
|||||||
video = data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0],
|
video = data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0],
|
||||||
audioFileLink = video.match('.mp4') ? `${video.split('_')[0]}_audio.mp4` : `${data["secure_media"]["reddit_video"]["fallback_url"].split('DASH')[0]}audio`;
|
audioFileLink = video.match('.mp4') ? `${video.split('_')[0]}_audio.mp4` : `${data["secure_media"]["reddit_video"]["fallback_url"].split('DASH')[0]}audio`;
|
||||||
|
|
||||||
await fetch(audioFileLink, { method: "HEAD" }).then((r) => { if (Number(r.status) === 200) audio = true }).catch(() => { audio = false });
|
audio = await fetch(audioFileLink, { method: "HEAD" }).then(r => (Number(r.status) === 200)).catch(() => false);
|
||||||
|
|
||||||
// fallback for videos with differentiating audio quality
|
// fallback for videos with differentiating audio quality
|
||||||
if (!audio) {
|
if (!audio) {
|
||||||
audioFileLink = `${video.split('_')[0]}_AUDIO_128.mp4`
|
audioFileLink = `${video.split('_')[0]}_AUDIO_128.mp4`;
|
||||||
await fetch(audioFileLink, { method: "HEAD" }).then((r) => { if (Number(r.status) === 200) audio = true }).catch(() => { audio = false });
|
audio = await fetch(audioFileLink, { method: "HEAD" }).then(r => (Number(r.status) === 200)).catch(() => false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let id = video.split('/')[3];
|
let id = video.split('/')[3];
|
||||||
|
@ -5,7 +5,7 @@ let cachedID = {};
|
|||||||
|
|
||||||
async function findClientID() {
|
async function findClientID() {
|
||||||
try {
|
try {
|
||||||
let sc = await fetch('https://soundcloud.com/').then((r) => { return r.text() }).catch(() => { return false });
|
let sc = await fetch('https://soundcloud.com/').then(r => r.text()).catch(() => false);
|
||||||
let scVersion = String(sc.match(/<script>window\.__sc_version="[0-9]{10}"<\/script>/)[0].match(/[0-9]{10}/));
|
let scVersion = String(sc.match(/<script>window\.__sc_version="[0-9]{10}"<\/script>/)[0].match(/[0-9]{10}/));
|
||||||
|
|
||||||
if (cachedID.version === scVersion) return cachedID.id;
|
if (cachedID.version === scVersion) return cachedID.id;
|
||||||
@ -17,7 +17,7 @@ async function findClientID() {
|
|||||||
|
|
||||||
if (url && !url.startsWith('https://a-v2.sndcdn.com')) return;
|
if (url && !url.startsWith('https://a-v2.sndcdn.com')) return;
|
||||||
|
|
||||||
let scrf = await fetch(url).then((r) => {return r.text()}).catch(() => { return false });
|
let scrf = await fetch(url).then(r => r.text()).catch(() => false);
|
||||||
let id = scrf.match(/\("client_id=[A-Za-z0-9]{32}"\)/);
|
let id = scrf.match(/\("client_id=[A-Za-z0-9]{32}"\)/);
|
||||||
|
|
||||||
if (id && typeof id[0] === 'string') {
|
if (id && typeof id[0] === 'string') {
|
||||||
@ -40,21 +40,21 @@ export default async function(obj) {
|
|||||||
|
|
||||||
let link;
|
let link;
|
||||||
if (obj.shortLink && !obj.author && !obj.song) {
|
if (obj.shortLink && !obj.author && !obj.song) {
|
||||||
link = await fetch(`https://on.soundcloud.com/${obj.shortLink}/`, { redirect: "manual" }).then((r) => {
|
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/")) {
|
if (r.status === 302 && r.headers.get("location").startsWith("https://soundcloud.com/")) {
|
||||||
return r.headers.get("location").split('?', 1)[0]
|
return r.headers.get("location").split('?', 1)[0]
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}).catch(() => { return false });
|
}).catch(() => false);
|
||||||
}
|
}
|
||||||
if (!link && obj.author && obj.song) {
|
if (!link && obj.author && obj.song) {
|
||||||
link = `https://soundcloud.com/${obj.author}/${obj.song}${obj.accessKey ? `/s-${obj.accessKey}` : ''}`
|
link = `https://soundcloud.com/${obj.author}/${obj.song}${obj.accessKey ? `/s-${obj.accessKey}` : ''}`
|
||||||
}
|
}
|
||||||
if (!link) return { error: 'ErrorCouldntFetch' };
|
if (!link) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
let json = await fetch(`https://api-v2.soundcloud.com/resolve?url=${link}&client_id=${clientId}`).then((r) => {
|
let json = await fetch(`https://api-v2.soundcloud.com/resolve?url=${link}&client_id=${clientId}`).then(r =>
|
||||||
return r.status === 200 ? r.json() : false
|
r.status === 200 ? r.json() : false
|
||||||
}).catch(() => { return false });
|
).catch(() => false);
|
||||||
if (!json) return { error: 'ErrorCouldntFetch' };
|
if (!json) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
|
if (!json["media"]["transcodings"]) return { error: 'ErrorEmptyDownload' };
|
||||||
@ -66,7 +66,7 @@ export default async function(obj) {
|
|||||||
|
|
||||||
if (json.duration > maxVideoDuration) return { error: ['ErrorLengthAudioConvert', maxVideoDuration / 60000] };
|
if (json.duration > maxVideoDuration) return { error: ['ErrorLengthAudioConvert', maxVideoDuration / 60000] };
|
||||||
|
|
||||||
let file = await fetch(fileUrl).then(async (r) => { return (await r.json()).url }).catch(() => { return false });
|
let file = await fetch(fileUrl).then(async r => (await r.json()).url).catch(() => false);
|
||||||
if (!file) return { error: 'ErrorCouldntFetch' };
|
if (!file) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let video = await fetch(`https://api.streamable.com/videos/${obj.id}`).then((r) => { return r.status === 200 ? r.json() : false }).catch(() => { return false });
|
let video = await fetch(`https://api.streamable.com/videos/${obj.id}`).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
if (!video) return { error: 'ErrorEmptyDownload' };
|
if (!video) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
let best = video.files['mp4-mobile'];
|
let best = video.files['mp4-mobile'];
|
||||||
|
@ -34,7 +34,7 @@ export default async function(obj) {
|
|||||||
let html = await fetch(`${config[obj.host]["short"]}${obj.id}`, {
|
let html = await fetch(`${config[obj.host]["short"]}${obj.id}`, {
|
||||||
redirect: "manual",
|
redirect: "manual",
|
||||||
headers: { "user-agent": userAgent }
|
headers: { "user-agent": userAgent }
|
||||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
}).then(r => r.text()).catch(() => false);
|
||||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
if (html.slice(0, 17) === '<a href="https://' && html.includes('/video/')) {
|
if (html.slice(0, 17) === '<a href="https://' && html.includes('/video/')) {
|
||||||
@ -48,7 +48,7 @@ export default async function(obj) {
|
|||||||
let detail;
|
let detail;
|
||||||
detail = await fetch(config[obj.host]["api"].replace("{postId}", postId), {
|
detail = await fetch(config[obj.host]["api"].replace("{postId}", postId), {
|
||||||
headers: {"user-agent": "TikTok 26.2.0 rv:262018 (iPhone; iOS 14.4.2; en_US) Cronet"}
|
headers: {"user-agent": "TikTok 26.2.0 rv:262018 (iPhone; iOS 14.4.2; en_US) Cronet"}
|
||||||
}).then((r) => { return r.json() }).catch(() => { return false });
|
}).then(r => r.json()).catch(() => false);
|
||||||
|
|
||||||
detail = selector(detail, obj.host, postId);
|
detail = selector(detail, obj.host, postId);
|
||||||
if (!detail) return { error: 'ErrorCouldntFetch' };
|
if (!detail) return { error: 'ErrorCouldntFetch' };
|
||||||
|
@ -5,7 +5,7 @@ export default async function(obj) {
|
|||||||
obj.user ? obj.user : obj.url.split('.')[0].replace('https://', '')
|
obj.user ? obj.user : obj.url.split('.')[0].replace('https://', '')
|
||||||
}.tumblr.com/post/${obj.id}`, {
|
}.tumblr.com/post/${obj.id}`, {
|
||||||
headers: { "user-agent": genericUserAgent }
|
headers: { "user-agent": genericUserAgent }
|
||||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
}).then(r => r.text()).catch(() => false);
|
||||||
|
|
||||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ export default async function(obj) {
|
|||||||
let req_act = await fetch(activateURL, {
|
let req_act = await fetch(activateURL, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: _headers
|
headers: _headers
|
||||||
}).then((r) => { return r.status === 200 ? r.json() : false }).catch(() => { return false });
|
}).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
if (!req_act) return { error: 'ErrorCouldntFetch' };
|
if (!req_act) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
_headers["host"] = "twitter.com";
|
_headers["host"] = "twitter.com";
|
||||||
@ -39,7 +39,7 @@ export default async function(obj) {
|
|||||||
query.features = new URLSearchParams(JSON.stringify(query.features)).toString().slice(0, -1);
|
query.features = new URLSearchParams(JSON.stringify(query.features)).toString().slice(0, -1);
|
||||||
query = `${graphqlTweetURL}?variables=${query.variables}&features=${query.features}`;
|
query = `${graphqlTweetURL}?variables=${query.variables}&features=${query.features}`;
|
||||||
|
|
||||||
let TweetResultByRestId = await fetch(query, { headers: _headers }).then((r) => { return r.status === 200 ? r.json() : false }).catch((e) => { return false });
|
let TweetResultByRestId = await fetch(query, { headers: _headers }).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
|
|
||||||
// {"data":{"tweetResult":{"result":{"__typename":"TweetUnavailable","reason":"Protected"}}}}
|
// {"data":{"tweetResult":{"result":{"__typename":"TweetUnavailable","reason":"Protected"}}}}
|
||||||
if (!TweetResultByRestId || TweetResultByRestId.data.tweetResult.result.__typename !== "Tweet") return { error: 'ErrorTweetUnavailable' };
|
if (!TweetResultByRestId || TweetResultByRestId.data.tweetResult.result.__typename !== "Tweet") return { error: 'ErrorTweetUnavailable' };
|
||||||
@ -55,7 +55,7 @@ export default async function(obj) {
|
|||||||
if (!baseMedia) return { error: 'ErrorNoVideosInTweet' };
|
if (!baseMedia) return { error: 'ErrorNoVideosInTweet' };
|
||||||
|
|
||||||
let single, multiple = [], media = baseMedia["media"];
|
let single, multiple = [], media = baseMedia["media"];
|
||||||
media = media.filter((i) => { if (i["type"] === "video" || i["type"] === "animated_gif") return true });
|
media = media.filter(i => (i["type"] === "video" || i["type"] === "animated_gif"));
|
||||||
|
|
||||||
if (media.length > 1) {
|
if (media.length > 1) {
|
||||||
for (let i in media) { multiple.push({type: "video", thumb: media[i]["media_url_https"], url: bestQuality(media[i]["video_info"]["variants"])}) }
|
for (let i in media) { multiple.push({type: "video", thumb: media[i]["media_url_https"], url: bestQuality(media[i]["video_info"]["variants"])}) }
|
||||||
@ -86,7 +86,7 @@ export default async function(obj) {
|
|||||||
query.features = new URLSearchParams(JSON.stringify(query.features)).toString().slice(0, -1);
|
query.features = new URLSearchParams(JSON.stringify(query.features)).toString().slice(0, -1);
|
||||||
query = `${graphqlSpaceURL}?variables=${query.variables}&features=${query.features}`;
|
query = `${graphqlSpaceURL}?variables=${query.variables}&features=${query.features}`;
|
||||||
|
|
||||||
let AudioSpaceById = await fetch(query, { headers: _headers }).then((r) => {return r.status === 200 ? r.json() : false}).catch((e) => { return false });
|
let AudioSpaceById = await fetch(query, { headers: _headers }).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
if (!AudioSpaceById) return { error: 'ErrorEmptyDownload' };
|
if (!AudioSpaceById) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
if (!AudioSpaceById.data.audioSpace.metadata) return { error: 'ErrorEmptyDownload' };
|
if (!AudioSpaceById.data.audioSpace.metadata) return { error: 'ErrorEmptyDownload' };
|
||||||
@ -94,7 +94,7 @@ export default async function(obj) {
|
|||||||
|
|
||||||
let streamStatus = await fetch(
|
let streamStatus = await fetch(
|
||||||
`https://twitter.com/i/api/1.1/live_video_stream/status/${AudioSpaceById.data.audioSpace.metadata.media_key}`, { headers: _headers }
|
`https://twitter.com/i/api/1.1/live_video_stream/status/${AudioSpaceById.data.audioSpace.metadata.media_key}`, { headers: _headers }
|
||||||
).then((r) =>{ return r.status === 200 ? r.json() : false }).catch(() => { return false });
|
).then(r => r.status === 200 ? r.json() : false).catch(() => false);
|
||||||
if (!streamStatus) return { error: 'ErrorCouldntFetch' };
|
if (!streamStatus) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
let participants = AudioSpaceById.data.audioSpace.participants.speakers,
|
let participants = AudioSpaceById.data.audioSpace.participants.speakers,
|
||||||
|
@ -27,7 +27,7 @@ export default async function(obj) {
|
|||||||
let quality = obj.quality === "max" ? "9000" : obj.quality;
|
let quality = obj.quality === "max" ? "9000" : obj.quality;
|
||||||
if (!quality || obj.isAudioOnly) quality = "9000";
|
if (!quality || obj.isAudioOnly) quality = "9000";
|
||||||
|
|
||||||
let api = await fetch(`https://player.vimeo.com/video/${obj.id}/config`).then((r) => { return r.json() }).catch(() => { return false });
|
let api = await fetch(`https://player.vimeo.com/video/${obj.id}/config`).then(r => r.json()).catch(() => false);
|
||||||
if (!api) return { error: 'ErrorCouldntFetch' };
|
if (!api) return { error: 'ErrorCouldntFetch' };
|
||||||
|
|
||||||
let downloadType = "dash";
|
let downloadType = "dash";
|
||||||
@ -49,7 +49,7 @@ export default async function(obj) {
|
|||||||
if (api.video.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
if (api.video.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
||||||
|
|
||||||
let masterJSONURL = api["request"]["files"]["dash"]["cdns"]["akfire_interconnect_quic"]["url"];
|
let masterJSONURL = api["request"]["files"]["dash"]["cdns"]["akfire_interconnect_quic"]["url"];
|
||||||
let masterJSON = await fetch(masterJSONURL).then((r) => { return r.json() }).catch(() => { return false });
|
let masterJSON = await fetch(masterJSONURL).then(r => r.json()).catch(() => false);
|
||||||
|
|
||||||
if (!masterJSON) return { error: 'ErrorCouldntFetch' };
|
if (!masterJSON) return { error: 'ErrorCouldntFetch' };
|
||||||
if (!masterJSON.video) return { error: 'ErrorEmptyDownload' };
|
if (!masterJSON.video) return { error: 'ErrorEmptyDownload' };
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export default async function(obj) {
|
export default async function(obj) {
|
||||||
let post = await fetch(`https://archive.vine.co/posts/${obj.id}.json`).then((r) => { return r.json() }).catch(() => { return false });
|
let post = await fetch(`https://archive.vine.co/posts/${obj.id}.json`).then(r => r.json()).catch(() => false);
|
||||||
if (!post) return { error: 'ErrorEmptyDownload' };
|
if (!post) return { error: 'ErrorEmptyDownload' };
|
||||||
|
|
||||||
if (post.videoUrl) return { urls: post.videoUrl.replace("http://", "https://"), filename: `vine_${obj.id}.mp4`, audioFilename: `vine_${obj.id}_audio` };
|
if (post.videoUrl) return { urls: post.videoUrl.replace("http://", "https://"), filename: `vine_${obj.id}.mp4`, audioFilename: `vine_${obj.id}_audio` };
|
||||||
|
@ -9,7 +9,7 @@ export default async function(o) {
|
|||||||
|
|
||||||
html = await fetch(`https://vk.com/video${o.userId}_${o.videoId}`, {
|
html = await fetch(`https://vk.com/video${o.userId}_${o.videoId}`, {
|
||||||
headers: { "user-agent": genericUserAgent }
|
headers: { "user-agent": genericUserAgent }
|
||||||
}).then((r) => { return r.text() }).catch(() => { return false });
|
}).then(r => r.text()).catch(() => false);
|
||||||
|
|
||||||
if (!html) return { error: 'ErrorCouldntFetch' };
|
if (!html) return { error: 'ErrorCouldntFetch' };
|
||||||
if (!html.includes(`{"lang":`)) return { error: 'ErrorEmptyDownload' };
|
if (!html.includes(`{"lang":`)) return { error: 'ErrorEmptyDownload' };
|
||||||
|
@ -50,7 +50,7 @@ export default async function(o) {
|
|||||||
if (!bestQuality && !o.isAudioOnly || !hasAudio) return { error: 'ErrorYTTryOtherCodec' };
|
if (!bestQuality && !o.isAudioOnly || !hasAudio) return { error: 'ErrorYTTryOtherCodec' };
|
||||||
if (info.basic_info.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
if (info.basic_info.duration > maxVideoDuration / 1000) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] };
|
||||||
|
|
||||||
let checkBestAudio = (i) => (i["has_audio"] && !i["has_video"]),
|
let checkBestAudio = i => (i["has_audio"] && !i["has_video"]),
|
||||||
audio = adaptive_formats.find(i => checkBestAudio(i) && !i["is_dubbed"]);
|
audio = adaptive_formats.find(i => checkBestAudio(i) && !i["is_dubbed"]);
|
||||||
|
|
||||||
if (o.dubLang) {
|
if (o.dubLang) {
|
||||||
@ -81,9 +81,9 @@ export default async function(o) {
|
|||||||
audioFilename: `youtube_${o.id}_audio${isDubbed ? `_${o.dubLang}`:''}`,
|
audioFilename: `youtube_${o.id}_audio${isDubbed ? `_${o.dubLang}`:''}`,
|
||||||
fileMetadata: fileMetadata
|
fileMetadata: fileMetadata
|
||||||
}
|
}
|
||||||
let checkSingle = (i) => ((qual(i) === quality || qual(i) === bestQuality) && i["mime_type"].includes(c[o.format].codec)),
|
let checkSingle = i => ((qual(i) === quality || qual(i) === bestQuality) && i["mime_type"].includes(c[o.format].codec)),
|
||||||
checkBestVideo = (i) => (i["has_video"] && !i["has_audio"] && qual(i) === bestQuality),
|
checkBestVideo = i => (i["has_video"] && !i["has_audio"] && qual(i) === bestQuality),
|
||||||
checkRightVideo = (i) => (i["has_video"] && !i["has_audio"] && qual(i) === quality);
|
checkRightVideo = i => (i["has_video"] && !i["has_audio"] && qual(i) === quality);
|
||||||
|
|
||||||
if (!o.isAudioOnly && !o.isAudioMuted && o.format === 'h264') {
|
if (!o.isAudioOnly && !o.isAudioMuted && o.format === 'h264') {
|
||||||
let single = info.streaming_data.formats.find(i => checkSingle(i));
|
let single = info.streaming_data.formats.find(i => checkSingle(i));
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
export const testers = {
|
export const testers = {
|
||||||
"twitter": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length < 20)
|
"twitter": patternMatch => (patternMatch["id"] && patternMatch["id"].length < 20)
|
||||||
|| (patternMatch["spaceId"] && patternMatch["spaceId"].length === 13),
|
|| (patternMatch["spaceId"] && patternMatch["spaceId"].length === 13),
|
||||||
|
|
||||||
"vk": (patternMatch) => (patternMatch["userId"] && patternMatch["videoId"]
|
"vk": patternMatch => (patternMatch["userId"] && patternMatch["videoId"]
|
||||||
&& patternMatch["userId"].length <= 10 && patternMatch["videoId"].length <= 10),
|
&& patternMatch["userId"].length <= 10 && patternMatch["videoId"].length <= 10),
|
||||||
|
|
||||||
"bilibili": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
"bilibili": patternMatch => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
||||||
|
|
||||||
"youtube": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 11),
|
"youtube": patternMatch => (patternMatch["id"] && patternMatch["id"].length <= 11),
|
||||||
|
|
||||||
"reddit": (patternMatch) => (patternMatch["sub"] && patternMatch["id"] && patternMatch["title"]
|
"reddit": patternMatch => (patternMatch["sub"] && patternMatch["id"] && patternMatch["title"]
|
||||||
&& patternMatch["sub"].length <= 22 && patternMatch["id"].length <= 10 && patternMatch["title"].length <= 96),
|
&& patternMatch["sub"].length <= 22 && patternMatch["id"].length <= 10 && patternMatch["title"].length <= 96),
|
||||||
|
|
||||||
"tiktok": (patternMatch) => ((patternMatch["user"] && patternMatch["postId"] && patternMatch["postId"].length <= 21)
|
"tiktok": patternMatch => ((patternMatch["user"] && patternMatch["postId"] && patternMatch["postId"].length <= 21)
|
||||||
|| (patternMatch["id"] && patternMatch["id"].length <= 13)),
|
|| (patternMatch["id"] && patternMatch["id"].length <= 13)),
|
||||||
|
|
||||||
"douyin": (patternMatch) => ((patternMatch["postId"] && patternMatch["postId"].length <= 21)
|
"douyin": patternMatch => ((patternMatch["postId"] && patternMatch["postId"].length <= 21)
|
||||||
|| (patternMatch["id"] && patternMatch["id"].length <= 13)),
|
|| (patternMatch["id"] && patternMatch["id"].length <= 13)),
|
||||||
|
|
||||||
"tumblr": (patternMatch) => ((patternMatch["id"] && patternMatch["id"].length < 21)
|
"tumblr": patternMatch => ((patternMatch["id"] && patternMatch["id"].length < 21)
|
||||||
|| (patternMatch["id"] && patternMatch["id"].length < 21 && patternMatch["user"] && patternMatch["user"].length <= 32)),
|
|| (patternMatch["id"] && patternMatch["id"].length < 21 && patternMatch["user"] && patternMatch["user"].length <= 32)),
|
||||||
|
|
||||||
"vimeo": (patternMatch) => ((patternMatch["id"] && patternMatch["id"].length <= 11)),
|
"vimeo": patternMatch => ((patternMatch["id"] && patternMatch["id"].length <= 11)),
|
||||||
|
|
||||||
"soundcloud": (patternMatch) => (patternMatch["author"]?.length <= 25 && patternMatch["song"]?.length <= 255)
|
"soundcloud": patternMatch => (patternMatch["author"]?.length <= 25 && patternMatch["song"]?.length <= 255)
|
||||||
|| (patternMatch["shortLink"] && patternMatch["shortLink"].length <= 32),
|
|| (patternMatch["shortLink"] && patternMatch["shortLink"].length <= 32),
|
||||||
|
|
||||||
"instagram": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
"instagram": patternMatch => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
||||||
|
|
||||||
"vine": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
"vine": patternMatch => (patternMatch["id"] && patternMatch["id"].length <= 12),
|
||||||
|
|
||||||
"pinterest": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length <= 128),
|
"pinterest": patternMatch => (patternMatch["id"] && patternMatch["id"].length <= 128),
|
||||||
|
|
||||||
"streamable": (patternMatch) => (patternMatch["id"] && patternMatch["id"].length === 6)
|
"streamable": patternMatch => (patternMatch["id"] && patternMatch["id"].length === 6)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import { streamLifespan } from "../config.js";
|
|||||||
const streamCache = new NodeCache({ stdTTL: streamLifespan/1000, checkperiod: 10, deleteOnExpire: true });
|
const streamCache = new NodeCache({ stdTTL: streamLifespan/1000, checkperiod: 10, deleteOnExpire: true });
|
||||||
const streamSalt = randomBytes(64).toString('hex');
|
const streamSalt = randomBytes(64).toString('hex');
|
||||||
|
|
||||||
streamCache.on("expired", (key) => {
|
streamCache.on("expired", key => {
|
||||||
streamCache.del(key);
|
streamCache.del(key);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ export function languageCode(req) {
|
|||||||
return req.header('Accept-Language') ? verifyLanguageCode(req.header('Accept-Language')) : "en"
|
return req.header('Accept-Language') ? verifyLanguageCode(req.header('Accept-Language')) : "en"
|
||||||
}
|
}
|
||||||
export function unicodeDecode(str) {
|
export function unicodeDecode(str) {
|
||||||
return str.replace(/\\u[\dA-F]{4}/gi, (unicode) => {
|
return str.replace(/\\u[\dA-F]{4}/gi, unicode => {
|
||||||
return String.fromCharCode(parseInt(unicode.replace(/\\u/g, ""), 16));
|
return String.fromCharCode(parseInt(unicode.replace(/\\u/g, ""), 16));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user