|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
package eu.kanade.tachiyomi.animeextension.en.gogoanime
|
|
|
|
|
|
|
|
|
|
import com.google.gson.JsonParser
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.SAnime
|
|
|
|
|
import eu.kanade.tachiyomi.animesource.model.SEpisode
|
|
|
|
@ -9,6 +10,7 @@ import eu.kanade.tachiyomi.network.GET
|
|
|
|
|
import eu.kanade.tachiyomi.network.await
|
|
|
|
|
import eu.kanade.tachiyomi.util.asJsoup
|
|
|
|
|
import kotlinx.coroutines.runBlocking
|
|
|
|
|
import okhttp3.Headers.Companion.toHeaders
|
|
|
|
|
import okhttp3.OkHttpClient
|
|
|
|
|
import okhttp3.Request
|
|
|
|
|
import okhttp3.Response
|
|
|
|
@ -20,7 +22,7 @@ class GogoAnime : ParsedAnimeHttpSource() {
|
|
|
|
|
|
|
|
|
|
override val name = "Gogoanime"
|
|
|
|
|
|
|
|
|
|
override val baseUrl = "https://www1.gogoanime.ai"
|
|
|
|
|
override val baseUrl = "https://gogoanime.pe"
|
|
|
|
|
|
|
|
|
|
override val lang = "en"
|
|
|
|
|
|
|
|
|
@ -71,19 +73,62 @@ class GogoAnime : ParsedAnimeHttpSource() {
|
|
|
|
|
|
|
|
|
|
override fun videoListParse(response: Response): List<Video> {
|
|
|
|
|
val document = response.asJsoup()
|
|
|
|
|
val videoListUrl = document.selectFirst("li.dowloads a").attr("href").replace("streamani.net", "gogo-stream.com")
|
|
|
|
|
var videoListUrl = document.selectFirst("a[data-video*=streamani.net/load.php]").attr("data-video")
|
|
|
|
|
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, headers),)
|
|
|
|
|
client.newCall(GET(videoListUrl, newHeaderList.toHeaders()))
|
|
|
|
|
.await().asJsoup()
|
|
|
|
|
}
|
|
|
|
|
return videoListResponse.select(videoListSelector()).map { videoFromElement(it) }
|
|
|
|
|
return videoListFromElement(videoListResponse.selectFirst(videoListSelector()))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun videoListSelector() = "div.mirror_link a[download]"
|
|
|
|
|
override fun videoListSelector() = "div.videocontent script"
|
|
|
|
|
|
|
|
|
|
override fun videoFromElement(element: Element): Video {
|
|
|
|
|
val quality = element.text().substringAfter("Download (").replace("P - mp4)", "p")
|
|
|
|
|
return Video(element.attr("href"), quality, element.attr("href"), null)
|
|
|
|
|
override fun videoFromElement(element: Element) = throw Exception("not used")
|
|
|
|
|
|
|
|
|
|
private fun videoListFromElement(element: Element): List<Video> {
|
|
|
|
|
val videos = mutableListOf<Video>()
|
|
|
|
|
val content = element.data()
|
|
|
|
|
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("m3u8")) {
|
|
|
|
|
val toFind = link.substringAfter("/videos/hls/").substringBefore("/")
|
|
|
|
|
val toRemove = link.substringAfter("/videos/hls/").substringBeforeLast(toFind)
|
|
|
|
|
link = link.replace("/videos/hls/$toRemove", "/videos/hls/")
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private suspend fun getIndividualLinks(link: String): List<Video> {
|
|
|
|
|
val response = client.newCall(GET(link)).await().body!!.string()
|
|
|
|
|
val links = response.split("\n").filter { !it.startsWith("#") && it.isNotEmpty() }.toMutableList()
|
|
|
|
|
val qualities = response.split("\n").filter { it.startsWith("#EXT-X-STREAM-INF") }.toMutableList()
|
|
|
|
|
val linkList = mutableListOf<Video>()
|
|
|
|
|
if (qualities.lastIndex != links.lastIndex) return emptyList()
|
|
|
|
|
for (i in 0..qualities.lastIndex) {
|
|
|
|
|
links[i] = link.substringBeforeLast("/") + "/" + links[i]
|
|
|
|
|
qualities[i] = qualities[i].substringAfter("NAME=").replace("\"", "")
|
|
|
|
|
linkList.add(Video(links[i], qualities[i], links[i], null))
|
|
|
|
|
}
|
|
|
|
|
return linkList.reversed()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun videoUrlFromElement(element: Element): String = throw Exception("not used")
|
|
|
|
|