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 new source + Tweak #1174

Merged
merged 11 commits into from
Oct 17, 2024
Merged

Add new source + Tweak #1174

merged 11 commits into from
Oct 17, 2024

Conversation

dragonx943
Copy link
Member

@dragonx943 dragonx943 commented Oct 16, 2024

Add SayHentai (#1172), tweak DocTruyen5s and update sources domain

val doc = webClient.httpGet(fullUrl).parseHtml()

val script = doc.selectFirst("script:containsData(const CHAPTER_ID)")?.data()
?: throw Exception("Failed to get chapter id")
Copy link
Member

Choose a reason for hiding this comment

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

Do not use generic Exception class

Comment on lines 20 to 21
val script = doc.selectFirst("script:containsData(const CHAPTER_ID)")?.data()
?: throw Exception("Failed to get chapter id")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
val script = doc.selectFirst("script:containsData(const CHAPTER_ID)")?.data()
?: throw Exception("Failed to get chapter id")
val script = doc.selectFirstOrThrow("script:containsData(const CHAPTER_ID)")?.data()

val responseJson = webClient.httpGet(ajaxUrl).parseJson()

if (!responseJson.optBoolean("status", false)) {
throw Exception(responseJson.optString("msg"))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
throw Exception(responseJson.optString("msg"))
throw IllegalStateException(responseJson.optString("msg"))

return manga.copy(
altTitle = doc.selectFirst("h2.other-name")?.text(),
author = doc.selectFirst("div.summary-heading:contains(Tác giả) + div.summary-content")?.text(),
tags = doc.select("div.genres-content a[rel=tag]").mapNotNullToSet { a ->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
tags = doc.select("div.genres-content a[rel=tag]").mapNotNullToSet { a ->
tags = doc.select("div.genres-content a[rel=tag]").mapToSet { a ->

tags = doc.select("div.genres-content a[rel=tag]").mapNotNullToSet { a ->
MangaTag(
key = a.attr("href").substringAfterLast("/"),
title = a.text(),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
title = a.text(),
title = a.text().toTitleCase(sourceLocale),

author = doc.selectFirst("div.summary-heading:contains(Tác giả) + div.summary-content")?.text(),
tags = doc.select("div.genres-content a[rel=tag]").mapNotNullToSet { a ->
MangaTag(
key = a.attr("href").substringAfterLast("/"),
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
key = a.attr("href").substringAfterLast("/"),
key = a.attr("href").substringAfterLast('/'),

return tagsCache.get() ?: run {
val tags = webClient.httpGet("https://$domain/genre").parseHtml()
.select("ul.page-genres li a")
.mapNotNullToSet { a ->
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
.mapNotNullToSet { a ->
.mapToSet { a ->

val tags = webClient.httpGet("https://$domain/genre").parseHtml()
.select("ul.page-genres li a")
.mapNotNullToSet { a ->
val title = a.ownText().trim()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
val title = a.ownText().trim()
val title = a.ownText().toTitleCase(sourceLocale)

@dragonx943 dragonx943 mentioned this pull request Oct 17, 2024
3 tasks
@Koitharu Koitharu merged commit b23e241 into KotatsuApp:master Oct 17, 2024
1 check passed
@dragonx943 dragonx943 deleted the new-src branch October 17, 2024 14:20
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.

2 participants