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 (matches && matches.length == 3) {
// If Source element // If Source element
if (matches[1] == "Source") { if (matches[1] == "Source") {
if (version == Version.v020) { const anchor = el.querySelector("a");
post.sources = [matches[2]]; if (anchor && anchor.href) {
post.sources = [anchor.href];
} else { } else {
post.sources = [(el.children[0] as HTMLAnchorElement).href]; // Fallback to plain text just in case
post.sources = [matches[2]];
} }
} }
// If Rating element // If Rating element

View File

@ -27,25 +27,14 @@ export default class SankakuComplex extends ScrapeEngineBase {
post.contentType = guessContentType(post.contentUrl); post.contentType = guessContentType(post.contentUrl);
// Set rating // Set rating
const safetyExp = new RegExp("Rating: (.*)"); const ratingElement = document.querySelector("#stats .rating-s, #stats .rating-q, #stats .rating-e");
const safetyElements = Array.from(document.querySelectorAll("#stats > ul > li")) if (ratingElement) {
.map((x) => x as HTMLLIElement) if (ratingElement.classList.contains("rating-s")) {
.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":
post.rating = "safe"; post.rating = "safe";
break; } else if (ratingElement.classList.contains("rating-q")) {
case "questionable":
post.rating = "sketchy"; post.rating = "sketchy";
break; } else if (ratingElement.classList.contains("rating-e")) {
case "explicit":
post.rating = "unsafe"; post.rating = "unsafe";
break;
}
} }
} }