From b3707d3b6fc012996ffc573d4a37590f6520809d Mon Sep 17 00:00:00 2001 From: vaginadesolator <76472350+vaginadesolator@users.noreply.github.com> Date: Fri, 15 Jan 2021 11:19:02 +0800 Subject: [PATCH] Add simply hentai ext chapter upload date (#5421) * Set default status as completed * Parse manga date and set as chapter attribute * Bump simply-hentai version --- src/all/simplyhentai/build.gradle | 2 +- .../all/simplyhentai/SimplyHentai.kt | 26 +++++++++++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/all/simplyhentai/build.gradle b/src/all/simplyhentai/build.gradle index 50e9ad9c9..841078eb3 100644 --- a/src/all/simplyhentai/build.gradle +++ b/src/all/simplyhentai/build.gradle @@ -5,7 +5,7 @@ ext { extName = 'Simply Hentai' pkgNameSuffix = 'all.simplyhentai' extClass = '.SimplyHentaiFactory' - extVersionCode = 1 + extVersionCode = 2 libVersion = '1.2' containsNsfw = true } diff --git a/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt b/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt index b70519f37..32284f862 100644 --- a/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt +++ b/src/all/simplyhentai/src/eu/kanade/tachiyomi/extension/all/simplyhentai/SimplyHentai.kt @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.extension.all.simplyhentai +import android.annotation.SuppressLint import com.github.salomonbrys.kotson.forEach import com.github.salomonbrys.kotson.fromJson import com.github.salomonbrys.kotson.get @@ -13,12 +14,14 @@ import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.online.ParsedHttpSource +import eu.kanade.tachiyomi.util.asJsoup import okhttp3.HttpUrl import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.Response import org.jsoup.nodes.Document import org.jsoup.nodes.Element +import java.text.SimpleDateFormat abstract class SimplyHentai( override val lang: String, @@ -119,6 +122,7 @@ abstract class SimplyHentai( manga.description += info.select("div.link-box > div.box-title:contains(Characters) ~ a").let { e -> if (e.text().isNotEmpty()) ("Characters: ${e.joinToString { it.text() }}\n\n") else "" } + manga.status = SManga.COMPLETED } manga.thumbnail_url = document.select("div.col-xs-12 img.img-responsive").attr("abs:data-src") @@ -128,11 +132,17 @@ abstract class SimplyHentai( // Chapters override fun chapterListParse(response: Response): List { - val chapter = SChapter.create().apply { - name = "Chapter" - url = response.request().url().toString().removeSuffix("/").substringAfterLast("/") - } - return listOf(chapter) + return listOf( + SChapter.create().apply { + name = "Chapter" + url = response.request().url().toString().removeSuffix("/").substringAfterLast("/") + chapter_number = 1f + + date_upload = response.asJsoup().select(".stat-container div:contains(Uploaded) div.bold")?.text().let { + DATE_FORMAT.parse(it!!)?.time + } ?: 0L + } + ) } override fun chapterListSelector() = "not used" @@ -199,4 +209,10 @@ abstract class SimplyHentai( SearchPair("Granblue Fantasy", "2041"), SearchPair("Girls Und Panzer", "1324") ) + + companion object { + + @SuppressLint("SimpleDateFormat") + private val DATE_FORMAT = SimpleDateFormat("dd.MM.yyyy") + } }