Add uploadMode to engines
parent
5253297809
commit
df9b1b2cfe
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "neo-scraper",
|
||||
"version": "0.7.5",
|
||||
"version": "0.8.0",
|
||||
"description": "Scrape a booru-like post object from the DOM.",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
|
|
|
|||
6137
pnpm-lock.yaml
6137
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
|
@ -2,6 +2,7 @@ import { TagCategory, SafetyRating } from "./BooruTypes.js";
|
|||
|
||||
export type Cookies = { [key: string]: string };
|
||||
export type ContentType = "image" | "video";
|
||||
export type UploadMode = "content" | "url";
|
||||
|
||||
export class ScrapedPost {
|
||||
contentUrl = "";
|
||||
|
|
@ -81,6 +82,8 @@ export interface ScrapeEngine {
|
|||
notes: string[];
|
||||
supportedHosts: string[];
|
||||
|
||||
get uploadMode(): UploadMode;
|
||||
|
||||
canImport(url: Location): boolean;
|
||||
scrapeDocument(document: Document): ScrapeResult;
|
||||
}
|
||||
|
|
@ -91,6 +94,10 @@ export abstract class ScrapeEngineBase implements ScrapeEngine {
|
|||
abstract notes: string[];
|
||||
abstract supportedHosts: string[];
|
||||
|
||||
get uploadMode(): UploadMode {
|
||||
return "url";
|
||||
}
|
||||
|
||||
canImport(url: Location): boolean {
|
||||
return this.supportedHosts.indexOf(url.host) != -1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ScrapeEngineBase, ScrapeResult, ScrapedPost, ScrapedTag, ScrapeEngineFeature } from "../ScrapeEngine.js";
|
||||
import { ScrapeEngineBase, ScrapeResult, ScrapedPost, ScrapedTag, ScrapeEngineFeature, UploadMode } from "../ScrapeEngine.js";
|
||||
import { TagCategory } from "../BooruTypes.js";
|
||||
import { createNoteFromDanbooruArticle, guessContentType } from "../Utility.js";
|
||||
|
||||
|
|
@ -8,6 +8,10 @@ export default class Danbooru extends ScrapeEngineBase {
|
|||
notes = [];
|
||||
supportedHosts = ["danbooru.donmai.us", "safebooru.donmai.us"];
|
||||
|
||||
override get uploadMode(): UploadMode {
|
||||
return "content";
|
||||
}
|
||||
|
||||
scrapeDocument(document: Document): ScrapeResult {
|
||||
const result = new ScrapeResult(this.name);
|
||||
const post = new ScrapedPost();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ScrapeEngineBase, ScrapeResult, ScrapedPost, ScrapeEngineFeature } from "../ScrapeEngine.js";
|
||||
import { ScrapeEngineBase, ScrapeResult, ScrapedPost, ScrapeEngineFeature, UploadMode } from "../ScrapeEngine.js";
|
||||
import { parseResolutionString } from "../Utility.js";
|
||||
import Cookies from "js-cookie";
|
||||
|
||||
|
|
@ -8,6 +8,10 @@ export default class Ehentai extends ScrapeEngineBase {
|
|||
notes = ["Rating is assumed to be unsafe."];
|
||||
supportedHosts = ["e-hentai.org", "exhentai.org"];
|
||||
|
||||
override get uploadMode(): UploadMode {
|
||||
return "content";
|
||||
}
|
||||
|
||||
scrapeDocument(document: Document): ScrapeResult {
|
||||
const result = new ScrapeResult(this.name);
|
||||
const post = new ScrapedPost();
|
||||
|
|
|
|||
Loading…
Reference in New Issue