NewToki domain update (#1783)

NewToki domain update
This commit is contained in:
Mike 2019-11-14 07:22:28 -05:00 committed by arkon
parent 685ac1ff01
commit ff98102d69
2 changed files with 12 additions and 4 deletions

View File

@ -5,7 +5,7 @@ ext {
appName = 'Tachiyomi: NewToki'
pkgNameSuffix = 'ko.newtoki'
extClass = '.NewTokiFactory'
extVersionCode = 9
extVersionCode = 10
libVersion = '1.2'
}

View File

@ -7,8 +7,16 @@ import eu.kanade.tachiyomi.source.model.Filter
import eu.kanade.tachiyomi.source.model.FilterList
import okhttp3.HttpUrl
import okhttp3.Request
import java.text.SimpleDateFormat
import java.util.Locale
import java.util.Date
private const val baseDomain = "newtoki26"
/**
* 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
*/
private val domainNumber = 32 + ((Date().time - SimpleDateFormat("yyyy-MM-dd", Locale.US).parse("2019-11-14").time) / 864000000)
class NewTokiFactory : SourceFactory {
override fun createSources(): List<Source> = listOf(
@ -17,9 +25,9 @@ class NewTokiFactory : SourceFactory {
)
}
class NewTokiManga : NewToki("NewToki", "https://$baseDomain.net", "comic")
class NewTokiManga : NewToki("NewToki", "https://newtoki$domainNumber.net", "comic")
class NewTokiWebtoon : NewToki("NewToki (Webtoon)", "https://$baseDomain.com", "webtoon") {
class NewTokiWebtoon : NewToki("NewToki (Webtoon)", "https://newtoki$domainNumber.com", "webtoon") {
override fun searchMangaRequest(page: Int, query: String, filters: FilterList): Request {
val url = HttpUrl.parse("$baseUrl/webtoon" + (if (page > 1) "/p$page" else ""))!!.newBuilder()
filters.forEach { filter ->