Skip to content

Commit

Permalink
More fixes for https://kakuyomu.jp/
Browse files Browse the repository at this point in the history
See: #1131
1. Handle episodes with no "arc".
2. Extract Author.
  • Loading branch information
dteviot committed Dec 5, 2023
1 parent 20654d1 commit b24736c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions plugin/js/parsers/KakuyomuParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,12 @@ class KakuyomuParser extends Parser{
}

buildSubToc(chapters, tocc, json, baseURI) {
let chapter = json[tocc.chapter.__ref];
let arcStart = true;
let arcStartIndex = chapters.length;
for(let episoderef of tocc.episodes) {
let episode = this.buildEpisode(json[episoderef.__ref], baseURI);
if (arcStart) {
episode.newArc = chapter.title;
arcStart = false;
}
chapters.push(episode);
}
this.addArcTitleToEpisode(chapters[arcStartIndex], tocc, json);
}

buildEpisode(episode, baseURI) {
Expand All @@ -48,6 +44,13 @@ class KakuyomuParser extends Parser{
});
}

addArcTitleToEpisode(episode, tocc, json) {
let id = tocc?.chapter?.__ref;
if (id && episode) {
episode.newArc = json[id].title;
}
}

findContent(dom) {
return dom.querySelector("div.widget-episode");
}
Expand All @@ -56,6 +59,11 @@ class KakuyomuParser extends Parser{
return dom.querySelector("a[title]");
}

extractAuthor(dom) {
let authorLabel = dom.querySelector(".partialGiftWidgetActivityName a");
return (authorLabel === null) ? super.extractAuthor(dom) : authorLabel.textContent;
}

findChapterTitle(dom) {
let title = "";
let chapterTitle = dom.querySelector("p.chapterTitle");
Expand Down

0 comments on commit b24736c

Please sign in to comment.