Fixed safety detection on chan.sankakucomplex.com, and improved source parsing on Gelbooru v0.2.0 sites.
master
Nes370 2026-10-17 19:29:36 -07:00
parent fe0a543bf4
commit 15bec7b115
2 changed files with 13 additions and 22 deletions

View File

@ -89,10 +89,12 @@ export default class Gelbooru extends ScrapeEngineBase {
if (matches && matches.length == 3) {
// If Source element
if (matches[1] == "Source") {
if (version == Version.v020) {
post.sources = [matches[2]];
const anchor = el.querySelector("a");
if (anchor && anchor.href) {
post.sources = [anchor.href];
} else {
post.sources = [(el.children[0] as HTMLAnchorElement).href];
// Fallback to plain text just in case
post.sources = [matches[2]];
}
}
// If Rating element

View File

@ -27,25 +27,14 @@ export default class SankakuComplex extends ScrapeEngineBase {
post.contentType = guessContentType(post.contentUrl);
// Set rating
const safetyExp = new RegExp("Rating: (.*)");
const safetyElements = Array.from(document.querySelectorAll("#stats > ul > li"))
.map((x) => x as HTMLLIElement)
.filter((x) => x.innerText.startsWith("Rating"));
if (safetyElements.length > 0) {
const matches = safetyElements[0].innerText.match(safetyExp);
if (matches && matches.length > 0) {
switch (matches[1].toLowerCase()) {
case "safe":
const ratingElement = document.querySelector("#stats .rating-s, #stats .rating-q, #stats .rating-e");
if (ratingElement) {
if (ratingElement.classList.contains("rating-s")) {
post.rating = "safe";
break;
case "questionable":
} else if (ratingElement.classList.contains("rating-q")) {
post.rating = "sketchy";
break;
case "explicit":
} else if (ratingElement.classList.contains("rating-e")) {
post.rating = "unsafe";
break;
}
}
}