mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Remove 1.x source models
Co-Authored-By: stevenyomi <95685115+stevenyomi@users.noreply.github.com>
This commit is contained in:
parent
b707cd19fe
commit
3dcf50704c
16 changed files with 67 additions and 184 deletions
|
@ -122,9 +122,6 @@ dependencies {
|
||||||
}
|
}
|
||||||
implementation("com.github.tachiyomiorg:image-decoder:7481a4a")
|
implementation("com.github.tachiyomiorg:image-decoder:7481a4a")
|
||||||
|
|
||||||
// Source models and interfaces from Tachiyomi 1.x
|
|
||||||
implementation("tachiyomi.sourceapi:source-api:1.1")
|
|
||||||
|
|
||||||
// Android X libraries
|
// Android X libraries
|
||||||
implementation("androidx.appcompat:appcompat:1.6.0-beta01")
|
implementation("androidx.appcompat:appcompat:1.6.0-beta01")
|
||||||
implementation("androidx.cardview:cardview:1.0.0")
|
implementation("androidx.cardview:cardview:1.0.0")
|
||||||
|
|
|
@ -5,13 +5,11 @@ import android.net.Uri
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
import eu.kanade.tachiyomi.data.library.CustomMangaManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.data.track.TrackManager
|
import eu.kanade.tachiyomi.data.track.TrackManager
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
|
@ -42,8 +40,7 @@ abstract class AbstractBackupManager(protected val context: Context) {
|
||||||
* @return Updated manga chapters.
|
* @return Updated manga chapters.
|
||||||
*/
|
*/
|
||||||
internal suspend fun restoreChapters(source: Source, manga: Manga, chapters: List<Chapter>): Pair<List<Chapter>, List<Chapter>> {
|
internal suspend fun restoreChapters(source: Source, manga: Manga, chapters: List<Chapter>): Pair<List<Chapter>, List<Chapter>> {
|
||||||
val fetchedChapters = source.getChapterList(manga.toMangaInfo())
|
val fetchedChapters = source.getChapterList(manga)
|
||||||
.map { it.toSChapter() }
|
|
||||||
val syncedChapters = syncChaptersWithSource(databaseHelper, fetchedChapters, manga, source)
|
val syncedChapters = syncChaptersWithSource(databaseHelper, fetchedChapters, manga, source)
|
||||||
if (syncedChapters.first.isNotEmpty()) {
|
if (syncedChapters.first.isNotEmpty()) {
|
||||||
chapters.forEach { it.manga_id = manga.id }
|
chapters.forEach { it.manga_id = manga.id }
|
||||||
|
|
|
@ -20,9 +20,7 @@ import eu.kanade.tachiyomi.data.database.models.History
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
import eu.kanade.tachiyomi.data.database.models.MangaCategory
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.modules.SerializersModule
|
import kotlinx.serialization.modules.SerializersModule
|
||||||
import kotlinx.serialization.modules.contextual
|
import kotlinx.serialization.modules.contextual
|
||||||
|
@ -75,9 +73,9 @@ class LegacyBackupManager(context: Context, version: Int = CURRENT_VERSION) : Ab
|
||||||
* @return Updated manga.
|
* @return Updated manga.
|
||||||
*/
|
*/
|
||||||
suspend fun fetchManga(source: Source, manga: Manga): Manga {
|
suspend fun fetchManga(source: Source, manga: Manga): Manga {
|
||||||
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
val networkManga = source.getMangaDetails(manga)
|
||||||
return manga.also {
|
return manga.also {
|
||||||
it.copyFrom(networkManga.toSManga())
|
it.copyFrom(networkManga)
|
||||||
it.favorite = true
|
it.favorite = true
|
||||||
it.initialized = true
|
it.initialized = true
|
||||||
it.id = insertManga(manga)
|
it.id = insertManga(manga)
|
||||||
|
|
|
@ -9,7 +9,6 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.settings.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.settings.ReadingModeType
|
||||||
import eu.kanade.tachiyomi.util.manga.MangaCoverMetadata
|
import eu.kanade.tachiyomi.util.manga.MangaCoverMetadata
|
||||||
import tachiyomi.source.model.MangaInfo
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -338,16 +337,3 @@ interface Manga : SManga {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Manga.toMangaInfo(): MangaInfo {
|
|
||||||
return MangaInfo(
|
|
||||||
artist = this.artist ?: "",
|
|
||||||
author = this.author ?: "",
|
|
||||||
cover = this.thumbnail_url ?: "",
|
|
||||||
description = this.description ?: "",
|
|
||||||
genres = this.getGenres() ?: emptyList(),
|
|
||||||
key = this.url,
|
|
||||||
status = this.status,
|
|
||||||
title = this.title,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
import eu.kanade.tachiyomi.data.database.models.LibraryManga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadService
|
import eu.kanade.tachiyomi.data.download.DownloadService
|
||||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Companion.start
|
import eu.kanade.tachiyomi.data.library.LibraryUpdateService.Companion.start
|
||||||
|
@ -32,8 +31,6 @@ import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.UnmeteredSource
|
import eu.kanade.tachiyomi.source.UnmeteredSource
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
|
||||||
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithTrackServiceTwoWay
|
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithTrackServiceTwoWay
|
||||||
|
@ -420,7 +417,7 @@ class LibraryUpdateService(
|
||||||
notifier.showProgressNotification(manga, progress, mangaToUpdate.size)
|
notifier.showProgressNotification(manga, progress, mangaToUpdate.size)
|
||||||
val source = sourceManager.get(manga.source) as? HttpSource ?: return false
|
val source = sourceManager.get(manga.source) as? HttpSource ?: return false
|
||||||
val fetchedChapters = withContext(Dispatchers.IO) {
|
val fetchedChapters = withContext(Dispatchers.IO) {
|
||||||
source.getChapterList(manga.toMangaInfo()).map { it.toSChapter() }
|
source.getChapterList(manga)
|
||||||
}
|
}
|
||||||
if (fetchedChapters.isNotEmpty()) {
|
if (fetchedChapters.isNotEmpty()) {
|
||||||
val newChapters = syncChaptersWithSource(db, fetchedChapters, manga, source)
|
val newChapters = syncChaptersWithSource(db, fetchedChapters, manga, source)
|
||||||
|
@ -487,7 +484,7 @@ class LibraryUpdateService(
|
||||||
)
|
)
|
||||||
|
|
||||||
val networkManga = try {
|
val networkManga = try {
|
||||||
source.getMangaDetails(manga.toMangaInfo()).toSManga()
|
source.getMangaDetails(manga.copy())
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
null
|
null
|
||||||
|
|
|
@ -8,10 +8,6 @@ import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toChapterInfo
|
|
||||||
import eu.kanade.tachiyomi.source.model.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
import eu.kanade.tachiyomi.util.chapter.ChapterRecognition
|
||||||
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
import eu.kanade.tachiyomi.util.lang.compareToCaseInsensitiveNaturalOrder
|
||||||
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
import eu.kanade.tachiyomi.util.storage.DiskUtil
|
||||||
|
@ -23,8 +19,6 @@ import kotlinx.serialization.encodeToString
|
||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.decodeFromStream
|
import kotlinx.serialization.json.decodeFromStream
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import tachiyomi.source.model.ChapterInfo
|
|
||||||
import tachiyomi.source.model.MangaInfo
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -159,23 +153,22 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val sManga = this
|
val manga = this
|
||||||
val mangaInfo = this.toMangaInfo()
|
|
||||||
runBlocking {
|
runBlocking {
|
||||||
val chapters = getChapterList(mangaInfo)
|
val chapters = getChapterList(manga)
|
||||||
if (chapters.isNotEmpty()) {
|
if (chapters.isNotEmpty()) {
|
||||||
val chapter = chapters.last().toSChapter()
|
val chapter = chapters.last()
|
||||||
val format = getFormat(chapter)
|
val format = getFormat(chapter)
|
||||||
if (format is Format.Epub) {
|
if (format is Format.Epub) {
|
||||||
EpubFile(format.file).use { epub ->
|
EpubFile(format.file).use { epub ->
|
||||||
epub.fillMangaMetadata(sManga)
|
epub.fillMangaMetadata(manga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy the cover from the first chapter found.
|
// Copy the cover from the first chapter found.
|
||||||
if (thumbnail_url == null) {
|
if (thumbnail_url == null) {
|
||||||
try {
|
try {
|
||||||
val dest = updateCover(chapter, sManga)
|
val dest = updateCover(chapter, manga)
|
||||||
thumbnail_url = dest?.absolutePath
|
thumbnail_url = dest?.absolutePath
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
|
@ -191,25 +184,25 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
||||||
|
|
||||||
override fun fetchLatestUpdates(page: Int) = fetchSearchManga(page, "", latestFilters)
|
override fun fetchLatestUpdates(page: Int) = fetchSearchManga(page, "", latestFilters)
|
||||||
|
|
||||||
override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo {
|
override suspend fun getMangaDetails(manga: SManga): SManga {
|
||||||
val localDetails = getBaseDirectories(context)
|
val localDetails = getBaseDirectories(context)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.mapNotNull { File(it, manga.key).listFiles()?.toList() }
|
.mapNotNull { File(it, manga.url).listFiles()?.toList() }
|
||||||
.flatten()
|
.flatten()
|
||||||
.firstOrNull { it.extension.equals("json", ignoreCase = true) }
|
.firstOrNull { it.extension.equals("json", ignoreCase = true) }
|
||||||
|
|
||||||
return if (localDetails != null) {
|
return if (localDetails != null) {
|
||||||
val obj = json.decodeFromStream<MangaJson>(localDetails.inputStream())
|
val obj = json.decodeFromStream<MangaJson>(localDetails.inputStream())
|
||||||
|
|
||||||
obj.lang?.let { langMap[manga.key] = it }
|
obj.lang?.let { langMap[manga.url] = it }
|
||||||
manga.copy(
|
SManga.create().apply {
|
||||||
title = obj.title ?: manga.title,
|
title = obj.title ?: manga.title
|
||||||
author = obj.author ?: manga.author,
|
author = obj.author ?: manga.author
|
||||||
artist = obj.artist ?: manga.artist,
|
artist = obj.artist ?: manga.artist
|
||||||
description = obj.description ?: manga.description,
|
description = obj.description ?: manga.description
|
||||||
genres = obj.genre?.toList() ?: manga.genres,
|
genre = obj.genre?.joinToString(", ") ?: manga.genre
|
||||||
status = obj.status ?: manga.status,
|
status = obj.status ?: manga.status
|
||||||
)
|
}
|
||||||
} else {
|
} else {
|
||||||
manga
|
manga
|
||||||
}
|
}
|
||||||
|
@ -256,17 +249,15 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChapterList(manga: MangaInfo): List<ChapterInfo> {
|
override suspend fun getChapterList(manga: SManga): List<SChapter> {
|
||||||
val sManga = manga.toSManga()
|
|
||||||
|
|
||||||
val chapters = getBaseDirectories(context)
|
val chapters = getBaseDirectories(context)
|
||||||
.asSequence()
|
.asSequence()
|
||||||
.mapNotNull { File(it, manga.key).listFiles()?.toList() }
|
.mapNotNull { File(it, manga.url).listFiles()?.toList() }
|
||||||
.flatten()
|
.flatten()
|
||||||
.filter { it.isDirectory || isSupportedFile(it.extension) }
|
.filter { it.isDirectory || isSupportedFile(it.extension) }
|
||||||
.map { chapterFile ->
|
.map { chapterFile ->
|
||||||
SChapter.create().apply {
|
SChapter.create().apply {
|
||||||
url = "${manga.key}/${chapterFile.name}"
|
url = "${manga.url}/${chapterFile.name}"
|
||||||
name = if (chapterFile.isDirectory) {
|
name = if (chapterFile.isDirectory) {
|
||||||
chapterFile.name
|
chapterFile.name
|
||||||
} else {
|
} else {
|
||||||
|
@ -281,12 +272,11 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChapterRecognition.parseChapterNumber(this, sManga)
|
ChapterRecognition.parseChapterNumber(this, manga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.map { it.toChapterInfo() }
|
|
||||||
.sortedWith { c1, c2 ->
|
.sortedWith { c1, c2 ->
|
||||||
val c = c2.number.compareTo(c1.number)
|
val c = c2.chapter_number.compareTo(c1.chapter_number)
|
||||||
if (c == 0) c2.name.compareToCaseInsensitiveNaturalOrder(c1.name) else c
|
if (c == 0) c2.name.compareToCaseInsensitiveNaturalOrder(c1.name) else c
|
||||||
}
|
}
|
||||||
.toList()
|
.toList()
|
||||||
|
@ -294,7 +284,7 @@ class LocalSource(private val context: Context) : CatalogueSource, UnmeteredSour
|
||||||
return chapters
|
return chapters
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getPageList(chapter: ChapterInfo) = throw Exception("Unused")
|
override suspend fun getPageList(chapter: SChapter) = throw Exception("Unused")
|
||||||
|
|
||||||
private fun isSupportedFile(extension: String): Boolean {
|
private fun isSupportedFile(extension: String): Boolean {
|
||||||
return extension.lowercase() in SUPPORTED_ARCHIVE_TYPES
|
return extension.lowercase() in SUPPORTED_ARCHIVE_TYPES
|
||||||
|
|
|
@ -5,34 +5,27 @@ import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
import eu.kanade.tachiyomi.source.model.Page
|
import eu.kanade.tachiyomi.source.model.Page
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toChapterInfo
|
|
||||||
import eu.kanade.tachiyomi.source.model.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.source.model.toPageUrl
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.util.system.awaitSingle
|
import eu.kanade.tachiyomi.util.system.awaitSingle
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import tachiyomi.source.model.ChapterInfo
|
|
||||||
import tachiyomi.source.model.MangaInfo
|
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A basic interface for creating a source. It could be an online source, a local source, etc...
|
* A basic interface for creating a source. It could be an online source, a local source, etc...
|
||||||
*/
|
*/
|
||||||
interface Source : tachiyomi.source.Source {
|
interface Source {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Id for the source. Must be unique.
|
* Id for the source. Must be unique.
|
||||||
*/
|
*/
|
||||||
override val id: Long
|
val id: Long
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Name of the source.
|
* Name of the source.
|
||||||
*/
|
*/
|
||||||
override val name: String
|
val name: String
|
||||||
|
|
||||||
override val lang: String
|
val lang: String
|
||||||
get() = ""
|
get() = ""
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -74,33 +67,27 @@ interface Source : tachiyomi.source.Source {
|
||||||
* [1.x API] Get the updated details for a manga.
|
* [1.x API] Get the updated details for a manga.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo {
|
suspend fun getMangaDetails(manga: SManga): SManga {
|
||||||
val sManga = manga.toSManga()
|
return fetchMangaDetails(manga).awaitSingle()
|
||||||
val networkManga = fetchMangaDetails(sManga).awaitSingle()
|
|
||||||
sManga.copyFrom(networkManga)
|
|
||||||
return sManga.toMangaInfo()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [1.x API] Get all the available chapters for a manga.
|
* [1.x API] Get all the available chapters for a manga.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
override suspend fun getChapterList(manga: MangaInfo): List<ChapterInfo> {
|
suspend fun getChapterList(manga: SManga): List<SChapter> {
|
||||||
return fetchChapterList(manga.toSManga()).awaitSingle()
|
return fetchChapterList(manga).awaitSingle()
|
||||||
.map { it.toChapterInfo() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [1.x API] Get the list of pages a chapter has.
|
* [1.x API] Get the list of pages a chapter has.
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
@Suppress("DEPRECATION")
|
||||||
override suspend fun getPageList(chapter: ChapterInfo): List<tachiyomi.source.model.Page> {
|
suspend fun getPageList(chapter: SChapter): List<Page> {
|
||||||
return fetchPageList(chapter.toSChapter()).awaitSingle()
|
return fetchPageList(chapter).awaitSingle()
|
||||||
.map { it.toPageUrl() }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Source.icon(): Drawable? =
|
fun Source.icon(): Drawable? = Injekt.get<ExtensionManager>().getAppIconForSource(this)
|
||||||
Injekt.get<ExtensionManager>().getAppIconForSource(this)
|
|
||||||
|
|
||||||
fun Source.getPreferenceKey(): String = "source_$id"
|
fun Source.getPreferenceKey(): String = "source_$id"
|
||||||
|
|
|
@ -13,8 +13,6 @@ import eu.kanade.tachiyomi.source.online.all.MangaDex
|
||||||
import eu.kanade.tachiyomi.source.online.english.KireiCake
|
import eu.kanade.tachiyomi.source.online.english.KireiCake
|
||||||
import eu.kanade.tachiyomi.source.online.english.MangaPlus
|
import eu.kanade.tachiyomi.source.online.english.MangaPlus
|
||||||
import rx.Observable
|
import rx.Observable
|
||||||
import tachiyomi.source.model.ChapterInfo
|
|
||||||
import tachiyomi.source.model.MangaInfo
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
open class SourceManager(private val context: Context) {
|
open class SourceManager(private val context: Context) {
|
||||||
|
@ -95,7 +93,7 @@ open class SourceManager(private val context: Context) {
|
||||||
override val name: String
|
override val name: String
|
||||||
get() = extensionManager.getStubSource(id)?.name ?: id.toString()
|
get() = extensionManager.getStubSource(id)?.name ?: id.toString()
|
||||||
|
|
||||||
override suspend fun getMangaDetails(manga: MangaInfo): MangaInfo {
|
override suspend fun getMangaDetails(manga: SManga): SManga {
|
||||||
throw getSourceNotInstalledException()
|
throw getSourceNotInstalledException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,7 +101,7 @@ open class SourceManager(private val context: Context) {
|
||||||
return Observable.error(getSourceNotInstalledException())
|
return Observable.error(getSourceNotInstalledException())
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getChapterList(manga: MangaInfo): List<ChapterInfo> {
|
override suspend fun getChapterList(manga: SManga): List<SChapter> {
|
||||||
throw getSourceNotInstalledException()
|
throw getSourceNotInstalledException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +109,7 @@ open class SourceManager(private val context: Context) {
|
||||||
return Observable.error(getSourceNotInstalledException())
|
return Observable.error(getSourceNotInstalledException())
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun getPageList(chapter: ChapterInfo): List<tachiyomi.source.model.Page> {
|
override suspend fun getPageList(chapter: SChapter): List<Page> {
|
||||||
throw getSourceNotInstalledException()
|
throw getSourceNotInstalledException()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.source.model
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import eu.kanade.tachiyomi.network.ProgressListener
|
import eu.kanade.tachiyomi.network.ProgressListener
|
||||||
import rx.subjects.Subject
|
import rx.subjects.Subject
|
||||||
import tachiyomi.source.model.PageUrl
|
|
||||||
|
|
||||||
open class Page(
|
open class Page(
|
||||||
val index: Int,
|
val index: Int,
|
||||||
|
@ -58,16 +57,3 @@ open class Page(
|
||||||
const val ERROR = 4
|
const val ERROR = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Page.toPageUrl(): PageUrl {
|
|
||||||
return PageUrl(
|
|
||||||
url = this.imageUrl ?: this.url,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun PageUrl.toPage(index: Int): Page {
|
|
||||||
return Page(
|
|
||||||
index = index,
|
|
||||||
imageUrl = this.url,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.source.model
|
package eu.kanade.tachiyomi.source.model
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
import eu.kanade.tachiyomi.data.database.models.ChapterImpl
|
||||||
import tachiyomi.source.model.ChapterInfo
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
interface SChapter : Serializable {
|
interface SChapter : Serializable {
|
||||||
|
@ -40,24 +39,3 @@ interface SChapter : Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SChapter.toChapterInfo(): ChapterInfo {
|
|
||||||
return ChapterInfo(
|
|
||||||
dateUpload = this.date_upload,
|
|
||||||
key = this.url,
|
|
||||||
name = this.name,
|
|
||||||
number = this.chapter_number,
|
|
||||||
scanlator = this.scanlator ?: "",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun ChapterInfo.toSChapter(): SChapter {
|
|
||||||
val chapter = this
|
|
||||||
return SChapter.create().apply {
|
|
||||||
url = chapter.key
|
|
||||||
name = chapter.name
|
|
||||||
date_upload = chapter.dateUpload
|
|
||||||
chapter_number = chapter.number
|
|
||||||
scanlator = chapter.scanlator
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.kanade.tachiyomi.source.model
|
package eu.kanade.tachiyomi.source.model
|
||||||
|
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||||
import tachiyomi.source.model.MangaInfo
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
interface SManga : Serializable {
|
interface SManga : Serializable {
|
||||||
|
@ -65,6 +64,18 @@ interface SManga : Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun copy() = create().also {
|
||||||
|
it.url = url
|
||||||
|
it.title = title
|
||||||
|
it.artist = artist
|
||||||
|
it.author = author
|
||||||
|
it.description = description
|
||||||
|
it.genre = genre
|
||||||
|
it.status = status
|
||||||
|
it.thumbnail_url = thumbnail_url
|
||||||
|
it.initialized = initialized
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val UNKNOWN = 0
|
const val UNKNOWN = 0
|
||||||
const val ONGOING = 1
|
const val ONGOING = 1
|
||||||
|
@ -79,30 +90,3 @@ interface SManga : Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun SManga.toMangaInfo(): MangaInfo {
|
|
||||||
return MangaInfo(
|
|
||||||
key = this.url,
|
|
||||||
title = this.title,
|
|
||||||
artist = this.artist ?: "",
|
|
||||||
author = this.author ?: "",
|
|
||||||
description = this.description ?: "",
|
|
||||||
genres = this.genre?.split(", ") ?: emptyList(),
|
|
||||||
status = this.status,
|
|
||||||
cover = this.thumbnail_url ?: "",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun MangaInfo.toSManga(): SManga {
|
|
||||||
val mangaInfo = this
|
|
||||||
return SManga.create().apply {
|
|
||||||
url = mangaInfo.key
|
|
||||||
title = mangaInfo.title
|
|
||||||
artist = mangaInfo.artist
|
|
||||||
author = mangaInfo.author
|
|
||||||
description = mangaInfo.description
|
|
||||||
genre = mangaInfo.genres.joinToString(", ")
|
|
||||||
status = mangaInfo.status
|
|
||||||
thumbnail_url = mangaInfo.cover
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -5,11 +5,8 @@ import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
import eu.kanade.tachiyomi.data.database.models.MangaImpl
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import uy.kohesive.injekt.injectLazy
|
import uy.kohesive.injekt.injectLazy
|
||||||
|
|
||||||
abstract class DelegatedHttpSource {
|
abstract class DelegatedHttpSource {
|
||||||
|
@ -29,7 +26,7 @@ abstract class DelegatedHttpSource {
|
||||||
protected open suspend fun getMangaInfo(url: String): Manga? {
|
protected open suspend fun getMangaInfo(url: String): Manga? {
|
||||||
val id = delegate?.id ?: return null
|
val id = delegate?.id ?: return null
|
||||||
val manga = Manga.create(url, "", id)
|
val manga = Manga.create(url, "", id)
|
||||||
val networkManga = delegate?.getMangaDetails(manga.toMangaInfo())?.toSManga() ?: return null
|
val networkManga = delegate?.getMangaDetails(manga.copy()) ?: return null
|
||||||
val newManga = MangaImpl().apply {
|
val newManga = MangaImpl().apply {
|
||||||
this.url = url
|
this.url = url
|
||||||
title = try { networkManga.title } catch (e: Exception) { "" }
|
title = try { networkManga.title } catch (e: Exception) { "" }
|
||||||
|
@ -42,6 +39,6 @@ abstract class DelegatedHttpSource {
|
||||||
suspend fun getChapters(url: String): List<SChapter>? {
|
suspend fun getChapters(url: String): List<SChapter>? {
|
||||||
val id = delegate?.id ?: return null
|
val id = delegate?.id ?: return null
|
||||||
val manga = Manga.create(url, "", id)
|
val manga = Manga.create(url, "", id)
|
||||||
return delegate?.getChapterList(manga.toMangaInfo())?.map { it.toSChapter() }
|
return delegate?.getChapterList(manga)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.Track
|
import eu.kanade.tachiyomi.data.database.models.Track
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
import eu.kanade.tachiyomi.data.download.model.DownloadQueue
|
||||||
|
@ -33,8 +32,6 @@ import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.SourceNotFoundException
|
import eu.kanade.tachiyomi.source.SourceNotFoundException
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BaseCoroutinePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BaseCoroutinePresenter
|
||||||
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
import eu.kanade.tachiyomi.ui.manga.chapter.ChapterItem
|
||||||
|
@ -323,7 +320,7 @@ class MangaDetailsPresenter(
|
||||||
var chapterError: java.lang.Exception? = null
|
var chapterError: java.lang.Exception? = null
|
||||||
val chapters = async(Dispatchers.IO) {
|
val chapters = async(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
source.getChapterList(manga.toMangaInfo()).map { it.toSChapter() }
|
source.getChapterList(manga)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
chapterError = e
|
chapterError = e
|
||||||
emptyList()
|
emptyList()
|
||||||
|
@ -332,7 +329,7 @@ class MangaDetailsPresenter(
|
||||||
val thumbnailUrl = manga.thumbnail_url
|
val thumbnailUrl = manga.thumbnail_url
|
||||||
val nManga = async(Dispatchers.IO) {
|
val nManga = async(Dispatchers.IO) {
|
||||||
try {
|
try {
|
||||||
source.getMangaDetails(manga.toMangaInfo()).toSManga()
|
source.getMangaDetails(manga.copy())
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
mangaError = e
|
mangaError = e
|
||||||
null
|
null
|
||||||
|
@ -419,7 +416,7 @@ class MangaDetailsPresenter(
|
||||||
|
|
||||||
presenterScope.launch(Dispatchers.IO) {
|
presenterScope.launch(Dispatchers.IO) {
|
||||||
val chapters = try {
|
val chapters = try {
|
||||||
source.getChapterList(manga.toMangaInfo()).map { it.toSChapter() }
|
source.getChapterList(manga)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
withContext(Dispatchers.Main) { controller?.showError(trimException(e)) }
|
withContext(Dispatchers.Main) { controller?.showError(trimException(e)) }
|
||||||
return@launch
|
return@launch
|
||||||
|
|
|
@ -16,7 +16,6 @@ import com.bluelinelabs.conductor.changehandler.FadeChangeHandler
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
import eu.kanade.tachiyomi.databinding.MigrationListControllerBinding
|
||||||
import eu.kanade.tachiyomi.smartsearch.SmartSearchEngine
|
import eu.kanade.tachiyomi.smartsearch.SmartSearchEngine
|
||||||
|
@ -24,8 +23,6 @@ import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
import eu.kanade.tachiyomi.source.Source
|
import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.SChapter
|
import eu.kanade.tachiyomi.source.model.SChapter
|
||||||
import eu.kanade.tachiyomi.source.model.toSChapter
|
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
import eu.kanade.tachiyomi.ui.base.controller.BaseController
|
||||||
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
import eu.kanade.tachiyomi.ui.main.BottomNavBarInterface
|
||||||
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
import eu.kanade.tachiyomi.ui.manga.MangaDetailsController
|
||||||
|
@ -182,8 +179,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||||
searchResult,
|
searchResult,
|
||||||
source.id,
|
source.id,
|
||||||
)
|
)
|
||||||
val chapters =
|
val chapters = source.getChapterList(localManga)
|
||||||
source.getChapterList(localManga.toMangaInfo()).map { it.toSChapter() }
|
|
||||||
try {
|
try {
|
||||||
syncChaptersWithSource(
|
syncChaptersWithSource(
|
||||||
db,
|
db,
|
||||||
|
@ -222,7 +218,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||||
source.id,
|
source.id,
|
||||||
)
|
)
|
||||||
val chapters: List<SChapter> = try {
|
val chapters: List<SChapter> = try {
|
||||||
source.getChapterList(localManga.toMangaInfo()).map { it.toSChapter() }
|
source.getChapterList(localManga)
|
||||||
} catch (e: java.lang.Exception) {
|
} catch (e: java.lang.Exception) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
emptyList()
|
emptyList()
|
||||||
|
@ -255,7 +251,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||||
if (result != null && result.thumbnail_url == null) {
|
if (result != null && result.thumbnail_url == null) {
|
||||||
try {
|
try {
|
||||||
val newManga =
|
val newManga =
|
||||||
sourceManager.getOrStub(result.source).getMangaDetails(result.toMangaInfo()).toSManga()
|
sourceManager.getOrStub(result.source).getMangaDetails(result)
|
||||||
result.copyFrom(newManga)
|
result.copyFrom(newManga)
|
||||||
|
|
||||||
db.insertManga(result).executeAsBlocking()
|
db.insertManga(result).executeAsBlocking()
|
||||||
|
@ -361,7 +357,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||||
val result = CoroutineScope(migratingManga.manga.migrationJob).async {
|
val result = CoroutineScope(migratingManga.manga.migrationJob).async {
|
||||||
val localManga = smartSearchEngine.networkToLocalManga(manga, source.id)
|
val localManga = smartSearchEngine.networkToLocalManga(manga, source.id)
|
||||||
try {
|
try {
|
||||||
val chapters = source.getChapterList(localManga.toMangaInfo()).map { it.toSChapter() }
|
val chapters = source.getChapterList(localManga)
|
||||||
syncChaptersWithSource(db, chapters, localManga, source)
|
syncChaptersWithSource(db, chapters, localManga, source)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
return@async null
|
return@async null
|
||||||
|
@ -372,8 +368,7 @@ class MigrationListController(bundle: Bundle? = null) :
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
try {
|
try {
|
||||||
val newManga =
|
val newManga =
|
||||||
sourceManager.getOrStub(result.source).getMangaDetails(result.toMangaInfo())
|
sourceManager.getOrStub(result.source).getMangaDetails(result)
|
||||||
.toSManga()
|
|
||||||
result.copyFrom(newManga)
|
result.copyFrom(newManga)
|
||||||
|
|
||||||
db.insertManga(result).executeAsBlocking()
|
db.insertManga(result).executeAsBlocking()
|
||||||
|
|
|
@ -6,7 +6,6 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Category
|
import eu.kanade.tachiyomi.data.database.models.Category
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||||
|
@ -14,7 +13,6 @@ import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.Filter
|
import eu.kanade.tachiyomi.source.model.Filter
|
||||||
import eu.kanade.tachiyomi.source.model.FilterList
|
import eu.kanade.tachiyomi.source.model.FilterList
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.ui.source.filter.CheckboxItem
|
import eu.kanade.tachiyomi.ui.source.filter.CheckboxItem
|
||||||
import eu.kanade.tachiyomi.ui.source.filter.CheckboxSectionItem
|
import eu.kanade.tachiyomi.ui.source.filter.CheckboxSectionItem
|
||||||
|
@ -244,8 +242,8 @@ open class BrowseSourcePresenter(
|
||||||
*/
|
*/
|
||||||
private suspend fun getMangaDetails(manga: Manga): Manga {
|
private suspend fun getMangaDetails(manga: Manga): Manga {
|
||||||
try {
|
try {
|
||||||
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
val networkManga = source.getMangaDetails(manga.copy())
|
||||||
manga.copyFrom(networkManga.toSManga())
|
manga.copyFrom(networkManga)
|
||||||
manga.initialized = true
|
manga.initialized = true
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.os.Bundle
|
||||||
import eu.kanade.tachiyomi.data.cache.CoverCache
|
import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
import eu.kanade.tachiyomi.data.database.models.toMangaInfo
|
|
||||||
import eu.kanade.tachiyomi.data.download.DownloadManager
|
import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||||
|
@ -13,7 +12,6 @@ import eu.kanade.tachiyomi.source.Source
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
import eu.kanade.tachiyomi.source.model.MangasPage
|
import eu.kanade.tachiyomi.source.model.MangasPage
|
||||||
import eu.kanade.tachiyomi.source.model.SManga
|
import eu.kanade.tachiyomi.source.model.SManga
|
||||||
import eu.kanade.tachiyomi.source.model.toSManga
|
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
|
import eu.kanade.tachiyomi.ui.source.browse.BrowseSourcePresenter
|
||||||
import eu.kanade.tachiyomi.util.system.runAsObservable
|
import eu.kanade.tachiyomi.util.system.runAsObservable
|
||||||
|
@ -284,8 +282,8 @@ open class GlobalSearchPresenter(
|
||||||
* @return The initialized manga.
|
* @return The initialized manga.
|
||||||
*/
|
*/
|
||||||
private suspend fun getMangaDetails(manga: Manga, source: Source): Manga {
|
private suspend fun getMangaDetails(manga: Manga, source: Source): Manga {
|
||||||
val networkManga = source.getMangaDetails(manga.toMangaInfo())
|
val networkManga = source.getMangaDetails(manga.copy())
|
||||||
manga.copyFrom(networkManga.toSManga())
|
manga.copyFrom(networkManga)
|
||||||
manga.initialized = true
|
manga.initialized = true
|
||||||
db.insertManga(manga).executeAsBlocking()
|
db.insertManga(manga).executeAsBlocking()
|
||||||
return manga
|
return manga
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue