Update MangaHost url. (#2212)

Update MangaHost url
This commit is contained in:
Alessandro Jean 2020-02-08 00:16:36 -03:00 committed by GitHub
parent 65c185f977
commit 44f10867c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 10 deletions

View File

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

View File

@ -7,6 +7,7 @@ import okhttp3.*
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import java.text.ParseException import java.text.ParseException
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Locale import java.util.Locale
@ -15,7 +16,7 @@ class MangaHost : ParsedHttpSource() {
override val name = "Manga Host" override val name = "Manga Host"
override val baseUrl = "https://mangahosted.com" override val baseUrl = "https://mangahost2.com"
override val lang = "pt" override val lang = "pt"
@ -71,9 +72,9 @@ class MangaHost : ParsedHttpSource() {
val infoElement = document.select("div#page > section > div > div.pull-left") val infoElement = document.select("div#page > section > div > div.pull-left")
return SManga.create().apply { return SManga.create().apply {
author = removeLabel(infoElement.select("li:contains(Autor:)").text()) author = infoElement.select("li:contains(Autor:)").textWithoutLabel()
artist = removeLabel(infoElement.select("li:contains(Desenho (Art):)").text()) artist = infoElement.select("li:contains(Desenho (Art):)").textWithoutLabel()
genre = removeLabel(infoElement.select("li:contains(Categoria(s):)").text()) genre = infoElement.select("li:contains(Categoria(s):)").textWithoutLabel()
description = infoElement.select("article").first()?.text() description = infoElement.select("article").first()?.text()
?.substringBefore("Relacionados:") ?.substringBefore("Relacionados:")
status = parseStatus(infoElement.select("li:contains(Status:)").text().orEmpty()) status = parseStatus(infoElement.select("li:contains(Status:)").text().orEmpty())
@ -89,8 +90,8 @@ class MangaHost : ParsedHttpSource() {
} }
override fun chapterListSelector(): String override fun chapterListSelector(): String
= "ul.list_chapters li a," + = "ul.list_chapters li a, " +
"table.table-hover:not(.table-mangas) > tbody > tr" "table.table-hover:not(.table-mangas) > tbody > tr"
override fun chapterFromElement(element: Element): SChapter { override fun chapterFromElement(element: Element): SChapter {
val isNewLayout = element.tagName() == "a" val isNewLayout = element.tagName() == "a"
@ -131,8 +132,8 @@ class MangaHost : ParsedHttpSource() {
override fun pageListRequest(chapter: SChapter): Request { override fun pageListRequest(chapter: SChapter): Request {
// Just to prevent the detection of the crawler. // Just to prevent the detection of the crawler.
val newHeader = headersBuilder() val newHeader = headersBuilder()
.set("Referer", "$baseUrl${chapter.url}".substringBeforeLast("/")) .set("Referer", "$baseUrl${chapter.url}".substringBeforeLast("/"))
.build() .build()
return GET(baseUrl + chapter.url, newHeader) return GET(baseUrl + chapter.url, newHeader)
} }
@ -159,7 +160,7 @@ class MangaHost : ParsedHttpSource() {
return GET(page.imageUrl!!, newHeaders) return GET(page.imageUrl!!, newHeaders)
} }
private fun removeLabel(text: String?): String = text!!.substringAfter(":") private fun Elements.textWithoutLabel(): String = text()!!.substringAfter(":")
companion object { companion object {
private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36" private const val USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.92 Safari/537.36"