Add 1.x page model converters

This commit is contained in:
arkon 2020-11-07 19:22:01 -05:00
parent e32445f2cf
commit 7dc70c9eab
2 changed files with 10 additions and 3 deletions

View file

@ -7,7 +7,7 @@ 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.toChapterInfo
import eu.kanade.tachiyomi.source.model.toMangaInfo import eu.kanade.tachiyomi.source.model.toMangaInfo
import eu.kanade.tachiyomi.source.model.toPageInfo import eu.kanade.tachiyomi.source.model.toPageUrl
import eu.kanade.tachiyomi.source.model.toSChapter import eu.kanade.tachiyomi.source.model.toSChapter
import eu.kanade.tachiyomi.source.model.toSManga import eu.kanade.tachiyomi.source.model.toSManga
import eu.kanade.tachiyomi.util.lang.awaitSingle import eu.kanade.tachiyomi.util.lang.awaitSingle
@ -80,7 +80,7 @@ interface Source : tachiyomi.source.Source {
*/ */
override suspend fun getPageList(chapter: ChapterInfo): List<tachiyomi.source.model.Page> { override suspend fun getPageList(chapter: ChapterInfo): List<tachiyomi.source.model.Page> {
return fetchPageList(chapter.toSChapter()).awaitSingle() return fetchPageList(chapter.toSChapter()).awaitSingle()
.map { it.toPageInfo() } .map { it.toPageUrl() }
} }
} }

View file

@ -63,8 +63,15 @@ open class Page(
} }
} }
fun Page.toPageInfo(): PageUrl { fun Page.toPageUrl(): PageUrl {
return PageUrl( return PageUrl(
url = this.imageUrl ?: this.url url = this.imageUrl ?: this.url
) )
} }
fun PageUrl.toPage(index: Int): Page {
return Page(
index = index,
imageUrl = this.url
)
}