Eneyida: Parse all episodes

This commit is contained in:
CakesTwix 2023-02-17 22:43:27 +02:00
parent 59b084b247
commit ebe06c226d
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825
2 changed files with 69 additions and 116 deletions

View file

@ -1,13 +1,14 @@
package com.lagradost package com.lagradost
import android.util.Log import android.util.Log
import com.lagradost.models.PlayerJson
import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.LoadResponse.Companion.addActors import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper
import org.jsoup.Jsoup import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
import java.util.* import java.util.*
@ -74,7 +75,6 @@ class EneyidaProvider : MainAPI() {
// Detailed information // Detailed information
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document val document = app.get(url).document
// Parse info // Parse info
val full_info = document.select(".full_info li") val full_info = document.select(".full_info li")
val title = document.selectFirst("div.full_header-title h1")?.text()?.trim().toString() val title = document.selectFirst("div.full_header-title h1")?.text()?.trim().toString()
@ -96,24 +96,27 @@ class EneyidaProvider : MainAPI() {
// Return to app // Return to app
// Parse Episodes as Series // Parse Episodes as Series
return if (tvType == TvType.TvSeries) { return if (tvType == TvType.TvSeries) {
val id = url.split("/").last().split("-").first() var episodes: List<Episode> = emptyList()
val episodes = val playerRawJson = app.get(playerUrl).document.select("script").html()
app.get("$mainUrl/engine/ajax/playlists.php?news_id=$id&xfield=playlist&time=${Date().time}") .substringAfterLast("file:\'")
.parsedSafe<Responses>()?.response.let { .substringBefore("\',")
Jsoup.parse(it.toString()).select("div.playlists-videos li").mapNotNull { eps ->
val href = "$mainUrl/engine/ajax/playlists.php?news_id=$id&xfield=playlist&time=${Date().time}" tryParseJson<List<PlayerJson>>(playerRawJson)?.map { dubs -> // Dubs
val name = eps.text().trim() // Серія 1 for(season in dubs.folder){ // Seasons
if (href.isNotEmpty()) { for(episode in season.folder){ // Episodes
Episode( episodes = episodes.plus(
"$href,$name", // link, Серія 1 Episode(
name, "${season.title}, ${episode.title}, $playerUrl",
) episode.title,
} else { season.title.replace(" Сезон ","").toIntOrNull(),
null episode.title.replace("Серія ","").toIntOrNull(),
} episode.poster
} )
)
} }
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes.distinctBy{ it.name }) { }
}
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
this.posterUrl = poster this.posterUrl = poster
this.year = year this.year = year
this.plot = description this.plot = description
@ -124,7 +127,7 @@ class EneyidaProvider : MainAPI() {
addTrailer(trailer) addTrailer(trailer)
} }
} else { // Parse as Movie. } else { // Parse as Movie.
newMovieLoadResponse(title, url, TvType.Movie, url) { newMovieLoadResponse(title, url, TvType.Movie, "$title, $playerUrl") {
this.posterUrl = poster this.posterUrl = poster
this.year = year this.year = year
this.plot = description this.plot = description
@ -139,121 +142,49 @@ class EneyidaProvider : MainAPI() {
// It works when I click to view the series // It works when I click to view the series
override suspend fun loadLinks( override suspend fun loadLinks(
data: String, // link, episode name data: String, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url]
isCasting: Boolean, isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
val dataList = data.split(",") val dataList = data.split(", ")
// TODO: OPTIMIZE code!!! Remove this shitty code as soon as possible!!!!!!
if(dataList.size == 1){
val id = data.split("/").last().split("-").first()
val responseGet = app.get("$mainUrl/engine/ajax/playlists.php?news_id=$id&xfield=playlist&time=${Date().time}").parsedSafe<Responses>()
if (responseGet?.success == true) { // Its serial
responseGet?.response?.let {
Jsoup.parse(it).select("div.playlists-videos li")
.mapNotNull { eps ->
var href = eps.attr("data-file") // ashdi
// Can be without https:
if (!href.contains("https://")) {
href = "https:$href"
}
val dub = eps.attr("data-voice") // FanWoxUA
// Get m3u from player script // Its film, parse one m3u8
app.get(href, referer = "$mainUrl/").document.select("script") if(dataList.size == 2){
.map { script -> val m3u8Url = app.get(dataList[1]).document.select("script").html()
if (script.data().contains("var player = new Playerjs({")) { .substringAfterLast("file:\"")
val m3uLink = script.data().substringAfterLast("file:\"") .substringBefore("\",")
.substringBefore("\",") Log.d("loadLinks-debug", m3u8Url)
M3u8Helper.generateM3u8(
source = dataList[0],
streamUrl = m3u8Url,
referer = "https://tortuga.wtf/"
).forEach(callback)
// Add as source
M3u8Helper.generateM3u8(
source = dub,
streamUrl = m3uLink,
referer = "https://ashdi.vip/"
).forEach(callback)
}
}
}
}
} else {
// Its maybe film
val document = app.get(data).document
val iframeUrl = document.selectFirst("iframe#pre")?.attr("src")
// Get m3u from player script
if (iframeUrl != null) {
app.get(iframeUrl, referer = "$mainUrl/").document.select("script").map { script ->
if (script.data().contains("var player = new Playerjs({")) {
val m3uLink = script.data().substringAfterLast("file:\"").substringBefore("\",")
// Add as source
M3u8Helper.generateM3u8(
source = document.selectFirst("h1 span.solototle")?.text()?.trim().toString(),
streamUrl = m3uLink,
referer = "https://ashdi.vip/"
).forEach(callback)
}
}
}
}
return true return true
} }
val responseGet = app.get(dataList[0]).parsedSafe<Responses>() // ajax link val playerRawJson = app.get(dataList[2]).document.select("script").html()
if (responseGet?.success == true){ // Its serial .substringAfterLast("file:\'")
responseGet?.response?.let { .substringBefore("\',")
Jsoup.parse(it).select("div.playlists-videos li:contains(${dataList[1]})").mapNotNull { eps ->
var href = eps.attr("data-file") // ashdi
// Can be without https:
if (! href.contains("https://")) {
href = "https:$href"
}
val dub = eps.attr("data-voice") // FanWoxUA
// Get m3u from player script
app.get(href, referer = "$mainUrl/").document.select("script").map { script ->
if (script.data().contains("var player = new Playerjs({")) {
val m3uLink = script.data().substringAfterLast("file:\"").substringBefore("\",")
tryParseJson<List<PlayerJson>>(playerRawJson)?.map { dubs -> // Dubs
for(season in dubs.folder){ // Seasons
if(season.title == dataList[0]){
for(episode in season.folder){ // Episodes
if(episode.title == dataList[1]){
// Add as source // Add as source
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
source = dub, source = dubs.title,
streamUrl = m3uLink, streamUrl = episode.file,
referer = "https://ashdi.vip/" referer = "https://tortuga.wtf/"
).forEach(callback) ).forEach(callback)
} }
} }
} }
} }
} else {
// Its maybe film
val document = app.get(data).document
val iframeUrl = document.selectFirst("iframe#pre")?.attr("src")
// Get m3u from player script
if (iframeUrl != null) {
app.get(iframeUrl, referer = "$mainUrl/").document.select("script").map { script ->
if (script.data().contains("var player = new Playerjs({")) {
val m3uLink = script.data().substringAfterLast("file:\"").substringBefore("\",")
// Add as source
M3u8Helper.generateM3u8(
source = document.selectFirst("h1 span.solototle")?.text()?.trim().toString(),
streamUrl = m3uLink,
referer = "https://ashdi.vip/"
).forEach(callback)
}
}
}
} }
return true return true
} }
data class Responses(
val success: Boolean?,
val response: String,
)
} }

View file

@ -0,0 +1,22 @@
package com.lagradost.models
data class PlayerJson (
val title : String,
val folder : List<Season>
)
data class Season (
val title : String,
val folder : List<Episode>
)
data class Episode (
val title : String,
val file : String,
val id : String,
val poster : String,
val subtitle : String,
)