Skip to content

Commit

Permalink
source: fix E-H parsing for large image mode (fix #2854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Dec 11, 2022
1 parent 8aea70f commit 6bc40c2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions src/sites/E-Hentai/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,24 @@ export const source: ISource = {
}*/

const images: IImage[] = [];
const matches = Grabber.regexMatches('<div class="gdtm"[^>]*><div style="(?<div_style>[^"]+)"><a href="(?<page_url>[^"]+)"><img[^>]*></a></div>', src);
let matches = Grabber.regexMatches('<div class="gdtm"[^>]*><div style="(?<div_style>[^"]+)"><a href="(?<page_url>[^"]+)"><img[^>]*></a></div>', src);
if (matches.length < 1) {
matches = Grabber.regexMatches('<div class="gdtl"[^>]*><a href="(?<page_url>[^"]+)"><img[^>]*src="(?<preview_url>[^"]+)"[^>]*></a></div>', src);
}
for (const match of matches) {
const styles = cssToObject(match["div_style"]);
delete match["div_style"];
if ("div_style" in match) {
const styles = cssToObject(match["div_style"]);
delete match["div_style"];

const background = styles["background"].match(/url\(([^)]+)\) ([^ ]+) ([^ ]+)/);
match["preview_url"] = background[1];
match["preview_rect"] = [
-sizeToInt(background[2]),
-sizeToInt(background[3]),
sizeToInt(styles["width"]),
sizeToInt(styles["height"]),
].join(";"); // x;y;w;h
const background = styles["background"].match(/url\(([^)]+)\) ([^ ]+) ([^ ]+)/);
match["preview_url"] = background[1];
match["preview_rect"] = [
-sizeToInt(background[2]),
-sizeToInt(background[3]),
sizeToInt(styles["width"]),
sizeToInt(styles["height"]),
].join(";"); // x;y;w;h
}

match["created_at"] = posted;
match["author"] = author;
Expand Down

0 comments on commit 6bc40c2

Please sign in to comment.