Skip to content

Commit

Permalink
Fix image count parser for Zerochan (issue #1280)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bionus committed Jun 10, 2018
1 parent 89dda75 commit 6311898
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions release/sites/Zerochan/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export const source: ISource = {
return "/" + query.search + "?s=id&xml&" + pagePart;
},
parse: (src: string): IParsedSearch => {
const data = Grabber.makeArray(Grabber.parseXML(src).rss.channel.item);
const parsed = Grabber.parseXML(src);
const data = Grabber.makeArray(parsed.rss.channel.item);

const images: IImage[] = [];
for (const image of data) {
Expand All @@ -46,7 +47,10 @@ export const source: ISource = {
images.push(completeImage(img));
}

return { images };
return {
images,
imageCount: Grabber.regexToConst("count", "has (?<count>[0-9,]+) .+? anime images", parsed.rss.channel.description["#text"]),
};
},
},
},
Expand All @@ -64,7 +68,7 @@ export const source: ISource = {
tags: Grabber.regexToTags("<li[^>]*>\\s*<a [^>]+>(?<name>[^>]+)</a>\\s+(?:<span>(?<type>[^<]+) (?<count>[0-9]+)</span>|(?<type_2>[^<]*))\\s*</li>", src),
images: Grabber.regexToImages("<a href=['\"]/(?<id>[^'\"]+)['\"][^>]*>[^<]*(?:<b>[^<]*</b>)?[^<]*(?:<span>[^<]*</span>)?[^<]*(?<image><img\\s*src=['\"](?<preview_url>[^'\"]*)['\"][^>]*/?>)", src).map(completeImage),
pageCount: Grabber.regexToConst("page", "page (?:[0-9,]+) of (?<page>[0-9,]+)", src),
imageCount: Grabber.regexToConst("count", "has (?<count>[0-9,]+) .*?images\\.", src),
imageCount: Grabber.regexToConst("count", "has (?<count>[0-9,]+) .+? images", src),
};
},
},
Expand Down

0 comments on commit 6311898

Please sign in to comment.