Gmanga Multisrc: make cover nullable (#1854)

* Gmanga Multisrc: make cover nullable

* filter empty alt titles
This commit is contained in:
AwkwardPeak7 2024-03-13 16:16:46 +05:00 committed by Draff
parent 5ad927dbf4
commit f2f809f35d
2 changed files with 7 additions and 5 deletions

View File

@ -2,4 +2,4 @@ plugins {
id("lib-multisrc") id("lib-multisrc")
} }
baseVersionCode = 1 baseVersionCode = 2

View File

@ -29,12 +29,12 @@ class SearchMangaDto(
class BrowseManga( class BrowseManga(
private val id: Int, private val id: Int,
private val title: String, private val title: String,
private val cover: String, private val cover: String? = null,
) { ) {
fun toSManga(createThumbnail: (String, String) -> String) = SManga.create().apply { fun toSManga(createThumbnail: (String, String) -> String) = SManga.create().apply {
url = "/mangas/$id" url = "/mangas/$id"
title = this@BrowseManga.title title = this@BrowseManga.title
thumbnail_url = createThumbnail(id.toString(), cover) thumbnail_url = cover?.let { createThumbnail(id.toString(), cover) }
} }
} }
@ -58,7 +58,7 @@ class MangaDetailsDto(
@Serializable @Serializable
class Manga( class Manga(
private val id: Int, private val id: Int,
private val cover: String, private val cover: String? = null,
private val title: String, private val title: String,
private val summary: String? = null, private val summary: String? = null,
private val artists: List<NameDto>, private val artists: List<NameDto>,
@ -74,7 +74,7 @@ class Manga(
) { ) {
fun toSManga(createThumbnail: (String, String) -> String) = SManga.create().apply { fun toSManga(createThumbnail: (String, String) -> String) = SManga.create().apply {
title = this@Manga.title title = this@Manga.title
thumbnail_url = createThumbnail(id.toString(), cover) thumbnail_url = cover?.let { createThumbnail(id.toString(), cover) }
artist = artists.joinToString { it.name } artist = artists.joinToString { it.name }
author = authors.joinToString { it.name } author = authors.joinToString { it.name }
status = when (this@Manga.status) { status = when (this@Manga.status) {
@ -105,6 +105,8 @@ class Manga(
} }
val titles = listOfNotNull(synonyms, arTitle, jpTitle, enTitle) val titles = listOfNotNull(synonyms, arTitle, jpTitle, enTitle)
.filterNot(String::isEmpty)
if (titles.isNotEmpty()) { if (titles.isNotEmpty()) {
append("\n\n") append("\n\n")
append("مسميّات أخرى") append("مسميّات أخرى")