mirror of
https://github.com/yuzono/anime-extensions.git
synced 2026-10-20 10:51:36 +00:00
feat: add LegacySource for lib-16 compatibility
This commit is contained in:
11
common/proguard-rules.pro
vendored
11
common/proguard-rules.pro
vendored
@@ -50,3 +50,14 @@
|
||||
|
||||
-if @kotlinx.serialization.Serializable class **
|
||||
-keep,allowshrinking,allowoptimization,allowobfuscation,allowaccessmodification class <1>
|
||||
|
||||
# Legacy video API — the app's AnimeHttpSource still declares getVideoList(SEpisode),
|
||||
# videoListRequest(SEpisode) and videoListParse(Response), but extensions-lib 16 doesn't,
|
||||
# so R8 sees no library method to match and renames them. The override is then silently
|
||||
# lost and the app runs its own base implementation instead.
|
||||
# See keiyoushi.utils.AnimeHttpLegacySource / ParsedAnimeHttpLegacySource.
|
||||
-keepclassmembers class * extends eu.kanade.tachiyomi.animesource.online.AnimeHttpSource {
|
||||
*** getVideoList(eu.kanade.tachiyomi.animesource.model.SEpisode, kotlin.coroutines.Continuation);
|
||||
*** videoListRequest(eu.kanade.tachiyomi.animesource.model.SEpisode);
|
||||
*** videoListParse(okhttp3.Response);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package keiyoushi.utils
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Hoster
|
||||
import eu.kanade.tachiyomi.animesource.model.Hoster.Companion.toHosterList
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
|
||||
abstract class AnimeHttpLegacySource : AnimeHttpSource() {
|
||||
override suspend fun getHosterList(episode: SEpisode): List<Hoster> = getVideoList(episode).toHosterList()
|
||||
|
||||
override fun hosterListParse(response: Response): List<Hoster> = throw UnsupportedOperationException()
|
||||
|
||||
open suspend fun getVideoList(episode: SEpisode): List<Video> = client.newCall(videoListRequest(episode))
|
||||
.awaitSuccess()
|
||||
.use(::videoListParse)
|
||||
|
||||
open fun videoListRequest(episode: SEpisode): Request = GET(baseUrl + episode.url, headers)
|
||||
open fun videoListParse(response: Response): List<Video> = throw UnsupportedOperationException()
|
||||
|
||||
override fun seasonListParse(response: Response) = throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package keiyoushi.utils
|
||||
|
||||
import eu.kanade.tachiyomi.animesource.model.Hoster
|
||||
import eu.kanade.tachiyomi.animesource.model.Hoster.Companion.toHosterList
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.animesource.online.ParsedAnimeHttpSource
|
||||
import eu.kanade.tachiyomi.network.GET
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.util.asJsoup
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import org.jsoup.nodes.Element
|
||||
|
||||
abstract class ParsedAnimeHttpLegacySource : ParsedAnimeHttpSource() {
|
||||
override suspend fun getHosterList(episode: SEpisode): List<Hoster> = getVideoList(episode).toHosterList()
|
||||
|
||||
override fun hosterListParse(response: Response): List<Hoster> = throw UnsupportedOperationException()
|
||||
|
||||
open suspend fun getVideoList(episode: SEpisode): List<Video> = client.newCall(videoListRequest(episode))
|
||||
.awaitSuccess()
|
||||
.use(::videoListParse)
|
||||
|
||||
open fun videoListRequest(episode: SEpisode): Request = GET(baseUrl + episode.url, headers)
|
||||
|
||||
open fun videoListParse(response: Response): List<Video> {
|
||||
val document = response.asJsoup()
|
||||
return document.select(videoListSelector()).map { videoFromElement(it) }
|
||||
}
|
||||
open fun videoListSelector(): String = throw UnsupportedOperationException()
|
||||
open fun videoFromElement(element: Element): Video = throw UnsupportedOperationException()
|
||||
|
||||
override fun seasonListSelector(): String = throw UnsupportedOperationException()
|
||||
override fun seasonFromElement(element: Element): SAnime = throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -7,19 +7,17 @@ import android.os.Looper
|
||||
import android.widget.Toast
|
||||
import eu.kanade.tachiyomi.animesource.ConfigurableAnimeSource
|
||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||
import eu.kanade.tachiyomi.animesource.model.Hoster
|
||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||
import eu.kanade.tachiyomi.animesource.model.Track
|
||||
import eu.kanade.tachiyomi.animesource.model.Video
|
||||
import eu.kanade.tachiyomi.animesource.online.AnimeHttpSource
|
||||
import kotlinx.serialization.json.Json
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Response
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.getValue
|
||||
|
||||
abstract class Source :
|
||||
AnimeHttpSource(),
|
||||
AnimeHttpLegacySource(),
|
||||
ConfigurableAnimeSource {
|
||||
protected val context: Application by injectLazy()
|
||||
|
||||
@@ -50,16 +48,18 @@ abstract class Source :
|
||||
override fun searchAnimeParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun animeDetailsRequest(anime: SAnime) = throw UnsupportedOperationException()
|
||||
override fun animeDetailsParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun seasonListRequest(anime: SAnime) = throw UnsupportedOperationException()
|
||||
override fun seasonListParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun episodeListRequest(anime: SAnime) = throw UnsupportedOperationException()
|
||||
override fun episodeListParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun videoListRequest(episode: SEpisode) = throw UnsupportedOperationException()
|
||||
override fun videoListParse(response: Response) = throw UnsupportedOperationException()
|
||||
override fun videoListRequest(hoster: Hoster) = throw UnsupportedOperationException()
|
||||
override fun videoListParse(response: Response, hoster: Hoster) = throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
fun Video.copyLegacy(
|
||||
// This is quick fix for the bug in Anikku preview r8888 (caused by a bug upstream)
|
||||
url: String = this.url.takeIf { it.isNotBlank() } ?: this.videoUrl?.takeIf { it.isNotBlank() } ?: "Video URL was empty",
|
||||
quality: String = this.quality,
|
||||
url: String = this.videoUrl,
|
||||
quality: String = this.videoTitle,
|
||||
videoUrl: String? = this.videoUrl,
|
||||
headers: Headers? = this.headers,
|
||||
subtitleTracks: List<Track> = this.subtitleTracks,
|
||||
|
||||
@@ -33,7 +33,7 @@ kotlin-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-
|
||||
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "5.3.2" }
|
||||
quickjs = { module = "app.cash.quickjs:quickjs-android", version = "0.9.2" }
|
||||
rxjava = { module = "io.reactivex:rxjava", version = "1.3.8" }
|
||||
aniyomi-lib = { module = "com.github.komikku-app:aniyomi-extensions-lib", version = "bdc8184127" }
|
||||
aniyomi-lib = { module = "com.github.komikku-app:aniyomi-extensions-lib", version = "f5961b5dfb" }
|
||||
|
||||
[plugins]
|
||||
android-application = { id = "com.android.application", version.ref = "android-gradle" }
|
||||
|
||||
Reference in New Issue
Block a user