Consume and extend 1.x Source API
TODO: make the rest of the app actually call the 1.x functions
This commit is contained in:
@@ -3,6 +3,7 @@ package eu.kanade.tachiyomi.source.model
|
||||
import android.net.Uri
|
||||
import eu.kanade.tachiyomi.network.ProgressListener
|
||||
import rx.subjects.Subject
|
||||
import tachiyomi.source.model.PageUrl
|
||||
|
||||
open class Page(
|
||||
val index: Int,
|
||||
@@ -61,3 +62,9 @@ open class Page(
|
||||
const val ERROR = 4
|
||||
}
|
||||
}
|
||||
|
||||
fun Page.toPageInfo(): PageUrl {
|
||||
return PageUrl(
|
||||
url = this.imageUrl ?: this.url
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.source.model
|
||||
|
||||
import tachiyomi.source.model.ChapterInfo
|
||||
import java.io.Serializable
|
||||
|
||||
interface SChapter : Serializable {
|
||||
@@ -28,3 +29,24 @@ 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,5 +1,6 @@
|
||||
package eu.kanade.tachiyomi.source.model
|
||||
|
||||
import tachiyomi.source.model.MangaInfo
|
||||
import java.io.Serializable
|
||||
|
||||
interface SManga : Serializable {
|
||||
@@ -61,3 +62,30 @@ 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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user