Update parsers and adjust fields nullability
This commit is contained in:
@@ -22,7 +22,7 @@ fun Collection<TagEntity>.toMangaTags() = mapToSet(TagEntity::toMangaTag)
|
|||||||
|
|
||||||
fun Collection<TagEntity>.toMangaTagsList() = map(TagEntity::toMangaTag)
|
fun Collection<TagEntity>.toMangaTagsList() = map(TagEntity::toMangaTag)
|
||||||
|
|
||||||
fun MangaEntity.toManga(tags: Set<MangaTag>, chapters: List<ChapterEntity>?) = Manga(
|
fun MangaEntity.toManga(tags: Set<MangaTag>, chapters: List<ChapterEntity>?) = Manga( // TODO
|
||||||
id = this.id,
|
id = this.id,
|
||||||
title = this.title,
|
title = this.title,
|
||||||
altTitle = this.altTitle,
|
altTitle = this.altTitle,
|
||||||
@@ -65,7 +65,7 @@ fun Manga.toEntity() = MangaEntity(
|
|||||||
publicUrl = publicUrl,
|
publicUrl = publicUrl,
|
||||||
source = source.name,
|
source = source.name,
|
||||||
largeCoverUrl = largeCoverUrl,
|
largeCoverUrl = largeCoverUrl,
|
||||||
coverUrl = coverUrl,
|
coverUrl = coverUrl.orEmpty(),
|
||||||
altTitle = altTitle,
|
altTitle = altTitle,
|
||||||
rating = rating,
|
rating = rating,
|
||||||
isNsfw = isNsfw,
|
isNsfw = isNsfw,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ data class MangaEntity(
|
|||||||
@ColumnInfo(name = "url") val url: String,
|
@ColumnInfo(name = "url") val url: String,
|
||||||
@ColumnInfo(name = "public_url") val publicUrl: String,
|
@ColumnInfo(name = "public_url") val publicUrl: String,
|
||||||
@ColumnInfo(name = "rating") val rating: Float, // normalized value [0..1] or -1
|
@ColumnInfo(name = "rating") val rating: Float, // normalized value [0..1] or -1
|
||||||
@ColumnInfo(name = "nsfw") val isNsfw: Boolean,
|
@ColumnInfo(name = "nsfw") val isNsfw: Boolean, // TODO change to contentRating
|
||||||
@ColumnInfo(name = "cover_url") val coverUrl: String,
|
@ColumnInfo(name = "cover_url") val coverUrl: String,
|
||||||
@ColumnInfo(name = "large_cover_url") val largeCoverUrl: String?,
|
@ColumnInfo(name = "large_cover_url") val largeCoverUrl: String?,
|
||||||
@ColumnInfo(name = "state") val state: String?,
|
@ColumnInfo(name = "state") val state: String?,
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class ExternalPluginContentSource(
|
|||||||
publicUrl = details.publicUrl.ifEmpty { manga.publicUrl },
|
publicUrl = details.publicUrl.ifEmpty { manga.publicUrl },
|
||||||
rating = maxOf(details.rating, manga.rating),
|
rating = maxOf(details.rating, manga.rating),
|
||||||
isNsfw = details.isNsfw,
|
isNsfw = details.isNsfw,
|
||||||
coverUrl = details.coverUrl.ifEmpty { manga.coverUrl },
|
coverUrl = details.coverUrl.ifNullOrEmpty { manga.coverUrl },
|
||||||
tags = details.tags + manga.tags,
|
tags = details.tags + manga.tags,
|
||||||
state = details.state ?: manga.state,
|
state = details.state ?: manga.state,
|
||||||
author = details.author.ifNullOrEmpty { manga.author },
|
author = details.author.ifNullOrEmpty { manga.author },
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import org.koitharu.kotatsu.parsers.util.ellipsize
|
|||||||
import org.koitharu.kotatsu.parsers.util.levenshteinDistance
|
import org.koitharu.kotatsu.parsers.util.levenshteinDistance
|
||||||
import java.util.UUID
|
import java.util.UUID
|
||||||
|
|
||||||
inline fun <C : CharSequence?> C?.ifNullOrEmpty(defaultValue: () -> C): C {
|
inline fun <C : R, R : CharSequence?> C?.ifNullOrEmpty(defaultValue: () -> R): R {
|
||||||
return if (this.isNullOrEmpty()) defaultValue() else this
|
return if (this.isNullOrEmpty()) defaultValue() else this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ class DetailsActivity :
|
|||||||
R.id.imageView_cover -> {
|
R.id.imageView_cover -> {
|
||||||
val manga = viewModel.manga.value ?: return
|
val manga = viewModel.manga.value ?: return
|
||||||
router.openImage(
|
router.openImage(
|
||||||
url = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl },
|
url = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl } ?: return,
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
anchor = v,
|
anchor = v,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class DownloadWorker @AssistedInject constructor(
|
|||||||
format = task.format ?: settings.preferredDownloadFormat,
|
format = task.format ?: settings.preferredDownloadFormat,
|
||||||
)
|
)
|
||||||
val coverUrl = mangaDetails.largeCoverUrl.ifNullOrEmpty { mangaDetails.coverUrl }
|
val coverUrl = mangaDetails.largeCoverUrl.ifNullOrEmpty { mangaDetails.coverUrl }
|
||||||
if (coverUrl.isNotEmpty()) {
|
if (!coverUrl.isNullOrEmpty()) {
|
||||||
downloadFile(coverUrl, destination, repo.source).let { file ->
|
downloadFile(coverUrl, destination, repo.source).let { file ->
|
||||||
output.addCover(file, getMediaType(coverUrl, file))
|
output.addCover(file, getMediaType(coverUrl, file))
|
||||||
file.deleteAwait()
|
file.deleteAwait()
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
import coil3.ImageLoader
|
import coil3.ImageLoader
|
||||||
import coil3.request.allowRgb565
|
import coil3.request.allowRgb565
|
||||||
import coil3.request.transformations
|
import coil3.request.transformations
|
||||||
import com.google.android.material.badge.BadgeDrawable
|
|
||||||
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
import com.hannesdorfmann.adapterdelegates4.dsl.adapterDelegateViewBinding
|
||||||
import org.koitharu.kotatsu.core.ui.image.TrimTransformation
|
import org.koitharu.kotatsu.core.ui.image.TrimTransformation
|
||||||
import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter
|
import org.koitharu.kotatsu.core.ui.list.AdapterDelegateClickListenerAdapter
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ data class MangaCompactListModel(
|
|||||||
override val id: Long,
|
override val id: Long,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
val subtitle: String,
|
val subtitle: String,
|
||||||
override val coverUrl: String,
|
override val coverUrl: String?,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
override val counter: Int,
|
override val counter: Int,
|
||||||
override val progress: ReadingProgress?,
|
override val progress: ReadingProgress?,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ data class MangaDetailedListModel(
|
|||||||
override val id: Long,
|
override val id: Long,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
val subtitle: String?,
|
val subtitle: String?,
|
||||||
override val coverUrl: String,
|
override val coverUrl: String?,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
override val counter: Int,
|
override val counter: Int,
|
||||||
override val progress: ReadingProgress?,
|
override val progress: ReadingProgress?,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
data class MangaGridModel(
|
data class MangaGridModel(
|
||||||
override val id: Long,
|
override val id: Long,
|
||||||
override val title: String,
|
override val title: String,
|
||||||
override val coverUrl: String,
|
override val coverUrl: String?,
|
||||||
override val manga: Manga,
|
override val manga: Manga,
|
||||||
override val counter: Int,
|
override val counter: Int,
|
||||||
override val progress: ReadingProgress?,
|
override val progress: ReadingProgress?,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ sealed class MangaListModel : ListModel {
|
|||||||
abstract val id: Long
|
abstract val id: Long
|
||||||
abstract val manga: Manga
|
abstract val manga: Manga
|
||||||
abstract val title: String
|
abstract val title: String
|
||||||
abstract val coverUrl: String
|
abstract val coverUrl: String?
|
||||||
abstract val counter: Int
|
abstract val counter: Int
|
||||||
abstract val isFavorite: Boolean
|
abstract val isFavorite: Boolean
|
||||||
abstract val progress: ReadingProgress?
|
abstract val progress: ReadingProgress?
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class PreviewFragment : BaseFragment<FragmentPreviewBinding>(), View.OnClickList
|
|||||||
)
|
)
|
||||||
|
|
||||||
R.id.imageView_cover -> router.openImage(
|
R.id.imageView_cover -> router.openImage(
|
||||||
url = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl },
|
url = manga.largeCoverUrl.ifNullOrEmpty { manga.coverUrl } ?: return,
|
||||||
source = manga.source,
|
source = manga.source,
|
||||||
anchor = v,
|
anchor = v,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ import org.koitharu.kotatsu.local.domain.model.LocalManga
|
|||||||
import org.koitharu.kotatsu.parsers.model.Manga
|
import org.koitharu.kotatsu.parsers.model.Manga
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
import org.koitharu.kotatsu.parsers.model.MangaChapter
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaPage
|
import org.koitharu.kotatsu.parsers.model.MangaPage
|
||||||
import org.koitharu.kotatsu.parsers.model.MangaSource
|
|
||||||
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
import org.koitharu.kotatsu.parsers.util.runCatchingCancellable
|
||||||
import org.koitharu.kotatsu.parsers.util.toFileNameSafe
|
import org.koitharu.kotatsu.parsers.util.toFileNameSafe
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -61,7 +60,7 @@ class LocalMangaParser(private val uri: Uri) {
|
|||||||
val mangaInfo = index?.getMangaInfo()
|
val mangaInfo = index?.getMangaInfo()
|
||||||
if (mangaInfo != null) {
|
if (mangaInfo != null) {
|
||||||
val coverEntry: Path? = index.getCoverEntry()?.let { rootPath / it } ?: fileSystem.findFirstImage(rootPath)
|
val coverEntry: Path? = index.getCoverEntry()?.let { rootPath / it } ?: fileSystem.findFirstImage(rootPath)
|
||||||
mangaInfo.copyInternal(
|
mangaInfo.copy(
|
||||||
source = LocalMangaSource,
|
source = LocalMangaSource,
|
||||||
url = rootFile.toUri().toString(),
|
url = rootFile.toUri().toString(),
|
||||||
coverUrl = coverEntry?.let { uri.child(it, resolve = true).toString() }.orEmpty(),
|
coverUrl = coverEntry?.let { uri.child(it, resolve = true).toString() }.orEmpty(),
|
||||||
@@ -72,7 +71,7 @@ class LocalMangaParser(private val uri: Uri) {
|
|||||||
if (path != null && !fileSystem.exists(rootPath / path)) {
|
if (path != null && !fileSystem.exists(rootPath / path)) {
|
||||||
null
|
null
|
||||||
} else {
|
} else {
|
||||||
c.copyInternal(
|
c.copy(
|
||||||
url = path?.let {
|
url = path?.let {
|
||||||
uri.child(it, resolve = false).toString()
|
uri.child(it, resolve = false).toString()
|
||||||
} ?: uri.toString(),
|
} ?: uri.toString(),
|
||||||
@@ -271,44 +270,5 @@ class LocalMangaParser(private val uri: Uri) {
|
|||||||
private fun String.fileNameToTitle() = substringBeforeLast('.')
|
private fun String.fileNameToTitle() = substringBeforeLast('.')
|
||||||
.replace('_', ' ')
|
.replace('_', ' ')
|
||||||
.replaceFirstChar { it.uppercase() }
|
.replaceFirstChar { it.uppercase() }
|
||||||
|
|
||||||
private fun Manga.copyInternal(
|
|
||||||
url: String = this.url,
|
|
||||||
coverUrl: String = this.coverUrl,
|
|
||||||
largeCoverUrl: String? = this.largeCoverUrl,
|
|
||||||
chapters: List<MangaChapter>? = this.chapters,
|
|
||||||
source: MangaSource = this.source,
|
|
||||||
): Manga = Manga(
|
|
||||||
id = id,
|
|
||||||
title = title,
|
|
||||||
altTitle = altTitle,
|
|
||||||
url = url,
|
|
||||||
publicUrl = publicUrl,
|
|
||||||
rating = rating,
|
|
||||||
isNsfw = isNsfw,
|
|
||||||
coverUrl = coverUrl,
|
|
||||||
tags = tags,
|
|
||||||
state = state,
|
|
||||||
author = author,
|
|
||||||
largeCoverUrl = largeCoverUrl,
|
|
||||||
description = description,
|
|
||||||
chapters = chapters,
|
|
||||||
source = source,
|
|
||||||
)
|
|
||||||
|
|
||||||
private fun MangaChapter.copyInternal(
|
|
||||||
url: String = this.url,
|
|
||||||
source: MangaSource = this.source,
|
|
||||||
) = MangaChapter(
|
|
||||||
id = id,
|
|
||||||
name = name,
|
|
||||||
number = number,
|
|
||||||
volume = volume,
|
|
||||||
url = url,
|
|
||||||
scanlator = scanlator,
|
|
||||||
uploadDate = uploadDate,
|
|
||||||
branch = branch,
|
|
||||||
source = source,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.koitharu.kotatsu.parsers.model.Manga
|
|||||||
|
|
||||||
data class FeedItem(
|
data class FeedItem(
|
||||||
val id: Long,
|
val id: Long,
|
||||||
val imageUrl: String,
|
val imageUrl: String?,
|
||||||
val title: String,
|
val title: String,
|
||||||
val manga: Manga,
|
val manga: Manga,
|
||||||
val count: Int,
|
val count: Int,
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ material = "1.13.0-alpha09"
|
|||||||
moshi = "1.15.2"
|
moshi = "1.15.2"
|
||||||
okhttp = "4.12.0"
|
okhttp = "4.12.0"
|
||||||
okio = "3.9.1"
|
okio = "3.9.1"
|
||||||
parsers = "8ce6694232"
|
parsers = "6abcdd8d4b"
|
||||||
preference = "1.2.1"
|
preference = "1.2.1"
|
||||||
recyclerview = "1.3.2"
|
recyclerview = "1.3.2"
|
||||||
room = "2.6.1"
|
room = "2.6.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user