Fix MangaPark image URLs and some code cleanup (#159)

* Fix MangaPark image URLs and some code cleanup

* Upgrade version

* Update version code
This commit is contained in:
Andy Bao 2018-01-23 19:27:31 -05:00 committed by inorichi
parent 2a91527e91
commit c25282c36d
2 changed files with 12 additions and 8 deletions

View File

@ -5,8 +5,8 @@ ext {
appName = 'Tachiyomi: MangaPark'
pkgNameSuffix = "en.mangapark"
extClass = '.MangaPark'
extVersionCode = 1
extVersionSuffix = 1
extVersionCode = 2
extVersionSuffix = 2
libVersion = '1.0'
}

View File

@ -30,13 +30,17 @@ class MangaPark : ParsedHttpSource() {
override fun popularMangaSelector() = directorySelector
private fun cleanUrl(url: String) = if (url.startsWith("//"))
"http:$url"
else url
private fun mangaFromElement(element: Element) = SManga.create().apply {
val coverElement = element.getElementsByClass("cover").first()
url = coverElement.attr("href")
title = coverElement.attr("title")
thumbnail_url = coverElement.getElementsByTag("img").attr("src")
thumbnail_url = cleanUrl(coverElement.getElementsByTag("img").attr("src"))
}
override fun popularMangaFromElement(element: Element) = mangaFromElement(element)
@ -73,7 +77,7 @@ class MangaPark : ParsedHttpSource() {
title = coverElement.attr("title")
thumbnail_url = coverElement.attr("src")
thumbnail_url = cleanUrl(coverElement.attr("src"))
document.select(".attr > tbody > tr").forEach {
val type = it.getElementsByTag("th").first().text().trim().toLowerCase()
@ -117,14 +121,14 @@ class MangaPark : ParsedHttpSource() {
private fun parseDate(date: String): Long {
val lcDate = date.toLowerCase()
if(lcDate.endsWith("ago")) return parseRelativeDate(lcDate)
if (lcDate.endsWith("ago")) return parseRelativeDate(lcDate)
//Handle 'yesterday' and 'today'
var relativeDate: Calendar? = null
if(lcDate.startsWith("yesterday")) {
if (lcDate.startsWith("yesterday")) {
relativeDate = Calendar.getInstance()
relativeDate.add(Calendar.DAY_OF_MONTH, -1) //yesterday
} else if(lcDate.startsWith("today")) {
} else if (lcDate.startsWith("today")) {
relativeDate = Calendar.getInstance()
}
@ -176,7 +180,7 @@ class MangaPark : ParsedHttpSource() {
override fun pageListParse(document: Document)
= document.getElementsByClass("img").map {
Page(it.attr("i").toInt() - 1, "", it.attr("src"))
Page(it.attr("i").toInt() - 1, "", cleanUrl(it.attr("src")))
}
//Unused, we can get image urls directly from the chapter page