This commit is contained in:
암냥 2026-04-16 00:07:00 +09:00
commit 5207f5d431
No known key found for this signature in database
25 changed files with 2932 additions and 332 deletions

View file

@ -0,0 +1,33 @@
function fetchPixivData(url: string): Promise<any> {
// https://www.pixiv.net/artworks/143552616
const match = url.match(/\/artworks\/(\d+)/);
if (!match) {
throw new Error("Invalid Pixiv URL");
}
const artworkId = match[1];
return fetch(`https://www.phixiv.net/api/info?id=${artworkId}&language=ko`)
.then((response) => {
if (!response.ok) {
throw new Error(`Failed to fetch Pixiv data: ${response.status} ${response.statusText}`);
}
return response.json();
})
.then((data) => {
// if #R-18 in tags, throw error
if (data.tags && data.tags.some((tag: string) => tag.includes("R-18"))) {
throw new Error("Pixiv artwork is marked as R-18");
}
return data;
})
.then((data) => {
if (data.error) {
throw new Error(`Pixiv API error: ${data.message}`);
}
return data;
});
}
export { fetchPixivData };