mirror of
https://github.com/lifegpc/eh-downloader.git
synced 2026-07-08 01:31:00 +08:00
Add sampled_name
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { DOMParser, Element } from "deno_dom/deno-dom-wasm-noinit.ts";
|
||||
import { extname } from "std/path/mod.ts";
|
||||
import { Client } from "../client.ts";
|
||||
import { EhFile, PMeta } from "../db.ts";
|
||||
import { initDOMParser, map, parse_bool } from "../utils.ts";
|
||||
@@ -75,6 +76,15 @@ class Image {
|
||||
get page_token() {
|
||||
return this.base.token;
|
||||
}
|
||||
get sampled_name() {
|
||||
const name = this.data?.name;
|
||||
if (name) return name;
|
||||
const n = this.base.name;
|
||||
const e = extname(n);
|
||||
const b = n.slice(0, n.length - e.length);
|
||||
if (n === ".gif") return `${b}.gif`;
|
||||
return `${b}.jpg`;
|
||||
}
|
||||
get src() {
|
||||
return this.data?.img_url;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DOMParser } from "deno_dom/deno-dom-wasm-noinit.ts";
|
||||
import { extname } from "std/path/mod.ts";
|
||||
import { Client } from "../client.ts";
|
||||
import { initDOMParser } from "../utils.ts";
|
||||
import { EhFile, PMeta } from "../db.ts";
|
||||
@@ -122,6 +123,13 @@ class MPVImage {
|
||||
get page_token() {
|
||||
return this.base.k;
|
||||
}
|
||||
get sampled_name() {
|
||||
const n = this.base.n;
|
||||
const e = extname(n);
|
||||
const b = n.slice(0, n.length - e.length);
|
||||
if (n === ".gif") return `${b}.gif`;
|
||||
return `${b}.jpg`;
|
||||
}
|
||||
get src() {
|
||||
return this.data?.i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user