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 (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
|
||||||
|
|
|
||||||
|
|
@ -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"));
|
post.rating = "safe";
|
||||||
|
} else if (ratingElement.classList.contains("rating-q")) {
|
||||||
if (safetyElements.length > 0) {
|
post.rating = "sketchy";
|
||||||
const matches = safetyElements[0].innerText.match(safetyExp);
|
} else if (ratingElement.classList.contains("rating-e")) {
|
||||||
if (matches && matches.length > 0) {
|
post.rating = "unsafe";
|
||||||
switch (matches[1].toLowerCase()) {
|
|
||||||
case "safe":
|
|
||||||
post.rating = "safe";
|
|
||||||
break;
|
|
||||||
case "questionable":
|
|
||||||
post.rating = "sketchy";
|
|
||||||
break;
|
|
||||||
case "explicit":
|
|
||||||
post.rating = "unsafe";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue