Skip to content

Commit

Permalink
Fix kuaikanmanhua not getting chapters
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeZeDev authored Nov 20, 2022
1 parent e68af1f commit 6a1558c
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions src/web/mjs/connectors/kuaikanmanhua.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,41 @@ export default class Kuaikanmanhua extends Connector {
}

async _getChapterList(manga, callback) {
let chapterList = await this.resolveChapterList(manga, 'comics');
if (chapterList.length < 1) {
chapterList = await this.resolveChapterList(manga, 'comicList');
}
if (chapterList.length < 1) {
console.error('No chapters found !', this);
callback( error, undefined );
return;
}
callback(null, chapterList);
}

async resolveChapterList(manga, objname) {
let chapterList = [];
try {
let script = `
new Promise(resolve => {
let pages = __NUXT__.data[0].`+objname+`.map( comic => {
return {
id : '/web/comic/'+comic.id,
title: comic.title.trim()
};
}).reverse();
resolve(pages);
});
`;
let request = new Request(this.url + manga.id, this.requestOptions);
let data = await this.fetchDOM(request, 'div.TopicList div div.TopicItem div.title a');
let chapterList = data.map(element => {
return {
id: this.getRootRelativeOrAbsoluteLink(element, request.url),
title: element.text.trim(),
language: ''
};
}).filter(chapter => chapter.id !== 'javascript:void(0);');
callback(null, chapterList);
} catch (error) {
chapterList = await Engine.Request.fetchUI(request, script);
}
catch (error) {
console.error(error, manga);
callback(error, undefined);
}
return chapterList;
}

async _getPageList(manga, chapter, callback) {
let newRequestOptions = Object.assign({}, this.requestOptions);
newRequestOptions.headers.set(
Expand All @@ -98,4 +116,4 @@ export default class Kuaikanmanhua extends Connector {
callback(error, undefined);
}
}
}
}

0 comments on commit 6a1558c

Please sign in to comment.