Skip to content

Commit

Permalink
MangaDemon: Fix bad url in some entries (#4861)
Browse files Browse the repository at this point in the history
* smh

* change var name
  • Loading branch information
bapeey authored Aug 31, 2024
1 parent 39404ca commit c7b8049
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/en/mangademon/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ext {
extName = 'Manga Demon'
extClass = '.MangaDemon'
extVersionCode = 13
extVersionCode = 14
isNsfw = false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import okhttp3.Response
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element
import rx.Observable
import java.net.URLEncoder
import java.text.ParseException
import java.text.SimpleDateFormat
import java.util.Locale
Expand Down Expand Up @@ -44,7 +45,7 @@ class MangaDemon : ParsedHttpSource() {
override fun popularMangaSelector() = "div#advanced-content > div.advanced-element"

override fun popularMangaFromElement(element: Element) = SManga.create().apply {
setUrlWithoutDomain(element.selectFirst("a")!!.attr("abs:href"))
setUrlWithoutDomain(element.selectFirst("a")!!.encodedAttr("href"))
title = element.selectFirst("h1")!!.ownText()
thumbnail_url = element.selectFirst("img")?.attr("abs:src")
}
Expand All @@ -59,7 +60,7 @@ class MangaDemon : ParsedHttpSource() {

override fun latestUpdatesFromElement(element: Element) = SManga.create().apply {
with(element.selectFirst("div.updates-element-info")!!) {
setUrlWithoutDomain(selectFirst("a")!!.attr("abs:href"))
setUrlWithoutDomain(selectFirst("a")!!.encodedAttr("href"))
title = selectFirst("a")!!.ownText()
}
thumbnail_url = element.selectFirst("div.thumb img")!!.attr("abs:src")
Expand Down Expand Up @@ -87,7 +88,7 @@ class MangaDemon : ParsedHttpSource() {
override fun searchMangaNextPageSelector() = null

override fun searchMangaFromElement(element: Element) = SManga.create().apply {
setUrlWithoutDomain(element.attr("abs:href"))
setUrlWithoutDomain(element.encodedAttr("href"))
title = element.selectFirst("div.seach-right > div")!!.ownText()
thumbnail_url = element.selectFirst("img")!!.attr("abs:src")
}
Expand Down Expand Up @@ -141,7 +142,7 @@ class MangaDemon : ParsedHttpSource() {
override fun chapterListSelector() = "div#chapters-list a.chplinks"

override fun chapterFromElement(element: Element) = SChapter.create().apply {
setUrlWithoutDomain(element.attr("abs:href"))
setUrlWithoutDomain(element.encodedAttr("href"))
name = element.ownText()
date_upload = parseDate(element.selectFirst("span")?.ownText())
}
Expand All @@ -160,6 +161,8 @@ class MangaDemon : ParsedHttpSource() {
}
}

private fun Element.encodedAttr(attribute: String) = URLEncoder.encode(attr(attribute), "UTF-8")

override fun imageUrlParse(document: Document): String = throw UnsupportedOperationException()

companion object {
Expand Down

0 comments on commit c7b8049

Please sign in to comment.