From a1fea0a5f10907c4d405674a6211276b9aaa756a Mon Sep 17 00:00:00 2001 From: wukko Date: Mon, 13 Feb 2023 20:30:57 +0600 Subject: [PATCH] fixes --- src/front/cobalt.js | 2 +- src/modules/processing/match.js | 2 +- src/modules/processing/services/reddit.js | 2 +- src/modules/processing/services/tiktok.js | 16 +++++++++------- src/modules/processing/services/vk.js | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/front/cobalt.js b/src/front/cobalt.js index 13333ae..0628d35 100644 --- a/src/front/cobalt.js +++ b/src/front/cobalt.js @@ -273,7 +273,7 @@ function toggle(toggl) { } function loadSettings() { try { - if (typeof(navigator.clipboard.readText) === undefined) throw new Error(); + if (typeof(navigator.clipboard.readText) == "undefined") throw new Error(); } catch (err) { eid("pasteFromClipboard").style.display = "none" } diff --git a/src/modules/processing/match.js b/src/modules/processing/match.js index c851697..3336bb4 100644 --- a/src/modules/processing/match.js +++ b/src/modules/processing/match.js @@ -1,5 +1,5 @@ import { apiJSON } from "../sub/utils.js"; -import { errorUnsupported, genericError } from "../sub/errors.js"; +import { errorUnsupported, genericError, brokenLink } from "../sub/errors.js"; import loc from "../../localization/manager.js"; diff --git a/src/modules/processing/services/reddit.js b/src/modules/processing/services/reddit.js index 30d51b7..816a8da 100644 --- a/src/modules/processing/services/reddit.js +++ b/src/modules/processing/services/reddit.js @@ -8,7 +8,7 @@ export default async function(obj) { if (data.url.endsWith('.gif')) return { typeId: 1, urls: data.url }; - if (!"reddit_video" in data["secure_media"]) return { error: 'ErrorEmptyDownload' }; + if (!("reddit_video" in data["secure_media"])) return { error: 'ErrorEmptyDownload' }; if (data["secure_media"]["reddit_video"]["duration"] * 1000 > maxVideoDuration) return { error: ['ErrorLengthLimit', maxVideoDuration / 60000] }; let video = data["secure_media"]["reddit_video"]["fallback_url"].split('?')[0], diff --git a/src/modules/processing/services/tiktok.js b/src/modules/processing/services/tiktok.js index ccd10f2..dac6fe4 100644 --- a/src/modules/processing/services/tiktok.js +++ b/src/modules/processing/services/tiktok.js @@ -28,7 +28,9 @@ function selector(j, h, id) { } export default async function(obj) { - if (!obj.postId) { + let postId = obj.postId ? obj.postId : false; + + if (!postId) { let html = await fetch(`${config[obj.host]["short"]}${obj.id}`, { redirect: "manual", headers: { "user-agent": userAgent } @@ -36,22 +38,22 @@ export default async function(obj) { if (!html) return { error: 'ErrorCouldntFetch' }; if (html.slice(0, 17) === ' { return r.json() }).catch(() => { return false }); - detail = selector(detail, obj.host, obj.postId); + detail = selector(detail, obj.host, postId); if (!detail) return { error: 'ErrorCouldntFetch' }; - let video, videoFilename, audioFilename, isMp3, audio, images, filenameBase = `${obj.host}_${obj.postId}`; + let video, videoFilename, audioFilename, isMp3, audio, images, filenameBase = `${obj.host}_${postId}`; if (obj.host === "tiktok") { images = detail["image_post_info"] ? detail["image_post_info"]["images"] : false } else { diff --git a/src/modules/processing/services/vk.js b/src/modules/processing/services/vk.js index c30d1e7..b7370af 100644 --- a/src/modules/processing/services/vk.js +++ b/src/modules/processing/services/vk.js @@ -36,7 +36,7 @@ export default async function(obj) { let maxQuality = js["player"]["params"][0][selectedQuality].split('type=')[1].slice(0, 1); let userQuality = selectQuality('vk', obj.quality, Object.entries(services.vk.quality_match).reduce((r, [k, v]) => { r[v] = k; return r; })[maxQuality]); let userRepr = repr[services.vk.representation_match[userQuality]]["_attributes"]; - if (!selectedQuality in js["player"]["params"][0]) return { error: 'ErrorEmptyDownload' }; + if (!(selectedQuality in js["player"]["params"][0])) return { error: 'ErrorEmptyDownload' }; return { urls: js["player"]["params"][0][`url${userQuality}`],