NewToki - fix pages (#4156)

This commit is contained in:
Mike 2020-08-18 00:17:48 -04:00 committed by GitHub
parent dfc91f27b2
commit e1cabf0d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 22 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = 'NewToki'
pkgNameSuffix = 'ko.newtoki'
extClass = '.NewTokiFactory'
extVersionCode = 11
extVersionCode = 12
libVersion = '1.2'
}

View File

@ -155,7 +155,7 @@ open class NewToki(override val name: String, private val defaultBaseUrl: String
calendar.timeInMillis
} else {
SimpleDateFormat("yyyy.MM.dd").parse(date).time
SimpleDateFormat("yyyy.MM.dd").parse(date)?.time ?: 0
}
} catch (e: Exception) {
e.printStackTrace()
@ -164,22 +164,9 @@ open class NewToki(override val name: String, private val defaultBaseUrl: String
}
override fun pageListParse(document: Document): List<Page> {
val pages = mutableListOf<Page>()
try {
document.select(".view-padding img")
.map {
val origin = it.attr("data-original")
if (origin.isNullOrEmpty()) it.attr("content") else origin
}
.forEach {
val url = if (it.contains("://")) it else baseUrl + it
pages.add(Page(pages.size, "", url))
}
} catch (e: Exception) {
e.printStackTrace()
}
return pages
return document.select("article > div > div > img")
.filterNot { it.attr("data-original").contains("blank.gif") }
.mapIndexed { i, img -> Page(i, "", img.attr("abs:data-original")) }
}
override fun latestUpdatesSelector() = popularMangaSelector()

View File

@ -5,18 +5,20 @@ import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import eu.kanade.tachiyomi.source.model.Page
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import okhttp3.HttpUrl
import okhttp3.Request
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
/**
* Source changes domain names approximately once every 10 days (e.g. newtoki31.net to newtoki32.net)
* The domain name was newtoki32 on 2019-11-14, this should increment that by 1 for every 10 days that pass
* If that rate holds and the code is correct, this should be accurate for a good while
* Source changes domain names every few days (e.g. newtoki31.net to newtoki32.net)
* The domain name was newtoki32 on 2019-11-14, this attempts to match the rate at which the domain changes
*/
private val domainNumber = 32 + ((Date().time - SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2019-11-14").time) / 864000000)
private val domainNumber = 32 + ((Date().time - SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2019-11-14")!!.time) / 595000000)
class NewTokiFactory : SourceFactory {
override fun createSources(): List<Source> = listOf(
@ -47,6 +49,20 @@ class NewTokiWebtoon : NewToki("NewToki (Webtoon)", "https://newtoki$domainNumbe
return GET(url.toString())
}
private val htmlDataRegex = Regex("""html_data\+='([^']+)'""")
override fun pageListParse(document: Document): List<Page> {
val script = document.select("script:containsData(html_data)").firstOrNull()?.data() ?: throw Exception("script not found")
return htmlDataRegex.findAll(script).map { it.groupValues[1] }
.asIterable()
.flatMap { it.split(".") }
.joinToString("") { it.toIntOrNull(16)?.toChar()?.toString() ?: "" }
.let { Jsoup.parse(it) }
.select("img[alt]")
.mapIndexed { i, img -> Page(i, "", img.attr("abs:data-original")) }
}
private class SearchTypeList : Filter.Select<String>("Type", arrayOf("전체", "일반웹툰", "성인웹툰", "BL/GL", "완결웹툰"))
override fun getFilterList() = FilterList(