api/pinterest: fetch.empty for invalid links

This commit is contained in:
hyperdefined 2025-05-30 15:47:31 -04:00
parent ea3223e0b0
commit cb78dd1db9
No known key found for this signature in database
GPG Key ID: 38C93C4835071D4A
2 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { resolveRedirectingURL } from "../url.js";
const videoRegex = /"url":"(https:\/\/v1\.pinimg\.com\/videos\/.*?)"/g;
const imageRegex = /src="(https:\/\/i\.pinimg\.com\/.*\.(jpg|gif))"/g;
const validPinRegex = /"__typename"\s*:\s*"PinNotFound"/;
export default async function(o) {
let id = o.id;
@ -19,6 +20,10 @@ export default async function(o) {
headers: { "user-agent": genericUserAgent }
}).then(r => r.text()).catch(() => {});
const invalidPin = html.match(validPinRegex);
if (invalidPin) return { error: "fetch.empty" }
if (!html) return { error: "fetch.fail" };
const videoLink = [...html.matchAll(videoRegex)]

View File

@ -8,6 +8,15 @@
"status": "redirect"
}
},
{
"name": "invalid link",
"url": "https://www.pinterest.com/pin/eeeeeee/",
"params": {},
"expected": {
"code": 400,
"status": "error"
}
},
{
"name": "regular video (isAudioOnly)",
"url": "https://www.pinterest.com/pin/70437485604616/",