Fix thumbnails not showing at MangaHost. (#2663)

This commit is contained in:
Alessandro Jean 2020-04-13 18:26:02 -03:00 committed by GitHub
parent b220477525
commit 7a09f9fc17
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 15 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: MangaHost'
pkgNameSuffix = 'pt.mangahost'
extClass = '.MangaHost'
extVersionCode = 8
extVersionCode = 9
libVersion = '1.2'
}

View File

@ -37,12 +37,16 @@ class MangaHost : ParsedHttpSource() {
thumbnail_url = element.select("img.manga")
.attr(if (lazy) "data-path" else "src")
.toLargeUrl()
setUrlWithoutDomain(element.attr("href"))
setUrlWithoutDomain(element.attr("href").substringBeforeLast("-mh"))
}
override fun popularMangaRequest(page: Int): Request {
val newHeaders = headersBuilder()
.set("Referer", "$baseUrl/mangas" + (if (page == 1) "" else "/mais-visualizados/page/${page - 1}"))
.build()
val pageStr = if (page != 1) "/page/$page" else ""
return GET("$baseUrl/mangas/mais-visualizados$pageStr", headers)
return GET("$baseUrl/mangas/mais-visualizados$pageStr", newHeaders)
}
override fun popularMangaSelector(): String = "div.thumbnail div a.pull-left"
@ -52,8 +56,12 @@ class MangaHost : ParsedHttpSource() {
override fun popularMangaNextPageSelector() = "div.wp-pagenavi:has(a.nextpostslink)"
override fun latestUpdatesRequest(page: Int): Request {
val newHeaders = headersBuilder()
.set("Referer", baseUrl + (if (page == 1) "" else "/lancamentos/page/${page - 1}"))
.build()
val pageStr = if (page != 1) "/page/$page" else ""
return GET("$baseUrl/lancamentos$pageStr", headers)
return GET("$baseUrl/lancamentos$pageStr", newHeaders)
}
override fun latestUpdatesSelector() = "table.table-lancamentos > tbody > tr > td:eq(0) > a"
@ -111,7 +119,7 @@ class MangaHost : ParsedHttpSource() {
return SChapter.create().apply {
name = element.attr("data-original-title").withoutLanguage()
scanlator = content.select("small.clearfix strong").text()
date_upload = parseChapterDate(date, DATE_FORMAT_NEW)
date_upload = DATE_FORMAT_NEW.tryParseTime(date)
chapter_number = element.text().toFloatOrNull() ?: 1f
setUrlWithoutDomain(content.select("div.clearfix a").attr("href"))
}
@ -124,19 +132,11 @@ class MangaHost : ParsedHttpSource() {
return SChapter.create().apply {
name = firstColumn.select("a").text().withoutLanguage()
scanlator = secondColumn.text()
date_upload = parseChapterDate(thirdColumn.text(), DATE_FORMAT_OLD)
date_upload = DATE_FORMAT_OLD.tryParseTime(thirdColumn.text())
setUrlWithoutDomain(firstColumn.select("a").attr("href"))
}
}
private fun parseChapterDate(date: String, formatter: SimpleDateFormat) : Long {
return try {
formatter.parse(date).time
} catch (e: ParseException) {
0L
}
}
override fun pageListRequest(chapter: SChapter): Request {
// Just to prevent the detection of the crawler.
val newHeader = headersBuilder()
@ -170,9 +170,17 @@ class MangaHost : ParsedHttpSource() {
return GET(page.imageUrl!!, newHeaders)
}
private fun SimpleDateFormat.tryParseTime(date: String) : Long {
return try {
parse(date).time
} catch (e: ParseException) {
0L
}
}
private fun String.withoutLanguage(): String = replace(LANG_REGEX, "")
private fun String.toLargeUrl(): String = replace(IMAGE_REGEX, "_large")
private fun String.toLargeUrl(): String = replace(IMAGE_REGEX, "_large.")
private fun Elements.textWithoutLabel(): String = text()!!.substringAfter(":")