From e208d6969588d1f2deaf358dd809f8c52465b462 Mon Sep 17 00:00:00 2001 From: GlobalGit3 <137680273+GlobalGit3@users.noreply.github.com> Date: Mon, 3 Jul 2023 16:43:39 -0500 Subject: [PATCH] Updated Features & Added resolution. Resolution now supported. Feature list was updated to reflect both resolution and tag category being used now. --- README.md | 38 +++++++++++++++++++------------------- src/engines/Philomena.ts | 9 ++++++++- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 24ebb67..72f25a8 100644 --- a/README.md +++ b/README.md @@ -4,22 +4,22 @@ Scrape a booru-like post object from the DOM. ## Supported sites -| Engine | Sites | Features | Notes | -| -------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------- | -| animepictures | anime-pictures.net | content, resolution, tags, tag_category | Rating is assumed to be safe. | -| danbooru | danbooru.donmai.us, safebooru.donmai.us | content, rating, resolution, tags, tag_category, source, notes | | -| e621 | e621.net, e926.net | content, rating, resolution, tags, tag_category, source | | -| furaffinity | www.furaffinity.net | content, rating, resolution, tags, tag_category | | -| gelbooru | safebooru.org, gelbooru.com, rule34.xxx, tbib.org, xbooru.com | content, rating, resolution, tags, tag_category, source, notes | Supported features might vary between hosts. | -| inkbunny | inkbunny.net | content, rating, resolution, tags | | -| moebooru | yande.re, konachan.com | content, rating, resolution, tags, tag_category, source, notes | | -| philomena | derpibooru.org, trixiebooru.org, ponybooru.org, furbooru.org, ponerpics.org, manebooru.art, twibooru.org | content, rating, tags, source | | -| pixiv | pixiv.net, www.pixiv.net | content | | -| reddit | reddit.com, new.reddit.com, old.reddit.com | content | | -| rule34us | rule34.us | content, resolution, tags, tag_category | Rating is assumed to be unsafe. | -| sankakucomplex | chan.sankakucomplex.com | content, rating, tags, tag_category, notes | Hotlink protection currently prevents szurubooru from importing from this site. | -| shimmie2 | rule34.paheal.net, rule34hentai.net | content, tags, source | Rating is assumed to be unsafe. | -| shuushuu | e-shuushuu.net | content, rating, resolution, tags, tag_category | Rating is assumed to be safe. | -| twitter | twitter.com, mobile.twitter.com | content | | -| zerochan | www.zerochan.net | content, resolution, tags, tag_category | Rating is assumed to be safe. | -| fallback | | content | Tries to find the largest image or video on the current page. | +| Engine | Sites | Features | Notes | +| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- | ------------------------------------------------------------- | +| animepictures | anime-pictures.net | content, resolution, tags, tag_category | Rating is assumed to be safe. | +| danbooru | danbooru.donmai.us, safebooru.donmai.us | content, rating, resolution, tags, tag_category, source, notes | | +| e621 | e621.net, e926.net | content, rating, resolution, tags, tag_category, source | | +| furaffinity | www.furaffinity.net | content, rating, resolution, tags, tag_category | | +| gelbooru | safebooru.org, gelbooru.com, rule34.xxx, tbib.org, xbooru.com | content, rating, resolution, tags, tag_category, source, notes | Supported features might vary between hosts. | +| inkbunny | inkbunny.net | content, rating, resolution, tags | | +| moebooru | yande.re, konachan.com | content, rating, resolution, tags, tag_category, source, notes | | +| philomena | derpibooru.org, trixiebooru.org, ponybooru.org, furbooru.org, ponerpics.org, manebooru.art, twibooru.org | content, rating, resolution, tags, tag_category, source | | +| pixiv | pixiv.net, www.pixiv.net | content | | +| reddit | reddit.com, new.reddit.com, old.reddit.com | content | | +| rule34us | rule34.us | content, resolution, tags, tag_category | Rating is assumed to be unsafe. | +| sankakucomplex | chan.sankakucomplex.com | content, rating, tags, tag_category, notes | | +| shimmie2 | rule34.paheal.net, rule34hentai.net | content, tags, source | Rating is assumed to be unsafe. | +| shuushuu | e-shuushuu.net | content, rating, resolution, tags, tag_category | Rating is assumed to be safe. | +| twitter | twitter.com, mobile.twitter.com | content | | +| zerochan | www.zerochan.net | content, resolution, tags, tag_category | Rating is assumed to be safe. | +| fallback | | content | Tries to find the largest image or video on the current page. | \ No newline at end of file diff --git a/src/engines/Philomena.ts b/src/engines/Philomena.ts index 53e8c84..5d21949 100644 --- a/src/engines/Philomena.ts +++ b/src/engines/Philomena.ts @@ -3,7 +3,7 @@ import { SafetyRating, TagCategory } from "../BooruTypes.js"; export default class Philomena extends ScrapeEngineBase { name = "Philomena"; - features: ScrapeEngineFeature[] = ["content", "rating", "tags", "source"]; + features: ScrapeEngineFeature[] = ["content", "rating", "resolution", "tags", "tag_category", "source"]; notes = []; supportedHosts = [ "derpibooru.org", @@ -47,6 +47,13 @@ export default class Philomena extends ScrapeEngineBase { // Set default rating (Will be determined later) post.rating = "unsafe"; + // Set resolution + const resolutionEl = ((document.querySelector("span[class='image-size']"))?.innerText).split(" ")[0]; + const [width, height] = (resolutionEl?.replace(" ", "").split("x") || []).map(Number); + if (!isNaN(width) && !isNaN(height)) { + post.resolution = [width, height]; + } + // Set tags const tagEls = Array.from(document.querySelectorAll(".tag.dropdown")).map((x) => x as HTMLSpanElement);