fix gogoanime
This commit is contained in:
@ -5,7 +5,7 @@ ext {
|
|||||||
extName = 'Gogoanime'
|
extName = 'Gogoanime'
|
||||||
pkgNameSuffix = 'en.gogoanime'
|
pkgNameSuffix = 'en.gogoanime'
|
||||||
extClass = '.GogoAnime'
|
extClass = '.GogoAnime'
|
||||||
extVersionCode = 9
|
extVersionCode = 10
|
||||||
libVersion = '12'
|
libVersion = '12'
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package eu.kanade.tachiyomi.animeextension.en.gogoanime
|
package eu.kanade.tachiyomi.animeextension.en.gogoanime
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.google.gson.JsonParser
|
|
||||||
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
||||||
import eu.kanade.tachiyomi.animesource.model.SAnime
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
||||||
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
||||||
@ -11,12 +9,13 @@ import eu.kanade.tachiyomi.network.GET
|
|||||||
import eu.kanade.tachiyomi.network.await
|
import eu.kanade.tachiyomi.network.await
|
||||||
import eu.kanade.tachiyomi.util.asJsoup
|
import eu.kanade.tachiyomi.util.asJsoup
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import okhttp3.Headers.Companion.toHeaders
|
import okhttp3.Headers
|
||||||
import okhttp3.OkHttpClient
|
import okhttp3.OkHttpClient
|
||||||
import okhttp3.Request
|
import okhttp3.Request
|
||||||
import okhttp3.Response
|
import okhttp3.Response
|
||||||
import org.jsoup.nodes.Document
|
import org.jsoup.nodes.Document
|
||||||
import org.jsoup.nodes.Element
|
import org.jsoup.nodes.Element
|
||||||
|
import org.jsoup.select.Elements
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|
||||||
class GogoAnime : ParsedAnimeHttpSource() {
|
class GogoAnime : ParsedAnimeHttpSource() {
|
||||||
@ -31,6 +30,11 @@ class GogoAnime : ParsedAnimeHttpSource() {
|
|||||||
|
|
||||||
override val client: OkHttpClient = network.cloudflareClient
|
override val client: OkHttpClient = network.cloudflareClient
|
||||||
|
|
||||||
|
override fun headersBuilder() = Headers.Builder().apply {
|
||||||
|
add("User-Agent", "Aniyomi")
|
||||||
|
add("Referer", "https://streamani.io/")
|
||||||
|
}
|
||||||
|
|
||||||
override fun popularAnimeSelector(): String = "div.img a"
|
override fun popularAnimeSelector(): String = "div.img a"
|
||||||
|
|
||||||
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/popular.html?page=$page")
|
override fun popularAnimeRequest(page: Int): Request = GET("$baseUrl/popular.html?page=$page")
|
||||||
@ -72,77 +76,49 @@ class GogoAnime : ParsedAnimeHttpSource() {
|
|||||||
return episode
|
return episode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun videoListRequest(episode: SEpisode): Request {
|
||||||
|
val document = client.newCall(GET(baseUrl + episode.url)).execute().asJsoup()
|
||||||
|
val link = document.selectFirst("li.dowloads a").attr("href")
|
||||||
|
return GET(link)
|
||||||
|
}
|
||||||
|
|
||||||
override fun videoListParse(response: Response): List<Video> {
|
override fun videoListParse(response: Response): List<Video> {
|
||||||
val document = response.asJsoup()
|
val document = response.asJsoup()
|
||||||
var videoListUrl = document.selectFirst("a[data-video*=streamani.io/embedplus]").attr("data-video")
|
return document.select(videoListSelector()).ordered().map { videoFromElement(it) }
|
||||||
if (!videoListUrl.startsWith("https:")) videoListUrl = "https:$videoListUrl"
|
|
||||||
val newHeaderList = mutableMapOf(Pair("referer", baseUrl))
|
|
||||||
headers.forEach { newHeaderList[it.first] = it.second }
|
|
||||||
val videoListResponse = runBlocking {
|
|
||||||
client.newCall(GET(videoListUrl, newHeaderList.toHeaders()))
|
|
||||||
.await().asJsoup()
|
|
||||||
}
|
|
||||||
val videoListResponseNoHeaders = runBlocking {
|
|
||||||
client.newCall(GET(videoListUrl))
|
|
||||||
.await().asJsoup()
|
|
||||||
}
|
|
||||||
return videoListFromElement(videoListResponseNoHeaders.selectFirst(videoListSelector())) +
|
|
||||||
videoListFromElement(videoListResponse.selectFirst(videoListSelector()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoListSelector() = "div.videocontent script"
|
private fun Elements.ordered(): Elements {
|
||||||
|
val newElements = Elements()
|
||||||
override fun videoFromElement(element: Element) = throw Exception("not used")
|
var googleElements = 0
|
||||||
|
for (element in this) {
|
||||||
private fun videoListFromElement(element: Element): List<Video> {
|
newElements.add(googleElements, element)
|
||||||
val videos = mutableListOf<Video>()
|
if (element.attr("href").startsWith("https://storage.googleapis.com")) {
|
||||||
val content = element.data()
|
googleElements++
|
||||||
var hit = content.indexOf("playerInstance.setup(")
|
|
||||||
while (hit >= 0) {
|
|
||||||
val objectString =
|
|
||||||
element.data().substring(hit).substringAfter("playerInstance.setup(").substringBefore(");")
|
|
||||||
val jsonObject =
|
|
||||||
JsonParser.parseString(objectString).asJsonObject["sources"].asJsonArray[0].asJsonObject
|
|
||||||
var link = jsonObject["file"].asString
|
|
||||||
if (link.contains("videos/videos")) {
|
|
||||||
val toFind = link.substringAfter("/videos/hls/").substringBefore("/")
|
|
||||||
val toRemove = link.substringAfter("/videos/hls/").substringBeforeLast(toFind)
|
|
||||||
link = link.replace("/videos/hls/$toRemove", "/videos/hls/")
|
|
||||||
} else if (link.contains("m3u8")) {
|
|
||||||
hit = content.indexOf("playerInstance.setup(", hit + 1)
|
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
val quality = jsonObject["label"].asString
|
|
||||||
if (videos.isEmpty() || !videos.last().url.contains(link.substringAfterLast("/"))) {
|
|
||||||
if (link.contains("m3u8")) {
|
|
||||||
val individualLinks = runBlocking { getIndividualLinks(link) }
|
|
||||||
individualLinks.forEach { videos.add(it) }
|
|
||||||
} else {
|
|
||||||
videos.add(Video(link, quality, link, null))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hit = content.indexOf("playerInstance.setup(", hit + 1)
|
|
||||||
}
|
}
|
||||||
return videos
|
return newElements
|
||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getIndividualLinks(link: String): List<Video> {
|
override fun videoListSelector() = "div.mirror_link a[download]"
|
||||||
val response = client.newCall(GET(link)).await().body!!.string()
|
|
||||||
val links = response.split("\n").filter { !it.startsWith("#") && it.isNotEmpty() }.toMutableList()
|
override fun videoFromElement(element: Element): Video {
|
||||||
val qualities = response.split("\n").filter { it.startsWith("#EXT-X-STREAM-INF") }.toMutableList()
|
val quality = element.text().substringAfter("Download (").replace("P - mp4)", "p")
|
||||||
val linkList = mutableListOf<Video>()
|
val url = element.attr("href")
|
||||||
if (qualities.lastIndex != links.lastIndex) return emptyList()
|
return if (url.startsWith("https://storage.googleapis.com")) {
|
||||||
for (i in 0..qualities.lastIndex) {
|
Video(url, quality, url, null)
|
||||||
links[i] = link.substringBeforeLast("/") + "/" + links[i]
|
} else {
|
||||||
qualities[i] = qualities[i].substringAfter("NAME=").replace("\"", "")
|
Video(url, quality, videoUrlParse(url), null)
|
||||||
Log.i("lol", links[i])
|
|
||||||
linkList.add(Video(links[i], qualities[i], links[i], null))
|
|
||||||
}
|
}
|
||||||
return linkList.reversed()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
override fun videoUrlParse(document: Document) = throw Exception("not used")
|
||||||
|
|
||||||
|
private fun videoUrlParse(url: String): String {
|
||||||
|
val noRedirectClient = client.newBuilder().followRedirects(false).build()
|
||||||
|
val videoUrl = noRedirectClient.newCall(GET(url)).execute().header("location")
|
||||||
|
return videoUrl ?: url
|
||||||
|
}
|
||||||
|
|
||||||
override fun searchAnimeFromElement(element: Element): SAnime {
|
override fun searchAnimeFromElement(element: Element): SAnime {
|
||||||
val anime = SAnime.create()
|
val anime = SAnime.create()
|
||||||
anime.setUrlWithoutDomain(element.attr("href"))
|
anime.setUrlWithoutDomain(element.attr("href"))
|
||||||
|
Reference in New Issue
Block a user