Fixes for brazilian sources (#716)

Fixes for brazilian sources
This commit is contained in:
Alessandro Jean 2019-01-09 22:56:12 -02:00 committed by Carlos
parent 65f0403ccb
commit b993afac8d
6 changed files with 541 additions and 528 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Mangá Livre'
pkgNameSuffix = 'pt.mangalivre'
extClass = '.MangaLivre'
extVersionCode = 1
extVersionCode = 2
libVersion = '1.2'
}

View File

@ -24,18 +24,19 @@ import java.util.concurrent.TimeUnit
class MangaLivre : HttpSource() {
override val name = "MangaLivre"
override val baseUrl = "https://mangalivre.com/"
override val baseUrl = "https://mangalivre.com"
override val lang = "pt"
override val supportsLatest = true
// Sometimes the site is slow.
override val client = network.client.newBuilder()
override val client =
network.client.newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.writeTimeout(1, TimeUnit.MINUTES)
.build()!!
.build()
private val catalogHeaders = Headers.Builder().apply {
add("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")
@ -244,7 +245,7 @@ class MangaLivre : HttpSource() {
val cName = obj["chapter_name"]!!.asString
return SChapter.create().apply {
name = if (cName == "") "Capítulo " + obj["number"]!!.asString else cName
name = "Cap. ${obj["number"]!!.asString}" + (if (cName == "") "" else " - $cName")
date_upload = parseChapterDate(obj["date"].nullString)
scanlator = scan["scanlators"]!!.asJsonArray.get(0)!!.asJsonObject["name"].nullString
url = scan["link"]!!.nullString ?: ""
@ -254,7 +255,7 @@ class MangaLivre : HttpSource() {
private fun parseChapterDate(date: String?) : Long {
return try {
SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(date).time
SimpleDateFormat("dd/MM/yy", Locale.ENGLISH).parse(date).time
} catch (e: ParseException) {
0L
}

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: mangásPROJECT'
pkgNameSuffix = 'pt.mangasproject'
extClass = '.MangasProject'
extVersionCode = 1
extVersionCode = 2
libVersion = '1.2'
}

View File

@ -31,11 +31,12 @@ class MangasProject : HttpSource() {
override val supportsLatest = true
// Sometimes the site is slow.
override val client = network.client.newBuilder()
override val client =
network.client.newBuilder()
.connectTimeout(1, TimeUnit.MINUTES)
.readTimeout(1, TimeUnit.MINUTES)
.writeTimeout(1, TimeUnit.MINUTES)
.build()!!
.build()
private val catalogHeaders = Headers.Builder().apply {
add("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")
@ -244,7 +245,7 @@ class MangasProject : HttpSource() {
val cName = obj["chapter_name"]!!.asString
return SChapter.create().apply {
name = if (cName == "") "Capítulo " + obj["number"]!!.asString else cName
name = "Cap. ${obj["number"]!!.asString}" + (if (cName == "") "" else " - $cName")
date_upload = parseChapterDate(obj["date"].nullString)
scanlator = scan["scanlators"]!!.asJsonArray.get(0)!!.asJsonObject["name"].nullString
url = scan["link"]!!.nullString ?: ""
@ -254,7 +255,7 @@ class MangasProject : HttpSource() {
private fun parseChapterDate(date: String?) : Long {
return try {
SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH).parse(date).time
SimpleDateFormat("dd/MM/yy", Locale.ENGLISH).parse(date).time
} catch (e: ParseException) {
0L
}

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: Union Mangás'
pkgNameSuffix = 'pt.unionmangas'
extClass = '.UnionMangas'
extVersionCode = 4
extVersionCode = 5
libVersion = '1.2'
}

View File

@ -21,13 +21,13 @@ class UnionMangas : ParsedHttpSource() {
override val name = "Union Mangás"
override val baseUrl = "http://unionmangas.top"
override val baseUrl = "https://unionmangas.top"
override val lang = "pt"
override val supportsLatest = true
// Sometimes the site it's very slow...
// Sometimes the site is very slow.
override val client =
network.client.newBuilder()
.connectTimeout(3, TimeUnit.MINUTES)
@ -35,8 +35,6 @@ class UnionMangas : ParsedHttpSource() {
.writeTimeout(3, TimeUnit.MINUTES)
.build()
private val langRegex: String = "( )?\\(Pt-Br\\)"
private val catalogHeaders = Headers.Builder().apply {
add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64)")
add("Host", "unionmangas.top")
@ -55,7 +53,7 @@ class UnionMangas : ParsedHttpSource() {
manga.thumbnail_url = element.select("a img").first()?.attr("src")
element.select("a").last().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text().replace(langRegex.toRegex(), "")
manga.title = it.text().replace(LANG_REGEX.toRegex(), "")
}
return manga
@ -63,7 +61,7 @@ class UnionMangas : ParsedHttpSource() {
override fun popularMangaNextPageSelector() = ".pagination li:contains(Next)"
override fun latestUpdatesSelector() = "div.row[style=margin-bottom: 10px;] > div.col-md-12"
override fun latestUpdatesSelector() = "div.row[style] div.col-md-12[style]"
override fun latestUpdatesRequest(page: Int): Request {
val form = FormBody.Builder().apply {
@ -74,7 +72,16 @@ class UnionMangas : ParsedHttpSource() {
}
override fun latestUpdatesFromElement(element: Element): SManga {
return popularMangaFromElement(element)
// return popularMangaFromElement(element)
val manga = SManga.create()
val infoElements = element.select("a.link-titulo")
manga.thumbnail_url = infoElements.first()?.select("img")?.attr("src")
infoElements.last().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text().replace(LANG_REGEX.toRegex(), "")
}
return manga
}
override fun latestUpdatesNextPageSelector() = "div#linha-botao-mais"
@ -87,11 +94,11 @@ class UnionMangas : ParsedHttpSource() {
override fun searchMangaFromElement(element: Element): SManga {
val manga = SManga.create()
manga.thumbnail_url = element.select("a img.img-thumbnail").first().attr("src")
val thumbnailElement = element.select("a img.img-thumbnail").first()
manga.thumbnail_url = thumbnailElement.attr("src").replace("com.br", "top")
element.select("a").last().let {
manga.setUrlWithoutDomain(it.attr("href"))
manga.title = it.text().replace(langRegex.toRegex(), "")
manga.title = it.text().replace(LANG_REGEX.toRegex(), "")
}
return manga
@ -119,7 +126,7 @@ class UnionMangas : ParsedHttpSource() {
manga.thumbnail_url = infoElement.select(".img-thumbnail").first()?.attr("src")
// Need to grab title again because the ellipsize in search.
manga.title = infoElement.select("h2").first()!!.text().replace(langRegex.toRegex(), "")
manga.title = infoElement.select("h2").first()!!.text().replace(LANG_REGEX.toRegex(), "")
return manga
}
@ -166,4 +173,8 @@ class UnionMangas : ParsedHttpSource() {
}
override fun imageUrlParse(document: Document) = ""
companion object {
private const val LANG_REGEX = "( )?\\(Pt-Br\\)"
}
}