diff --git a/library/src/main/java/eu/kanade/tachiyomi/animesource/model/SAnime.kt b/library/src/main/java/eu/kanade/tachiyomi/animesource/model/SAnime.kt index 5bb236d..21226a8 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/animesource/model/SAnime.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/animesource/model/SAnime.kt @@ -18,6 +18,8 @@ interface SAnime { var thumbnail_url: String? + var update_strategy: UpdateStrategy + var initialized: Boolean companion object { diff --git a/library/src/main/java/eu/kanade/tachiyomi/animesource/model/UpdateStrategy.kt b/library/src/main/java/eu/kanade/tachiyomi/animesource/model/UpdateStrategy.kt new file mode 100644 index 0000000..1000ea4 --- /dev/null +++ b/library/src/main/java/eu/kanade/tachiyomi/animesource/model/UpdateStrategy.kt @@ -0,0 +1,6 @@ +package eu.kanade.tachiyomi.animesource.model + +enum class UpdateStrategy { + ALWAYS_UPDATE, + ONLY_FETCH_ONCE +} diff --git a/library/src/main/java/eu/kanade/tachiyomi/animesource/online/AnimeHttpSource.kt b/library/src/main/java/eu/kanade/tachiyomi/animesource/online/AnimeHttpSource.kt index 401a590..0972802 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/animesource/online/AnimeHttpSource.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/animesource/online/AnimeHttpSource.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.animesource.online import eu.kanade.tachiyomi.network.NetworkHelper import eu.kanade.tachiyomi.animesource.AnimeCatalogueSource import eu.kanade.tachiyomi.animesource.model.* -import eu.kanade.tachiyomi.network.GET import okhttp3.Headers import okhttp3.OkHttpClient import okhttp3.Request @@ -270,6 +269,29 @@ abstract class AnimeHttpSource : AnimeCatalogueSource { throw Exception("Stub!") } + + /** + * Returns the url of the provided anime + * + * @since extensions-lib 14 + * @param anime the anime + * @return url of the anime + */ + open fun getAnimeUrl(anime: SAnime): String { + throw Exception("Stub!") + } + + /** + * Returns the url of the provided episode + * + * @since extensions-lib 14 + * @param episode the episode + * @return url of the episode + */ + open fun getEpisodeUrl(episode: SEpisode): String { + throw Exception("Stub!") + } + /** * Called before inserting a new episode into database. Use it if you need to override episode * fields, like the title or the episode number. Do not change anything to [anime]. @@ -277,8 +299,7 @@ abstract class AnimeHttpSource : AnimeCatalogueSource { * @param episode the episode to be added. * @param anime the anime of the episode. */ - open fun prepareNewEpisode(episode: SEpisode, anime: SAnime) { - } + open fun prepareNewEpisode(episode: SEpisode, anime: SAnime) {} /** * Returns the list of filters for the source. diff --git a/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt b/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt new file mode 100644 index 0000000..3d29e78 --- /dev/null +++ b/library/src/main/java/eu/kanade/tachiyomi/network/JavaScriptEngine.kt @@ -0,0 +1,19 @@ +package eu.kanade.tachiyomi.network + +import android.content.Context + +/** + * Util for evaluating JavaScript in sources. + */ +class JavaScriptEngine(context: Context) { + + /** + * Evaluate arbitrary JavaScript code and get the result as a primtive type + * (e.g., String, Int). + * + * @since extensions-lib 14 + * @param script JavaScript to execute. + * @return Result of JavaScript code as a primitive type. + */ + suspend fun evaluate(script: String): T = throw Exception("Stub!") +} diff --git a/library/src/main/java/eu/kanade/tachiyomi/network/Requests.kt b/library/src/main/java/eu/kanade/tachiyomi/network/Requests.kt index 642540e..27d19bd 100644 --- a/library/src/main/java/eu/kanade/tachiyomi/network/Requests.kt +++ b/library/src/main/java/eu/kanade/tachiyomi/network/Requests.kt @@ -2,6 +2,7 @@ package eu.kanade.tachiyomi.network import okhttp3.CacheControl import okhttp3.Headers +import okhttp3.HttpUrl import okhttp3.Request import okhttp3.RequestBody @@ -16,6 +17,16 @@ fun GET(url: String, throw Exception("Stub!") } +/** + * @since extensions-lib 14 + */ +fun GET(url: HttpUrl, + headers: Headers = DEFAULT_HEADERS, + cache: CacheControl = DEFAULT_CACHE_CONTROL): Request { + + throw Exception("Stub!") +} + fun POST(url: String, headers: Headers = DEFAULT_HEADERS, body: RequestBody = DEFAULT_BODY,