From 9bf943362d6f62a8e18eb1877c597d80b9d84011 Mon Sep 17 00:00:00 2001 From: Snazzah Date: Fri, 24 Jan 2025 19:33:17 -0600 Subject: [PATCH] fix(api/threads): update threads and support gif posts --- api/src/processing/cookie/manager.js | 3 ++- api/src/processing/services/threads.js | 25 +++++++++++++++++++++++-- api/src/util/tests/threads.json | 11 ++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/api/src/processing/cookie/manager.js b/api/src/processing/cookie/manager.js index 25f41c2c..30bdab28 100644 --- a/api/src/processing/cookie/manager.js +++ b/api/src/processing/cookie/manager.js @@ -13,7 +13,8 @@ const VALID_SERVICES = new Set([ 'reddit', 'twitter', 'youtube', - 'youtube_oauth' + 'youtube_oauth', + 'threads' ]); const invalidCookies = {}; diff --git a/api/src/processing/services/threads.js b/api/src/processing/services/threads.js index 0cac4d48..90b97e21 100644 --- a/api/src/processing/services/threads.js +++ b/api/src/processing/services/threads.js @@ -1,5 +1,6 @@ import { createStream } from "../../stream/manage.js"; import { getCookie, updateCookie } from "../cookie/manager.js"; +import { genericUserAgent } from "../../config.js"; const commonHeaders = { "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8", @@ -17,10 +18,10 @@ const commonHeaders = { "Sec-Fetch-Site": "same-origin", "Sec-Gpc": "1", "Upgrade-Insecure-Requests": "1", - "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36", + "User-Agent": genericUserAgent, }; -const DATA_REGEX = /