wow
This commit is contained in:
parent
b12ebb725d
commit
5207f5d431
25 changed files with 2932 additions and 332 deletions
33
apps/backend/src/lib/pixiv.ts
Normal file
33
apps/backend/src/lib/pixiv.ts
Normal 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 };
|
||||
Loading…
Add table
Add a link
Reference in a new issue