Add Philomena video resolution test

pull/17/head
neobooru 2023-07-22 14:35:28 +02:00
parent 7a12310bb4
commit 18e9b57e12
3 changed files with 17 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "neo-scraper",
"version": "0.7.1",
"version": "0.7.2",
"description": "Scrape a booru-like post object from the DOM.",
"type": "module",
"main": "dist/index.js",

View File

@ -28,3 +28,16 @@ test("get derpibooru.org post 3157356", async () => {
expect(res.posts[0].pageUrl).toBe(pageUrl);
expect(res.posts[0].contentUrl).toBe("https://derpicdn.net/img/download/2023/7/5/3157356.png");
});
test("get derpibooru.org video post 3161674", async () => {
const pageUrl = "https://derpibooru.org/images/3161674?q=video";
const res = await scrapeUrl(pageUrl);
expect(res.posts.length).toBe(1);
expect(res.posts[0].rating).toBe("safe");
expect(res.posts[0]).not.toHaveTag("safe");
expect(res.posts[0]).toHaveTag("oc");
expect(res.posts[0]).toHaveTag("rainbow_dash", "character");
expect(res.posts[0]).toHaveResolution([1920, 1080]);
expect(res.posts[0].pageUrl).toBe(pageUrl);
expect(res.posts[0].contentUrl).toBe("https://derpicdn.net/img/download/2023/7/12/3161674.webm");
});

View File

@ -49,7 +49,9 @@ export default class Philomena extends ScrapeEngineBase {
post.rating = "unsafe";
// Set resolution
const resStr = (<HTMLElement>document.querySelector("span[class='image-size']"))?.innerText?.match(/(\d+x\d+)/)?.[0];
const resStr = (<HTMLElement>document.querySelector("span[class='image-size']"))?.innerText?.match(
/(\d+x\d+)/
)?.[0];
if (resStr) {
const res = parseResolutionString(resStr);
if (res) {