all extensions to new format :P

This commit is contained in:
2025-12-15 19:40:07 +01:00
parent 9986b64ace
commit 9fe48f93fe
19 changed files with 1725 additions and 1375 deletions

View File

@@ -8,12 +8,11 @@ class WaifuPics {
'happy', 'wink', 'poke', 'dance', 'cringe'
];
constructor(fetchPath, cheerioPath) {
this.fetch = require(fetchPath);
constructor() {
this.type = "image-board";
}
async fetchSearchResult(query, page = 1, perPage = 42) {
async search(query, page = 1, perPage = 42) {
if (!query) query = "waifu";
const category = query.trim().split(' ')[0];
@@ -34,7 +33,7 @@ class WaifuPics {
try {
const response = await this.fetch(`${this.baseUrl}/many/sfw/${category}`, {
const response = await fetch(`${this.baseUrl}/many/sfw/${category}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ exclude: [] }),
@@ -49,13 +48,12 @@ class WaifuPics {
const results = data.files.map((url, index) => {
const id = url.substring(url.lastIndexOf('/') + 1) || `${category}-${index}`;
const uniqueId = `${page}-${id}`;
const uniqueId = `${id}`;
return {
id: uniqueId,
image: url,
tags: [category],
type: 'preview'
};
});
@@ -83,19 +81,13 @@ class WaifuPics {
}
}
async fetchInfo(id) {
console.log(`[WaifuPics] fetchInfo called for ${id}, but this API only provides direct URLs.`);
async getInfo(id) {
return {
id: id,
fullImage: `https://i.waifu.pics/${id}`,
resizedImageUrl: `https://i.waifu.pics/${id}`,
tags: [],
createdAt: null,
publishedBy: 'Waifu.pics',
rating: 'sfw',
comments: []
id,
image: `https://i.waifu.pics/${id}`,
tags: []
};
}
}
module.exports = { WaifuPics };
module.exports = WaifuPics;