diff --git a/src/en/animeflix/build.gradle b/src/en/animeflix/build.gradle index df7bf6e73a..82b76084b0 100644 --- a/src/en/animeflix/build.gradle +++ b/src/en/animeflix/build.gradle @@ -8,7 +8,7 @@ ext { extName = 'AnimeFlix' pkgNameSuffix = 'en.animeflix' extClass = '.AnimeFlix' - extVersionCode = 6 + extVersionCode = 7 libVersion = '13' } diff --git a/src/en/animeflix/src/eu/kanade/tachiyomi/animeextension/en/animeflix/AnimeFlix.kt b/src/en/animeflix/src/eu/kanade/tachiyomi/animeextension/en/animeflix/AnimeFlix.kt index a8ba4a106c..b81f6122f5 100644 --- a/src/en/animeflix/src/eu/kanade/tachiyomi/animeextension/en/animeflix/AnimeFlix.kt +++ b/src/en/animeflix/src/eu/kanade/tachiyomi/animeextension/en/animeflix/AnimeFlix.kt @@ -12,6 +12,7 @@ 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.POST import eu.kanade.tachiyomi.util.asJsoup import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -21,6 +22,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import okhttp3.HttpUrl.Companion.toHttpUrl +import okhttp3.MultipartBody import okhttp3.OkHttpClient import okhttp3.Request import org.jsoup.nodes.Document @@ -34,7 +36,7 @@ class AnimeFlix : ConfigurableAnimeSource, ParsedAnimeHttpSource() { override val name = "AnimeFlix" - override val baseUrl = "https://animeflix.net.in" + override val baseUrl = "https://animeflix.mobi" override val lang = "en" @@ -250,7 +252,13 @@ class AnimeFlix : ConfigurableAnimeSource, ParsedAnimeHttpSource() { if (url.url.toHttpUrl().encodedPath == "/404") return@runCatching null val (videos, mediaUrl) = extractVideo(url) when { - videos.isEmpty() -> extractGDriveLink(mediaUrl, url.quality) + videos.isEmpty() -> { + extractGDriveLink(mediaUrl, url.quality).ifEmpty { + getDirectLink(mediaUrl, "instant", "/mfile/")?.let { + listOf(Video(it, "${url.quality}p - GDrive Instant link", it)) + } ?: emptyList() + } + } else -> videos } }.getOrNull() @@ -293,15 +301,37 @@ class AnimeFlix : ConfigurableAnimeSource, ParsedAnimeHttpSource() { Video( url = decodedLink, - quality = "$quality - CF $type Worker ${index + 1}$size", + quality = "${quality}p - CF $type Worker ${index + 1}$size", videoUrl = decodedLink, ) } } + private fun getDirectLink(url: String, action: String = "direct", newPath: String = "/file/"): String? { + val doc = client.newCall(GET(url, headers)).execute().use { it.asJsoup() } + val script = doc.selectFirst("script:containsData(async function taskaction)") + ?.data() + ?: return url + + val key = script.substringAfter("key\", \"").substringBefore('"') + val form = MultipartBody.Builder() + .setType(MultipartBody.FORM) + .addFormDataPart("action", action) + .addFormDataPart("key", key) + .addFormDataPart("action_token", "") + .build() + + val headers = headersBuilder().set("x-token", url.toHttpUrl().host).build() + + val req = client.newCall(POST(url.replace("/file/", newPath), headers, form)).execute() + return runCatching { + json.decodeFromString(req.use { it.body.string() }).url + }.getOrNull() + } + private fun extractGDriveLink(mediaUrl: String, quality: String): List