Anitubeinua: Parse main and impl. load
This commit is contained in:
parent
04dd470753
commit
80800dc8ba
1 changed files with 39 additions and 66 deletions
|
@ -1,9 +1,11 @@
|
||||||
package com.lagradost
|
package com.lagradost
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
import com.lagradost.models.PlayerJson
|
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.toJson
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
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
|
||||||
|
@ -12,24 +14,20 @@ import org.jsoup.nodes.Element
|
||||||
class AnitubeinuaProvider : MainAPI() {
|
class AnitubeinuaProvider : MainAPI() {
|
||||||
|
|
||||||
// Basic Info
|
// Basic Info
|
||||||
override var mainUrl = "https://eneyida.tv"
|
override var mainUrl = "https://anitube.in.ua"
|
||||||
override var name = "Anitubeinua"
|
override var name = "Anitubeinua"
|
||||||
override val hasMainPage = true
|
override val hasMainPage = true
|
||||||
override var lang = "uk"
|
override var lang = "uk"
|
||||||
override val hasDownloadSupport = true
|
override val hasDownloadSupport = true
|
||||||
override val supportedTypes = setOf(
|
override val supportedTypes = setOf(
|
||||||
TvType.Movie,
|
TvType.AnimeMovie,
|
||||||
TvType.TvSeries,
|
|
||||||
TvType.Anime,
|
TvType.Anime,
|
||||||
)
|
)
|
||||||
|
|
||||||
// Sections
|
// Sections
|
||||||
override val mainPage = mainPageOf(
|
override val mainPage = mainPageOf(
|
||||||
"$mainUrl/films/page/" to "Фільми",
|
"$mainUrl/anime/page/" to "Нові",
|
||||||
"$mainUrl/series/page/" to "Серіали",
|
"$mainUrl/f/sort=rating/order=desc/page/" to "Популярне",
|
||||||
"$mainUrl/anime/page/" to "Аніме",
|
|
||||||
"$mainUrl/cartoon/page/" to "Мультфільми",
|
|
||||||
"$mainUrl/cartoon-series/page/" to "Мультсеріали",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
override suspend fun getMainPage(
|
override suspend fun getMainPage(
|
||||||
|
@ -38,16 +36,16 @@ class AnitubeinuaProvider : MainAPI() {
|
||||||
): HomePageResponse {
|
): HomePageResponse {
|
||||||
var document = app.get(request.data + page).document
|
var document = app.get(request.data + page).document
|
||||||
|
|
||||||
val home = document.select("article.short").map {
|
val home = document.select(".story").map {
|
||||||
it.toSearchResponse()
|
it.toSearchResponse()
|
||||||
}
|
}
|
||||||
return newHomePageResponse(request.name, home)
|
return newHomePageResponse(request.name, home)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun Element.toSearchResponse(): SearchResponse {
|
private fun Element.toSearchResponse(): SearchResponse {
|
||||||
val title = this.selectFirst("a.short_title")?.text()?.trim().toString()
|
val title = this.selectFirst(".story_c h2 a")?.text()?.trim().toString()
|
||||||
val href = this.selectFirst("a.short_title")?.attr("href").toString()
|
val href = this.selectFirst(".story_c h2 a")?.attr("href").toString()
|
||||||
val posterUrl = mainUrl + this.selectFirst("a.short_img img")?.attr("data-src")
|
val posterUrl = mainUrl + this.selectFirst(".story_c_l span.story_post img")?.attr("src")
|
||||||
|
|
||||||
return newMovieSearchResponse(title, href, TvType.Movie) {
|
return newMovieSearchResponse(title, href, TvType.Movie) {
|
||||||
this.posterUrl = posterUrl
|
this.posterUrl = posterUrl
|
||||||
|
@ -73,71 +71,46 @@ class AnitubeinuaProvider : 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
|
||||||
|
|
||||||
|
var someInfo = document.select("div.story_c_r")[1]
|
||||||
|
|
||||||
// Parse info
|
// Parse info
|
||||||
val full_info = document.select(".full_info li")
|
val title = document.selectFirst(".story_c h2")?.text()?.trim().toString()
|
||||||
val title = document.selectFirst("div.full_header-title h1")?.text()?.trim().toString()
|
val poster = mainUrl + document.selectFirst(".story_c_left span.story_post img")?.attr("src")
|
||||||
val poster = mainUrl + document.selectFirst(".full_content-poster img")?.attr("src")
|
val tags = someInfo.select("noindex a").html().split("\n").map { it }
|
||||||
val tags = full_info[1].select("a").map { it.text() }
|
val year = someInfo.select("strong:contains(Рік випуску аніме:)").next().html().toIntOrNull()
|
||||||
val year = full_info[0].select("a").text().toIntOrNull()
|
|
||||||
val playerUrl = document.select(".tabs_b.visible iframe").attr("src")
|
|
||||||
|
|
||||||
val tvType = if (tags.contains("фільм") or playerUrl.contains("/vod/")) TvType.Movie else TvType.TvSeries
|
val tvType = TvType.Anime
|
||||||
val description = document.selectFirst(".full_content-desc p")?.text()?.trim()
|
val description = document.selectFirst("div.my-text")?.text()?.trim()
|
||||||
val trailer = document.selectFirst("div#trailer_place iframe")?.attr("src").toString()
|
// val author = someInfo.select("strong:contains(Студія:)").next().html()
|
||||||
val rating = document.selectFirst(".r_kp span, .r_imdb span")?.text().toRatingInt()
|
val rating = document.selectFirst(".lexington-box > div:last-child span")?.text().toRatingInt()
|
||||||
val actors = full_info[4].select("a").map { it.text() }
|
|
||||||
|
|
||||||
val recommendations = document.select(".short.related_item").map {
|
val recommendations = document.select(".horizontal ul").map {
|
||||||
it.toSearchResponse()
|
it.toSearchResponse()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return to app
|
// Return to app
|
||||||
// Parse Episodes as Series
|
// 12 - json with episodes
|
||||||
return if (tvType == TvType.TvSeries) {
|
// Players, Episodes, Number of episodes
|
||||||
var episodes: List<Episode> = emptyList()
|
// TODO: Parse Episodes
|
||||||
val playerRawJson = app.get(playerUrl).document.select("script").html()
|
val playerScriptJson = document.select("script")[12].html().substringAfterLast(".init(").substringBefore(");")
|
||||||
.substringAfterLast("file:\'")
|
val playerNames = playerScriptJson.substringAfterLast("],")
|
||||||
.substringBefore("\',")
|
val numberOfEpisodes = playerScriptJson.substringAfterLast(",")
|
||||||
|
Log.d("load-debug", playerScriptJson.substringAfterLast(","))
|
||||||
|
|
||||||
tryParseJson<List<PlayerJson>>(playerRawJson)?.map { dubs -> // Dubs
|
var episodes: List<Episode> = emptyList()
|
||||||
for(season in dubs.folder){ // Seasons
|
|
||||||
for(episode in season.folder){ // Episodes
|
return newTvSeriesLoadResponse(title, url, tvType, episodes) {
|
||||||
episodes = episodes.plus(
|
this.posterUrl = poster
|
||||||
Episode(
|
this.year = year
|
||||||
"${season.title}, ${episode.title}, $playerUrl",
|
this.plot = description
|
||||||
episode.title,
|
this.tags = tags
|
||||||
season.title.replace(" Сезон ","").toIntOrNull(),
|
this.rating = rating
|
||||||
episode.title.replace("Серія ","").toIntOrNull(),
|
this.recommendations = recommendations
|
||||||
episode.poster
|
|
||||||
)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes) {
|
|
||||||
this.posterUrl = poster
|
|
||||||
this.year = year
|
|
||||||
this.plot = description
|
|
||||||
this.tags = tags
|
|
||||||
this.rating = rating
|
|
||||||
addActors(actors)
|
|
||||||
this.recommendations = recommendations
|
|
||||||
addTrailer(trailer)
|
|
||||||
}
|
|
||||||
} else { // Parse as Movie.
|
|
||||||
newMovieLoadResponse(title, url, TvType.Movie, "$title, $playerUrl") {
|
|
||||||
this.posterUrl = poster
|
|
||||||
this.year = year
|
|
||||||
this.plot = description
|
|
||||||
this.tags = tags
|
|
||||||
this.rating = rating
|
|
||||||
addActors(actors)
|
|
||||||
this.recommendations = recommendations
|
|
||||||
addTrailer(trailer)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url]
|
data: String, // (Serisl) [Season, Episode, Player Url] | (Film) [Title, Player Url]
|
||||||
|
|
Loading…
Reference in a new issue