fix gogo and tenshi, final lib12 change

This commit is contained in:
jmir1
2021-06-29 16:26:23 +02:00
parent 837558b9aa
commit ceca00e86a
6 changed files with 59 additions and 14 deletions

View File

@ -5,7 +5,7 @@ ext {
extName = '4anime.to'
pkgNameSuffix = 'en.fouranime'
extClass = '.FourAnime'
extVersionCode = 11
extVersionCode = 12
libVersion = '12'
}
dependencies {

View File

@ -5,7 +5,7 @@ ext {
extName = 'Gogoanime'
pkgNameSuffix = 'en.gogoanime'
extClass = '.GogoAnime'
extVersionCode = 2
extVersionCode = 6
libVersion = '12'
}
dependencies {

View File

@ -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")

View File

@ -5,7 +5,7 @@ ext {
extName = 'hanime.tv'
pkgNameSuffix = 'en.hanime'
extClass = '.Hanime'
extVersionCode = 6
extVersionCode = 7
libVersion = '12'
containsNsfw = true
}

View File

@ -5,7 +5,7 @@ ext {
extName = 'tenshi.moe'
pkgNameSuffix = 'en.tenshimoe'
extClass = '.TenshiMoe'
extVersionCode = 15
extVersionCode = 17
libVersion = '12'
}
dependencies {

View File

@ -46,7 +46,7 @@ class TenshiMoe : ParsedAnimeHttpSource() {
return anime
}
override fun popularAnimeNextPageSelector(): String? = "ul.pagination li.page-item a[rel=next]"
override fun popularAnimeNextPageSelector(): String = "ul.pagination li.page-item a[rel=next]"
override fun episodeListSelector() = "ul.episode-loop li a"
@ -104,7 +104,7 @@ class TenshiMoe : ParsedAnimeHttpSource() {
override fun videoFromElement(element: Element): Video {
Log.i("lol", element.attr("src"))
return Video(element.attr("src"), element.attr("title"), element.attr("title"), null)
return Video(element.attr("src"), element.attr("title"), element.attr("src"), null)
}
override fun videoUrlFromElement(element: Element): String = throw Exception("not used")