api/tiktok: add support for proxying images in a picker

This commit is contained in:
wukko 2024-08-31 15:01:09 +06:00
parent 0852f5dc09
commit f464d87585
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2
2 changed files with 16 additions and 5 deletions

View file

@ -128,7 +128,8 @@ export default async function(host, patternMatch, obj) {
id: patternMatch.id,
fullAudio: obj.tiktokFullAudio,
isAudioOnly,
h265: obj.tiktokH265
h265: obj.tiktokH265,
alwaysProxy: obj.alwaysProxy,
});
break;

View file

@ -3,6 +3,7 @@ import Cookie from "../cookie/cookie.js";
import { extract } from "../url.js";
import { genericUserAgent } from "../../config.js";
import { updateCookie } from "../cookie/manager.js";
import { createStream } from "../../stream/manage.js";
const shortDomain = "https://vt.tiktok.com/";
@ -97,10 +98,19 @@ export default async function(obj) {
if (images) {
let imageLinks = images
.map(i => i.imageURL.urlList.find(p => p.includes(".jpeg?")))
.map(url => ({
.map((url, i) => {
if (obj.alwaysProxy) url = createStream({
service: "tiktok",
type: "proxy",
u: url,
filename: `${filenameBase}_photo_${i + 1}.jpg`
})
return {
type: "photo",
url
}));
}
});
return {
picker: imageLinks,