Bugfixes
Fixed safety detection on chan.sankakucomplex.com, and improved source parsing on Gelbooru v0.2.0 sites.master
parent
fe0a543bf4
commit
15bec7b115
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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":
|
||||
post.rating = "safe";
|
||||
break;
|
||||
case "questionable":
|
||||
post.rating = "sketchy";
|
||||
break;
|
||||
case "explicit":
|
||||
post.rating = "unsafe";
|
||||
break;
|
||||
}
|
||||
const ratingElement = document.querySelector("#stats .rating-s, #stats .rating-q, #stats .rating-e");
|
||||
if (ratingElement) {
|
||||
if (ratingElement.classList.contains("rating-s")) {
|
||||
post.rating = "safe";
|
||||
} else if (ratingElement.classList.contains("rating-q")) {
|
||||
post.rating = "sketchy";
|
||||
} else if (ratingElement.classList.contains("rating-e")) {
|
||||
post.rating = "unsafe";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue