animeua: Add MAL/AniList
This commit is contained in:
parent
70e197c958
commit
e21570f834
3 changed files with 75 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
// use an integer for version numbers
|
||||
version = 1
|
||||
version = 2
|
||||
|
||||
|
||||
cloudstream {
|
||||
|
@ -16,7 +16,7 @@ cloudstream {
|
|||
* 2: Slow
|
||||
* 3: Beta only
|
||||
* */
|
||||
status = 3 // will be 3 if unspecified
|
||||
status = 1 // will be 3 if unspecified
|
||||
tvTypes = listOf(
|
||||
"Anime",
|
||||
"AnimeMovie",
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package com.lagradost
|
||||
|
||||
import android.util.Log
|
||||
import com.lagradost.models.PlayerJson
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addAniListId
|
||||
import com.lagradost.cloudstream3.LoadResponse.Companion.addMalId
|
||||
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.M3u8Helper
|
||||
|
@ -55,13 +58,14 @@ class AnimeUAProvider : MainAPI() {
|
|||
return newHomePageResponse(request.name, home)
|
||||
}
|
||||
|
||||
private fun Element.toSearchResponse(): SearchResponse {
|
||||
private fun Element.toSearchResponse(): AnimeSearchResponse {
|
||||
val title = this.selectFirst(titleSelector)?.text()?.trim().toString()
|
||||
val href = this.selectFirst(hrefSelector)?.attr("href").toString()
|
||||
val posterUrl = mainUrl + this.selectFirst(posterSelector)?.attr("data-src")
|
||||
|
||||
return newMovieSearchResponse(title, href, TvType.Anime) {
|
||||
val status = this.select(".poster__label").text()
|
||||
return newAnimeSearchResponse(title, href, TvType.Anime) {
|
||||
this.posterUrl = posterUrl
|
||||
addDubStatus(isDub = true)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -87,6 +91,7 @@ class AnimeUAProvider : MainAPI() {
|
|||
// Parse info
|
||||
|
||||
val title = document.selectFirst(titleLoadSelector)?.text()?.trim().toString()
|
||||
val engTitle = document.select(".pmovie__original-title").text()
|
||||
val poster = mainUrl + document.selectFirst("div.page__subcol-side $posterSelector")?.attr("data-src")
|
||||
val tags = document.select(genresSelector).map { it.text() }
|
||||
val year = document.select(yearSelector).text().substringAfter(": ").substringBefore("-").toIntOrNull()
|
||||
|
@ -107,6 +112,9 @@ class AnimeUAProvider : MainAPI() {
|
|||
it.toSearchResponse()
|
||||
}
|
||||
|
||||
val (malId, anilistId, image, cover) = Tracker().getTracker(engTitle, "TV", year)
|
||||
Log.d("load-debug", engTitle)
|
||||
//Log.d("load-debug", anilistId!!)
|
||||
// Return to app
|
||||
// Parse Episodes as Series
|
||||
return if (tvType == TvType.Anime || tvType == TvType.OVA) {
|
||||
|
@ -130,13 +138,16 @@ class AnimeUAProvider : MainAPI() {
|
|||
}
|
||||
}
|
||||
}
|
||||
newTvSeriesLoadResponse(title, url, tvType, episodes) {
|
||||
newAnimeLoadResponse(title, url, tvType) {
|
||||
this.posterUrl = poster
|
||||
this.year = year
|
||||
this.plot = description
|
||||
this.tags = tags
|
||||
this.rating = rating
|
||||
this.recommendations = recommendations
|
||||
addEpisodes(DubStatus.Dubbed, episodes)
|
||||
addMalId(malId)
|
||||
addAniListId(anilistId?.toIntOrNull())
|
||||
}
|
||||
} else { // Parse as Movie.
|
||||
newMovieLoadResponse(title, url, tvType, "$title, $playerUrl") {
|
||||
|
|
58
AnimeUAProvider/src/main/kotlin/com/lagradost/Tracker.kt
Normal file
58
AnimeUAProvider/src/main/kotlin/com/lagradost/Tracker.kt
Normal file
|
@ -0,0 +1,58 @@
|
|||
package com.lagradost
|
||||
|
||||
import android.util.Log
|
||||
import com.lagradost.cloudstream3.app
|
||||
|
||||
class Tracker {
|
||||
suspend fun getTracker(title: String?, type: String?, year: Int?): Tracker {
|
||||
val res = app.get("https://api.consumet.org/meta/anilist/$title")
|
||||
.parsedSafe<AniSearch>()?.results?.find { media ->
|
||||
Log.d("load-debug", media.toString())
|
||||
(media.title?.english.equals(title, true) || media.title?.romaji.equals(
|
||||
title,
|
||||
true
|
||||
))
|
||||
}
|
||||
return Tracker(res?.malId, res?.aniId, res?.image, res?.cover)
|
||||
}
|
||||
|
||||
data class Tracker(
|
||||
val malId: Int? = null,
|
||||
val aniId: String? = null,
|
||||
val image: String? = null,
|
||||
val cover: String? = null,
|
||||
)
|
||||
|
||||
data class Title(
|
||||
val romaji: String? = null,
|
||||
val english: String? = null,
|
||||
)
|
||||
|
||||
data class Results(
|
||||
val aniId: String? = null,
|
||||
val malId: Int? = null,
|
||||
val title: Title? = null,
|
||||
val releaseDate: Int? = null,
|
||||
val type: String? = null,
|
||||
val image: String? = null,
|
||||
val cover: String? = null,
|
||||
)
|
||||
|
||||
data class AniSearch(
|
||||
val results: ArrayList<Results>? = arrayListOf(),
|
||||
)
|
||||
|
||||
private data class Episodes(
|
||||
val file: String? = null,
|
||||
val title: String? = null,
|
||||
val poster: String? = null,
|
||||
)
|
||||
|
||||
private data class Home(
|
||||
val table: String? = null,
|
||||
)
|
||||
|
||||
private data class Search(
|
||||
val mes: String? = null,
|
||||
)
|
||||
}
|
Loading…
Reference in a new issue