Add Philomena video resolution test
parent
7a12310bb4
commit
18e9b57e12
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "neo-scraper",
|
"name": "neo-scraper",
|
||||||
"version": "0.7.1",
|
"version": "0.7.2",
|
||||||
"description": "Scrape a booru-like post object from the DOM.",
|
"description": "Scrape a booru-like post object from the DOM.",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
|
||||||
|
|
@ -28,3 +28,16 @@ test("get derpibooru.org post 3157356", async () => {
|
||||||
expect(res.posts[0].pageUrl).toBe(pageUrl);
|
expect(res.posts[0].pageUrl).toBe(pageUrl);
|
||||||
expect(res.posts[0].contentUrl).toBe("https://derpicdn.net/img/download/2023/7/5/3157356.png");
|
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");
|
||||||
|
});
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,9 @@ export default class Philomena extends ScrapeEngineBase {
|
||||||
post.rating = "unsafe";
|
post.rating = "unsafe";
|
||||||
|
|
||||||
// Set resolution
|
// 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) {
|
if (resStr) {
|
||||||
const res = parseResolutionString(resStr);
|
const res = parseResolutionString(resStr);
|
||||||
if (res) {
|
if (res) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue