Add rule34.paheal.net (Shimmie2)

feature-show_image_resolution
neobooru 2019-08-05 01:19:27 +02:00
parent c1d4f899b2
commit 963e694b48
2 changed files with 44 additions and 0 deletions

43
src/loaders/Shimmie2.ts Normal file
View File

@ -0,0 +1,43 @@
import ILoader from "./ILoader"
import { SzuruPost, SzuruTag, SzuruCategory } from "../SzuruTypes";
export default class Shimmie2 implements ILoader {
canImport(location: Location): boolean {
return location.host == "rule34.paheal.net";
}
async grabPost(dom: Document): Promise<SzuruPost | null> {
let post = new SzuruPost();
post.source = dom.location.href;
// Set image url
const originalImageElements = Array.from(dom.querySelectorAll(".image_info > tbody > tr > td > a"))
.map(x => x as HTMLAnchorElement)
.filter(x => x.innerText == "Image Only");
if (originalImageElements.length > 0) {
post.imageUrl = originalImageElements[0].href;
}
// Set safety
post.safety = "unsafe"; // Usually it is unsafe
// Set tags
// Shimmie2 doesn't support categories so we don't need to worry about those.
// They also use uppercase tags, so we toLowerCase() those.
// Tags might not match with other booru-likes, but that is for the user to figure out.
// For example by deleting 'wrong' tags or setting up some aliases in szurubooru.
post.tags = Array.from(dom.querySelectorAll("a.tag_name"))
.map(x => (x as HTMLAnchorElement).innerText.toLowerCase())
.map(x => new SzuruTag(x));
// console.dir(post);
// If post has enough filled fields to be considered a valid post
if (post.imageUrl) {
return post;
} else {
return null;
}
}
}

View File

@ -1,2 +1,3 @@
export { default as Gelbooru } from "./Gelbooru";
export { default as Danbooru } from "./Danbooru";
export { default as Shimmie2 } from "./Shimmie2";