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

Add KunMangaTo source #6192

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add KunMangaTo source #6192

wants to merge 2 commits into from

Conversation

gtament
Copy link

@gtament gtament commented Nov 20, 2024

Checklist:

  • Updated extVersionCode value in build.gradle for individual extensions
  • Updated overrideVersionCode or baseVersionCode as needed for all multisrc extensions
  • Referenced all related issues in the PR body (e.g. "Closes #xyz")
  • Added the isNsfw = true flag in build.gradle when appropriate
  • Have not changed source names
  • Have explicitly kept the id if a source's name or language were changed
  • Have tested the modifications by compiling and running the extension through Android Studio
  • Have removed web_hi_res_512.png when adding a new extension

@gtament
Copy link
Author

gtament commented Nov 21, 2024

@bapeey Pushed fixes in a separate commit. Will squash and force push in this branch after code's approval, if you don't mind (maybe I don't even need to be that specific of my actions)
Thanks for taking your time to review my code! I truly appreciate that
Also sorry for confusing you, by making several replies from another account (digis4eva)

@bapeey
Copy link
Contributor

bapeey commented Nov 21, 2024

All commits are squashed during the merge process, so don't worry about that

val a = element.selectFirst("a.manga")!!
return SManga.create().apply {
title = a.text()
url = a.attr("href").removePrefix(baseUrl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
url = a.attr("href").removePrefix(baseUrl)
setUrlWithoutDomain(a.absUrl("href"))

author = document.selectFirst("p.mb-1:nth-child(1)")!!.text().drop(9)
description = document.getElementById("manga-description")!!.text()
genre =
document.select("a.manga-genre").joinToString(", ") { element -> element.text() }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

", " is already the default join operation, so no need to specify

Comment on lines +109 to +110
val chaptersDocument =
Jsoup.parse("<div>" + document.selectFirst(chapterListSelector())!!.attr("value") + "</div>")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use Jsoup.parseBodyFragment instead.
(won't need to add div tag manually i think)


override fun chapterFromElement(element: Element): SChapter {
return SChapter.create().apply {
url = element.getElementsByTag("a").first()!!.attr("href").removePrefix(baseUrl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setUrlWithoutDomain here too

also use selectFirst instead of calling first()

extName = 'KunMangaTo'
extClass = '.KunMangaTo'
extVersionCode = 1
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be marked as NSFW since they carry 'He Does a Body Good'.

document.select("a.manga-genre").joinToString(", ") { element -> element.text() }
status =
if (document.select(".text-success").size > 0) SManga.COMPLETED else SManga.ONGOING
thumbnail_url = document.selectFirst("img.text-end")!!.attr("src")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thumbnail_url should be optional.

genre =
document.select("a.manga-genre").joinToString(", ") { element -> element.text() }
status =
if (document.select(".text-success").size > 0) SManga.COMPLETED else SManga.ONGOING
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat flaky. Since it is so generic it will cause issues if the layout changes slightly. It would be preferable if it's SManga.UNKOWN by default, and only set to either completed or ongoing if found.

The document is a bit difficult to navigate, but you can rely on Jsoup's selectors:

*:has(~ #manga-description) p span:contains(Status:) ~ span

return SChapter.create().apply {
url = element.getElementsByTag("a").first()!!.attr("href").removePrefix(baseUrl)
name = element.getElementsByTag("h3").first()!!.text()
date_upload = element.selectFirst(".text-muted")!!.text().parseChapterDate()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

date_upload should be optional.

val form = FormBody.Builder()
.add(
"chapterIdx",
response.request.url.toString().substringBefore(".html").substringAfterLast("-"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract to variable. Consider using regex.

val document = response.asJsoup()
val chapterIdx = response.request.url.toString().substringBefore(".html").substringAfterLast("-")
val form = FormBody.Builder()
    .add("chapterIdx", chapterIdx)
    .build()

val chaptersRequest = POST(
// ...

@vetleledaal vetleledaal marked this pull request as draft November 28, 2024 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants