Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update GenesiStudioParser #1529

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions plugin/js/parsers/GenesiStudioParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ class GenesiStudioParser extends Parser{
async getChapterUrls(dom) {
let data = (await HttpClient.fetchJson(dom.baseURI + "/__data.json")).json;
let tmpids = data.nodes[2].data[0].chapters;
tmpids = data.nodes[2].data[tmpids].free_chapters;
let freeChapterids = data.nodes[2].data[tmpids];

let returnchapters = freeChapterids.map(e => ({
sourceUrl: `https://genesistudio.com/viewer/${data.nodes[2].data[data.nodes[2].data[e].id]}`,
title: `${data.nodes[2].data[data.nodes[2].data[e].chapter_title]}`
let jsdata = data.nodes[2].data[tmpids];
let extractfreechapter = [...jsdata.match(/'free'.*'premium'/)[0].matchAll(/'id':0.*?,/g)];
let freechapterids = extractfreechapter.map(e => Number(e[0].replace("'id':","").replace(",","")));

let returnchapters = freechapterids.map(e => ({
sourceUrl: "https://genesistudio.com/viewer/"+e,
title: "[placeholder]"
}));
return returnchapters;
}
Expand All @@ -34,8 +35,8 @@ class GenesiStudioParser extends Parser{
let newDoc = Parser.makeEmptyDocForContent(url);

this.appendElement(newDoc, "h1", this.titleFromJson(json));
let hash = json.nodes[2].data[json.nodes[2].data[0].akezmZmaAOMmegnQAlkRnalAJnr];
let content = json.nodes[2].data[json.nodes[2].data[0][hash]];
let index = json.nodes[2].data[0].content;
let content = json.nodes[2].data[index];
this.appendContent(newDoc, content);
let notes = json.nodes[2].data[json.nodes[2].data[0].footnotes];
if (notes !== null && notes != "") {
Expand Down Expand Up @@ -63,6 +64,10 @@ class GenesiStudioParser extends Parser{
findContent(dom) {
return Parser.findConstrutedContent(dom);
}

findChapterTitle(dom) {
return dom.querySelector("h1");
}

extractTitleImpl(dom) {
return dom.querySelector("h1");
Expand Down
Loading
Loading