mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-05 23:09:26 -05:00
Fix broken waifu.im image and tag search (#3239)
This commit is contained in:
@@ -190,19 +190,19 @@ Singleton {
|
|||||||
"waifu.im": {
|
"waifu.im": {
|
||||||
"name": "waifu.im",
|
"name": "waifu.im",
|
||||||
"url": "https://waifu.im",
|
"url": "https://waifu.im",
|
||||||
"api": "https://api.waifu.im/search",
|
"api": "https://api.waifu.im/images",
|
||||||
"description": Translation.tr("Waifus only | Excellent quality, limited quantity"),
|
"description": Translation.tr("Waifus only | Excellent quality, limited quantity"),
|
||||||
"mapFunc": (response) => {
|
"mapFunc": (response) => {
|
||||||
response = response.images
|
response = response.items
|
||||||
return response.map(item => {
|
return response.map(item => {
|
||||||
return {
|
return {
|
||||||
"id": item.image_id,
|
"id": item.id,
|
||||||
"width": item.width,
|
"width": item.width,
|
||||||
"height": item.height,
|
"height": item.height,
|
||||||
"aspect_ratio": item.width / item.height,
|
"aspect_ratio": item.width / item.height,
|
||||||
"tags": item.tags.map(tag => {return tag.name}).join(" "),
|
"tags": item.tags.map(tag => {return tag.name}).join(" "),
|
||||||
"rating": item.is_nsfw ? "e" : "s",
|
"rating": item.isNsfw ? "e" : "s",
|
||||||
"is_nsfw": item.is_nsfw,
|
"is_nsfw": item.isNsfw,
|
||||||
"md5": item.md5,
|
"md5": item.md5,
|
||||||
"preview_url": item.sample_url ?? item.url, // preview_url just says access denied (maybe i fucked up and sent too many requests idk)
|
"preview_url": item.sample_url ?? item.url, // preview_url just says access denied (maybe i fucked up and sent too many requests idk)
|
||||||
"sample_url": item.url,
|
"sample_url": item.url,
|
||||||
@@ -212,10 +212,9 @@ Singleton {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
"tagSearchTemplate": "https://api.waifu.im/tags",
|
"tagSearchTemplate": "https://api.waifu.im/tags?Name={{query}}",
|
||||||
"tagMapFunc": (response) => {
|
"tagMapFunc": (response) => {
|
||||||
return [...response.versatile.map(item => {return {"name": item}}),
|
return response.items.map(item => {return {"name": item.name}})
|
||||||
...response.nsfw.map(item => {return {"name": item}})]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"t.alcy.cc": {
|
"t.alcy.cc": {
|
||||||
@@ -276,7 +275,7 @@ Singleton {
|
|||||||
property var currentProvider: Persistent.states.booru.provider
|
property var currentProvider: Persistent.states.booru.provider
|
||||||
|
|
||||||
function getWorkingImageSource(url) {
|
function getWorkingImageSource(url) {
|
||||||
if (url.includes('pximg.net')) {
|
if (url?.includes('pximg.net')) {
|
||||||
return `https://www.pixiv.net/en/artworks/${url.substring(url.lastIndexOf('/') + 1).replace(/_p\d+\.(png|jpg|jpeg|gif)$/, '')}`;
|
return `https://www.pixiv.net/en/artworks/${url.substring(url.lastIndexOf('/') + 1).replace(/_p\d+\.(png|jpg|jpeg|gif)$/, '')}`;
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
@@ -330,10 +329,10 @@ Singleton {
|
|||||||
else if (currentProvider === "waifu.im") {
|
else if (currentProvider === "waifu.im") {
|
||||||
var tagsArray = tagString.split(" ");
|
var tagsArray = tagString.split(" ");
|
||||||
tagsArray.forEach(tag => {
|
tagsArray.forEach(tag => {
|
||||||
params.push("included_tags=" + encodeURIComponent(tag));
|
params.push("IncludedTags=" + encodeURIComponent(tag.toLowerCase()));
|
||||||
});
|
});
|
||||||
params.push("limit=" + Math.min(limit, 30)) // Only admin can do > 30
|
params.push("PageSize=" + Math.min(limit, 30)) // Only admin can do > 30
|
||||||
params.push("is_nsfw=" + (nsfw ? "null" : "false")) // null is random
|
params.push("IsNsfw=" + (nsfw ? "All" : "False")) // null is random
|
||||||
}
|
}
|
||||||
else if (currentProvider === "t.alcy.cc") {
|
else if (currentProvider === "t.alcy.cc") {
|
||||||
url += tagString
|
url += tagString
|
||||||
|
|||||||
Reference in New Issue
Block a user