From e55fb1a7feaf08d9bfd9fe18de92796ccec7fad2 Mon Sep 17 00:00:00 2001
From: AntsyLich <59261191+AntsyLich@users.noreply.github.com>
Date: Mon, 1 May 2023 03:29:40 +0600
Subject: [PATCH] Webnovel updates (#16246)

Add On Hiatus status and update cycle to description
---
 src/en/webnovel/build.gradle                      |  2 +-
 .../tachiyomi/extension/en/webnovel/Webnovel.kt   | 14 +++++++++++---
 .../extension/en/webnovel/WebnovelDto.kt          | 15 +++++++++++----
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/src/en/webnovel/build.gradle b/src/en/webnovel/build.gradle
index ecbbefc25..0c5705707 100644
--- a/src/en/webnovel/build.gradle
+++ b/src/en/webnovel/build.gradle
@@ -6,7 +6,7 @@ ext {
     extName = 'Webnovel.com'
     pkgNameSuffix = 'en.webnovel'
     extClass = '.Webnovel'
-    extVersionCode = 7
+    extVersionCode = 8
 }
 
 apply from: "$rootDir/common.gradle"
diff --git a/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/Webnovel.kt b/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/Webnovel.kt
index 42e0e0f55..1e8b83169 100644
--- a/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/Webnovel.kt
+++ b/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/Webnovel.kt
@@ -22,6 +22,7 @@ import uy.kohesive.injekt.injectLazy
 import java.io.IOException
 import java.util.Calendar
 import java.util.Date
+import java.util.Locale
 
 class Webnovel : HttpSource() {
 
@@ -130,11 +131,18 @@ class Webnovel : HttpSource() {
             url = comic.id
             thumbnail_url = getCoverUrl(comic.id)
             author = comic.authorName
-            description = comic.description
+            description = buildString {
+                append(comic.description)
+                if (comic.actionStatus == ComicDetailInfoDto.ONGOING && comic.updateCycle.isNotBlank()) {
+                    append("\n\nInformation:")
+                    append("\n• ${comic.updateCycle.replaceFirstChar { it.uppercase(Locale.ENGLISH) }}")
+                }
+            }
             genre = comic.categoryName
             status = when (comic.actionStatus) {
-                1 -> SManga.ONGOING
-                2 -> SManga.COMPLETED
+                ComicDetailInfoDto.ONGOING -> SManga.ONGOING
+                ComicDetailInfoDto.COMPLETED -> SManga.COMPLETED
+                ComicDetailInfoDto.ON_HIATUS -> SManga.ON_HIATUS
                 else -> SManga.UNKNOWN
             }
         }
diff --git a/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/WebnovelDto.kt b/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/WebnovelDto.kt
index 8ab1a0fe2..1e4b1c347 100644
--- a/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/WebnovelDto.kt
+++ b/src/en/webnovel/src/eu/kanade/tachiyomi/extension/en/webnovel/WebnovelDto.kt
@@ -41,7 +41,14 @@ data class ComicDetailInfoDto(
     val authorName: String,
     val categoryName: String,
     val description: String,
-)
+    val updateCycle: String,
+) {
+    companion object {
+        const val ONGOING = 1
+        const val COMPLETED = 2
+        const val ON_HIATUS = 3
+    }
+}
 
 @Serializable
 data class ComicChapterListDto(
@@ -63,17 +70,17 @@ data class ComicChapterDto(
 
 @Serializable
 data class ChapterContentResponseDto(
-    @SerialName("chapterInfo") val chapterContent: ChapterContentDto
+    @SerialName("chapterInfo") val chapterContent: ChapterContentDto,
 )
 
 @Serializable
 data class ChapterContentDto(
     @SerialName("chapterId") val id: Long,
-    @SerialName("chapterPage") val pages: List<ChapterPageDto>
+    @SerialName("chapterPage") val pages: List<ChapterPageDto>,
 )
 
 @Serializable
 data class ChapterPageDto(
     @SerialName("pageId") val id: String,
-    val url: String
+    val url: String,
 )