diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt index fbb17fc..fb04675 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/CatalogueSource.kt @@ -10,6 +10,7 @@ interface CatalogueSource : Source { /** * An ISO 639-1 compliant language code (two letters in lower case). */ + @Deprecated("Use language instead", ReplaceWith("language")) val lang: String /** @@ -43,5 +44,6 @@ interface CatalogueSource : Source { /** * Returns the list of filters for the source. */ + @Deprecated("Use the new suspend variant instead", ReplaceWith("getSearchFilters")) fun getFilterList(): FilterList -} \ No newline at end of file +} diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt index 83f9af4..7fd5baa 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/Source.kt @@ -1,5 +1,7 @@ package eu.kanade.tachiyomi.source +import eu.kanade.tachiyomi.source.model.FilterList +import eu.kanade.tachiyomi.source.model.MangasPage import eu.kanade.tachiyomi.source.model.Page import eu.kanade.tachiyomi.source.model.SChapter import eu.kanade.tachiyomi.source.model.SManga @@ -21,6 +23,50 @@ interface Source { */ val name: String + /** + * Represents an IETF BCP 47 compliant language tag. + * Special cases include: + * - [Language.MULTI]: Indicates multiple languages. + * - [Language.OTHER]: Refers to a language not explicitly defined. + * - 'all': Indicates multiple language. + * + * Usage of 'all' is highly discouraged and is only supported due to legacy reasons. + * + * @since extensions-lib 1.5 + */ + val language: String + + /** + * Indicates if the source supports search filters + */ + val hasSearchFilters: Boolean + + /** + * Returns the list of filters for the source. + * + * @since extensions-lib 1.5 + */ + suspend fun getSearchFilters(): FilterList + + /** + * Get a page with a list of manga. + * + * @since extensions-lib 1.5 + * @param query the search query. + * @param filters the list of filters to apply. + * @param page the page number to retrieve. + */ + suspend fun getMangaList(query: String, filters: FilterList, page: Int): MangasPage = throw Exception("Stub!") + + /** + * Get the updated details for a manga and its chapters + * + * @since extensions-lib 1.5 + * @param manga manga to get details and chapters for + * @return the updated manga and its chapters + */ + suspend fun getMangaDetailsAndChapters(manga: SManga): Pair> = throw Exception("Stub!") + /** * Get the updated details for a manga. * @@ -66,4 +112,9 @@ interface Source { ReplaceWith("getPageList"), ) fun fetchPageList(chapter: SChapter): Observable> = throw Exception("Stub!") -} \ No newline at end of file + + object Language { + const val MULTI = "multi" + const val OTHER = "other" + } +} diff --git a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt index f1d2c26..fbae961 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/source/online/HttpSource.kt @@ -15,6 +15,12 @@ import rx.Observable @Suppress("unused", "unused_parameter") abstract class HttpSource : CatalogueSource { + @Suppress("DEPRECATION") + override val language: String get() = lang + + @Suppress("DEPRECATION") + override val hasSearchFilters: Boolean get() = getFilterList().isNotEmpty() + /** * Network service. */ @@ -48,6 +54,11 @@ abstract class HttpSource : CatalogueSource { */ open val client: OkHttpClient = throw Exception("Stub!") + override suspend fun getSearchFilters(): FilterList { + @Suppress("DEPRECATION") + return getFilterList() + } + /** * Headers builder for requests. Implementations can override this method for custom headers. */ @@ -328,6 +339,10 @@ abstract class HttpSource : CatalogueSource { /** * Returns the list of filters for the source. */ + @Deprecated( + "Use the new suspend variant instead", + replaceWith = ReplaceWith("getSearchFilters") + ) override fun getFilterList(): FilterList { throw Exception("Stub!") }