pinterest: fix id checking for shortened links

This commit is contained in:
wukko 2024-01-17 23:20:49 +06:00
parent 9976ec59c8
commit 45a85e5928

View file

@ -8,15 +8,15 @@ const videoLinkBase = {
export default async function(o) { export default async function(o) {
let id = o.id, type = "regular"; let id = o.id, type = "regular";
if (id.includes("--")) {
id = id.split("--")[1];
type = "story";
}
if (!o.id && o.shortLink) { if (!o.id && o.shortLink) {
id = await fetch(`https://api.pinterest.com/url_shortener/${o.shortLink}/redirect/`, { redirect: "manual" }).then((r) => { id = await fetch(`https://api.pinterest.com/url_shortener/${o.shortLink}/redirect/`, { redirect: "manual" }).then((r) => {
return r.headers.get("location").split('pin/')[1].split('/')[0] return r.headers.get("location").split('pin/')[1].split('/')[0]
}).catch(() => {}); }).catch(() => {});
} }
if (id.includes("--")) {
id = id.split("--")[1];
type = "story";
}
if (!id) return { error: 'ErrorCouldntFetch' }; if (!id) return { error: 'ErrorCouldntFetch' };
let html = await fetch(`https://www.pinterest.com/pin/${id}/`, { let html = await fetch(`https://www.pinterest.com/pin/${id}/`, {