Feat/wuxiadreams add new plugin#2169
Conversation
# Conflicts: # plugins/english/wuxiadreams.ts
|
@K1ngfish3r Could you check if I need to improve my code at all? |
K1ngfish3r
left a comment
There was a problem hiding this comment.
- image needs to be 96x96 pixels
- use URL method for constructing URLs https://developer.mozilla.org/en-US/docs/Web/API/URL, resolveURL is from a time when hermes did not support URL method
- the filters went poof for whatever reason
- the summary error is from a JSON parse error, wrapping in divs is not required
- the POST request can be made by adding novelId to the end of novel.path in parseNovels, novelId can be obtained from the cover url
you can request a review by clicking here (no suggestions for me as I am not PR creator)
rather than closing the PR, you can convert to draft if you are still working on it, and request for review when done
| ): Promise<Plugin.NovelItem[]> { | ||
| let url = `${this.site}novels?page=${pageNo}`; | ||
|
|
||
| if (filters.sort?.value) { |
There was a problem hiding this comment.
What happened to filters?
| // Wrap in <div> to prevent selector parsing errors on plain text | ||
| const summary = $('<div>' + (summaryElement.html() || '') + '</div>'); |
There was a problem hiding this comment.
summaryElement.html() is already from an html, this is not required as the response did not come from a json
| cover: this.resolveUrl(cover), | ||
| path: url.replace(/^\//, ''), |
There was a problem hiding this comment.
Can use URL method instead
| novel.chapters = this.parseChapters($); | ||
|
|
||
| // Pagination | ||
| const lastPageLink = $('a[aria-label="Last page"]').attr('href'); | ||
| if (lastPageLink) { | ||
| const match = lastPageLink.match(/page=(\d+)/); | ||
| if (match) { | ||
| novel.totalPages = parseInt(match[1], 10); | ||
| } | ||
| } else { | ||
| const pageText = $('div:contains("Page")').text(); | ||
| const match = pageText.match(/Page\s+\d+\s+of\s+(\d+)/); | ||
| if (match) { | ||
| novel.totalPages = parseInt(match[1], 10); | ||
| } | ||
| } |
There was a problem hiding this comment.
can change to POST request, rather than fetching all these GETs, good for environment
but it'll involve smuggling novelId from parseNovels, which is possible
| private resolveUrl(path?: string) { | ||
| if (!path) return undefined; | ||
| return path.startsWith('http') ? path : this.site + path.replace(/^\//, ''); | ||
| } |
There was a problem hiding this comment.
can use URL method instead of this function
Checklist
This PR adds a new plugin for Wuxia Dreams (wuxiadreams.com), apopular English novel site.
close #2159