add page title

This commit is contained in:
Aria Moradi
2021-01-22 17:00:33 +03:30
parent 9a61f58043
commit 6401b946b6
13 changed files with 133 additions and 43 deletions

View File

@@ -53,7 +53,7 @@ fun getChapterList(mangaId: Int): List<ChapterDataClass> {
}
}
fun getPages(chapterId: Int, mangaId: Int): List<PageDataClass> {
fun getPages(chapterId: Int, mangaId: Int): Pair<ChapterDataClass, List<PageDataClass>> {
return transaction {
val chapterEntry = ChapterTable.select { ChapterTable.id eq chapterId }.firstOrNull()!!
assert(mangaId == chapterEntry[ChapterTable.manga].value) // sanity check
@@ -67,12 +67,24 @@ fun getPages(chapterId: Int, mangaId: Int): List<PageDataClass> {
}
).toBlocking().first()
return@transaction pagesList.map {
val chapter = ChapterDataClass(
chapterEntry[ChapterTable.id].value,
chapterEntry[ChapterTable.url],
chapterEntry[ChapterTable.name],
chapterEntry[ChapterTable.date_upload],
chapterEntry[ChapterTable.chapter_number],
chapterEntry[ChapterTable.scanlator],
mangaId
)
val pages = pagesList.map {
PageDataClass(
it.index,
getTrueImageUrl(it, source)
)
}
return@transaction Pair(chapter, pages)
}
}

View File

@@ -40,7 +40,7 @@ fun getMangaList(sourceId: Long, pageNum: Int = 1, popular: Boolean): List<Manga
MangaDataClass(
mangaEntityId,
sourceId.toLong(),
sourceId,
manga.url,
manga.title,

View File

@@ -80,3 +80,17 @@ fun getSourceList(): List<SourceDataClass> {
}
}
}
fun getSource(sourceId: Long): SourceDataClass {
return transaction {
val source = SourceTable.select { SourceTable.id eq sourceId }.firstOrNull()!!
return@transaction SourceDataClass(
source[SourceTable.id].value.toString(),
source[SourceTable.name],
Locale(source[SourceTable.lang]).getDisplayLanguage(Locale(source[SourceTable.lang])),
ExtensionsTable.select { ExtensionsTable.id eq source[SourceTable.extension] }.first()[ExtensionsTable.iconUrl],
getHttpSource(source[SourceTable.id].value).supportsLatest
)
}
}