fixes
This commit is contained in:
parent
20ae9acfe8
commit
a1fea0a5f1
5 changed files with 13 additions and 11 deletions
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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) === '<a href="https://' && html.includes('/video/')) {
|
||||
obj.postId = html.split('/video/')[1].split('?')[0].replace("/", '')
|
||||
postId = html.split('/video/')[1].split('?')[0].replace("/", '')
|
||||
} else if (html.slice(0, 32) === '<a href="https://m.tiktok.com/v/' && html.includes('/v/')) {
|
||||
obj.postId = html.split('/v/')[1].split('.html')[0].replace("/", '')
|
||||
postId = html.split('/v/')[1].split('.html')[0].replace("/", '')
|
||||
}
|
||||
}
|
||||
if (!obj.postId) return { error: 'ErrorCantGetID' };
|
||||
if (!postId) return { error: 'ErrorCantGetID' };
|
||||
|
||||
let detail;
|
||||
detail = await fetch(config[obj.host]["api"].replace("{postId}", obj.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"}
|
||||
}).then((r) => { 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 {
|
||||
|
|
|
@ -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}`],
|
||||
|
|
Loading…
Reference in a new issue