From f464d87585a023820db0500aa139b617d63082ea Mon Sep 17 00:00:00 2001 From: wukko Date: Sat, 31 Aug 2024 15:01:09 +0600 Subject: [PATCH] api/tiktok: add support for proxying images in a picker --- api/src/processing/match.js | 3 ++- api/src/processing/services/tiktok.js | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/src/processing/match.js b/api/src/processing/match.js index 4738af5d..d6c72e7e 100644 --- a/api/src/processing/match.js +++ b/api/src/processing/match.js @@ -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; diff --git a/api/src/processing/services/tiktok.js b/api/src/processing/services/tiktok.js index bc77c1c1..3c70e033 100644 --- a/api/src/processing/services/tiktok.js +++ b/api/src/processing/services/tiktok.js @@ -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 => ({ - type: "photo", - 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,