4.5
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { apiJSON } from "../sub/utils.js";
|
||||
import { errorUnsupported, genericError } from "../sub/errors.js";
|
||||
|
||||
import loc from "../../localization/manager.js";
|
||||
|
||||
import { testers } from "./servicesPatternTesters.js";
|
||||
|
||||
import bilibili from "../services/bilibili.js";
|
||||
@@ -105,7 +107,9 @@ export default async function (host, patternMatch, url, lang, obj) {
|
||||
default:
|
||||
return apiJSON(0, { t: errorUnsupported(lang) });
|
||||
}
|
||||
return matchActionDecider(r, host, obj.ip, obj.aFormat, obj.isAudioOnly)
|
||||
return !r.error ? matchActionDecider(r, host, obj.ip, obj.aFormat, obj.isAudioOnly, lang) : apiJSON(0, {
|
||||
t: Array.isArray(r.error) ? loc(lang, r.error[0], r.error[1]) : loc(lang, r.error)
|
||||
});
|
||||
} catch (e) {
|
||||
return apiJSON(0, { t: genericError(lang, host) })
|
||||
}
|
||||
|
||||
@@ -1,105 +1,109 @@
|
||||
import { audioIgnore, services, supportedAudio } from "../config.js"
|
||||
import { apiJSON } from "../sub/utils.js"
|
||||
import loc from "../../localization/manager.js";
|
||||
|
||||
export default function(r, host, ip, audioFormat, isAudioOnly) {
|
||||
if (!r.error) {
|
||||
if (!isAudioOnly && !r.picker) {
|
||||
switch (host) {
|
||||
case "twitter":
|
||||
return apiJSON(1, { u: r.urls });
|
||||
case "vk":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "bilibili":
|
||||
export default function(r, host, ip, audioFormat, isAudioOnly, lang) {
|
||||
if (!isAudioOnly && !r.picker) {
|
||||
switch (host) {
|
||||
case "twitter":
|
||||
return apiJSON(1, { u: r.urls });
|
||||
case "vk":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "bilibili":
|
||||
return apiJSON(2, {
|
||||
type: "render", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
time: r.time
|
||||
});
|
||||
case "youtube":
|
||||
return apiJSON(2, {
|
||||
type: r.type, u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
time: r.time,
|
||||
});
|
||||
case "reddit":
|
||||
return apiJSON(r.typeId, {
|
||||
type: r.type, u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "tiktok":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "douyin":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "tumblr":
|
||||
return apiJSON(1, { u: r.urls });
|
||||
case "vimeo":
|
||||
if (r.filename) {
|
||||
return apiJSON(2, {
|
||||
type: "render", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
time: r.time
|
||||
filename: r.filename
|
||||
});
|
||||
case "youtube":
|
||||
return apiJSON(2, {
|
||||
type: r.type, u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
time: r.time,
|
||||
});
|
||||
case "reddit":
|
||||
return apiJSON(r.typeId, {
|
||||
type: r.type, u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "tiktok":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "douyin":
|
||||
return apiJSON(2, {
|
||||
type: "bridge", u: r.urls, service: host, ip: ip,
|
||||
filename: r.filename,
|
||||
});
|
||||
case "tumblr":
|
||||
} else {
|
||||
return apiJSON(1, { u: r.urls });
|
||||
case "vimeo":
|
||||
return apiJSON(1, { u: r.urls });
|
||||
}
|
||||
} else if (r.picker) {
|
||||
switch (host) {
|
||||
case "douyin":
|
||||
case "tiktok":
|
||||
let type = "render";
|
||||
if (audioFormat === "mp3" || audioFormat === "best") {
|
||||
audioFormat = "mp3"
|
||||
type = "bridge"
|
||||
}
|
||||
return apiJSON(5, {
|
||||
type: type,
|
||||
picker: r.picker,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, isAudioOnly: true, audioFormat: audioFormat, copy: audioFormat === "best" ? true : false,
|
||||
})
|
||||
case "twitter":
|
||||
return apiJSON(5, {
|
||||
picker: r.picker, service: host
|
||||
})
|
||||
}
|
||||
} else {
|
||||
if (host === "reddit" && r.typeId === 1 || audioIgnore.includes(host)) return apiJSON(0, { t: r.audioFilename });
|
||||
let type = "render";
|
||||
let copy = false;
|
||||
|
||||
if (!supportedAudio.includes(audioFormat)) audioFormat = "best";
|
||||
if ((host == "tiktok" || host == "douyin") && isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) {
|
||||
if (r.isMp3) {
|
||||
if (audioFormat === "mp3" || audioFormat === "best") {
|
||||
audioFormat = "mp3"
|
||||
type = "bridge"
|
||||
}
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
}
|
||||
}
|
||||
} else if (r.picker) {
|
||||
switch (host) {
|
||||
case "douyin":
|
||||
case "tiktok":
|
||||
let type = "render";
|
||||
if (audioFormat === "mp3" || audioFormat === "best") {
|
||||
audioFormat = "mp3"
|
||||
type = "bridge"
|
||||
}
|
||||
}
|
||||
if ((audioFormat === "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat === services[host]["bestAudio"])) {
|
||||
audioFormat = services[host]["bestAudio"]
|
||||
type = "bridge"
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
copy = true
|
||||
if (r.audioFilename.includes("twitterspaces")) {
|
||||
audioFormat = "mp3"
|
||||
copy = false
|
||||
}
|
||||
}
|
||||
return apiJSON(2, {
|
||||
type: type,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, isAudioOnly: true,
|
||||
audioFormat: audioFormat, copy: copy, fileMetadata: r.fileMetadata ? r.fileMetadata : false
|
||||
})
|
||||
return apiJSON(5, {
|
||||
type: type,
|
||||
picker: r.picker,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, isAudioOnly: true, audioFormat: audioFormat, copy: audioFormat === "best" ? true : false,
|
||||
})
|
||||
case "twitter":
|
||||
return apiJSON(5, {
|
||||
picker: r.picker, service: host
|
||||
})
|
||||
}
|
||||
} else {
|
||||
return apiJSON(0, { t: r.error });
|
||||
if ((host === "reddit" && r.typeId === 1) || (host === "vimeo" && !r.filename) || audioIgnore.includes(host)) return apiJSON(0, { t: loc(lang, 'ErrorEmptyDownload') });
|
||||
let type = "render";
|
||||
let copy = false;
|
||||
|
||||
if (!supportedAudio.includes(audioFormat)) audioFormat = "best";
|
||||
if ((host == "tiktok" || host == "douyin") && isAudioOnly && services.tiktok.audioFormats.includes(audioFormat)) {
|
||||
if (r.isMp3) {
|
||||
if (audioFormat === "mp3" || audioFormat === "best") {
|
||||
audioFormat = "mp3"
|
||||
type = "bridge"
|
||||
}
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
type = "bridge"
|
||||
}
|
||||
}
|
||||
if ((audioFormat === "best" && services[host]["bestAudio"]) || services[host]["bestAudio"] && (audioFormat === services[host]["bestAudio"])) {
|
||||
audioFormat = services[host]["bestAudio"]
|
||||
type = "bridge"
|
||||
} else if (audioFormat === "best") {
|
||||
audioFormat = "m4a"
|
||||
copy = true
|
||||
if (r.audioFilename.includes("twitterspaces")) {
|
||||
audioFormat = "mp3"
|
||||
copy = false
|
||||
}
|
||||
}
|
||||
return apiJSON(2, {
|
||||
type: type,
|
||||
u: Array.isArray(r.urls) ? r.urls[1] : r.urls, service: host, ip: ip,
|
||||
filename: r.audioFilename, isAudioOnly: true,
|
||||
audioFormat: audioFormat, copy: copy, fileMetadata: r.fileMetadata ? r.fileMetadata : false
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"audioIgnore": ["vk", "vimeo"],
|
||||
"audioIgnore": ["vk"],
|
||||
"config": {
|
||||
"bilibili": {
|
||||
"alias": "bilibili.com",
|
||||
@@ -12,12 +12,12 @@
|
||||
"enabled": true
|
||||
},
|
||||
"twitter": {
|
||||
"alias": "twitter, twitter spaces",
|
||||
"alias": "twitter posts & spaces",
|
||||
"patterns": [":user/status/:id", ":user/status/:id/video/:v", "i/spaces/:spaceId"],
|
||||
"enabled": true
|
||||
},
|
||||
"vk": {
|
||||
"alias": "vk clips, vk video",
|
||||
"alias": "vk video & clips",
|
||||
"patterns": ["video-:userId_:videoId", "clip-:userId_:videoId", "clips-:userId?z=clip-:userId_:videoId"],
|
||||
"quality_match": {
|
||||
"2160": 7,
|
||||
@@ -47,7 +47,7 @@
|
||||
"enabled": true
|
||||
},
|
||||
"youtube": {
|
||||
"alias": "youtube, youtube music, youtube shorts",
|
||||
"alias": "youtube videos & shorts & music",
|
||||
"patterns": ["watch?v=:id"],
|
||||
"quality_match": ["2160", "1440", "1080", "720", "480", "360", "240", "144"],
|
||||
"bestAudio": "opus",
|
||||
@@ -59,26 +59,34 @@
|
||||
"enabled": true
|
||||
},
|
||||
"tumblr": {
|
||||
"patterns": ["post/:id", "blog/view/:user/:id"],
|
||||
"patterns": ["post/:id", "blog/view/:user/:id", ":user/:id", ":user/:id/:trackingId"],
|
||||
"enabled": true
|
||||
},
|
||||
"tiktok": {
|
||||
"alias": "tiktok videos & slideshow & audio",
|
||||
"patterns": [":user/video/:postId", ":id", "t/:id"],
|
||||
"audioFormats": ["best", "m4a", "mp3"],
|
||||
"enabled": true
|
||||
},
|
||||
"douyin": {
|
||||
"alias": "douyin videos & slideshow & audio",
|
||||
"patterns": ["video/:postId", ":id"],
|
||||
"enabled": true
|
||||
},
|
||||
"vimeo": {
|
||||
"patterns": [":id"],
|
||||
"resolutionMatch": {
|
||||
"3840": "2160",
|
||||
"1920": "1080",
|
||||
"1280": "720",
|
||||
"960": "480"
|
||||
},
|
||||
"enabled": true
|
||||
},
|
||||
"soundcloud": {
|
||||
"patterns": [":author/:song", ":shortLink"],
|
||||
"bestAudio": "none",
|
||||
"clientid": "1TLciEOiKE0PThutYu5Xj0kc8R4twD9p",
|
||||
"clientid": "YeTcsotswIIc4sse5WZsXszVxMtP6eLc",
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user