tachiyomi/source-api/src/commonMain/kotlin/eu/kanade/tachiyomi/source/Source.kt

85 lines
2.2 KiB
Kotlin
Raw Normal View History

package eu.kanade.tachiyomi.source
import eu.kanade.tachiyomi.source.model.Page
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.awaitSingle
import rx.Observable
/**
* A basic interface for creating a source. It could be an online source, a local source, etc...
*/
2022-08-18 20:07:13 +02:00
interface Source {
/**
* Id for the source. Must be unique.
*/
2022-08-18 20:07:13 +02:00
val id: Long
/**
* Name of the source.
*/
2022-08-18 20:07:13 +02:00
val name: String
2022-08-18 20:07:13 +02:00
val lang: String
get() = ""
/**
* Returns an observable with the updated details for a manga.
*
* @param manga the manga to update.
*/
@Deprecated(
"Use the 1.x API instead",
2022-04-08 22:44:23 +02:00
ReplaceWith("getMangaDetails"),
)
fun fetchMangaDetails(manga: SManga): Observable<SManga> = throw IllegalStateException("Not used")
/**
* Returns an observable with all the available chapters for a manga.
*
* @param manga the manga to update.
*/
@Deprecated(
"Use the 1.x API instead",
2022-04-08 22:44:23 +02:00
ReplaceWith("getChapterList"),
)
fun fetchChapterList(manga: SManga): Observable<List<SChapter>> = throw IllegalStateException("Not used")
// TODO: remove direct usages on this method
/**
* Returns an observable with the list of pages a chapter has.
*
* @param chapter the chapter.
*/
@Deprecated(
"Use the 1.x API instead",
2022-04-08 22:44:23 +02:00
ReplaceWith("getPageList"),
)
fun fetchPageList(chapter: SChapter): Observable<List<Page>> = Observable.empty()
/**
* [1.x API] Get the updated details for a manga.
*/
2020-12-13 05:50:28 +01:00
@Suppress("DEPRECATION")
2022-08-18 20:07:13 +02:00
suspend fun getMangaDetails(manga: SManga): SManga {
return fetchMangaDetails(manga).awaitSingle()
}
/**
* [1.x API] Get all the available chapters for a manga.
*/
2020-12-13 05:50:28 +01:00
@Suppress("DEPRECATION")
2022-08-18 20:07:13 +02:00
suspend fun getChapterList(manga: SManga): List<SChapter> {
return fetchChapterList(manga).awaitSingle()
}
/**
* [1.x API] Get the list of pages a chapter has.
*/
2020-12-13 05:50:28 +01:00
@Suppress("DEPRECATION")
2022-08-18 20:07:13 +02:00
suspend fun getPageList(chapter: SChapter): List<Page> {
return fetchPageList(chapter).awaitSingle()
}
2020-02-27 00:03:34 +01:00
}