Skip to content

Commit

Permalink
Ultima: AniList: Fix wrong episodes playing (https://discord.com/chan…
Browse files Browse the repository at this point in the history
…nels/1239637180700164136/1261144594347851848)

- "season year" is not recognised by media provider sites and show "start year" was required
- Fizes wrong episodes from Aniwave
- Provides links form Anitaku
  • Loading branch information
RowdyRushya committed Jul 12, 2024
1 parent 1744da9 commit 173261c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Ultima/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ dependencies {
implementation("com.google.android.material:material:1.12.0")
}
// use an integer for version numbers
version = 32
version = 33


cloudstream {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ class AniwaveMediaProvider : MediaProvider() {
callback: (ExtractorLink) -> Unit
) {
val episode = data.episode ?: if (data.isAnime && data.type.equals("Movie")) 1 else return
val searchPage =
app.get(
"$url/filter?keyword=${data.title}&year[]=${data.year?:""}&sort=most_relevance"
)
.document
val filterUrl =
"$url/filter?keyword=${data.title}&year[]=${data.year?:""}&sort=most_relevance"
val searchPage = app.get(filterUrl).document
val id =
searchPage.selectFirst("div.poster")?.attr("data-tip")?.split("?/")?.get(0)
?: return
Expand Down
10 changes: 6 additions & 4 deletions Ultima/src/main/kotlin/com/RowdyAvocado/MetaProviders/AniList.kt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class AniList(val plugin: UltimaPlugin) : MainAPI() {
val id = url.removeSuffix("/").substringAfterLast("/")
val data =
anilistAPICall(
"query (\$id: Int = $id) { Media (id: \$id, type: ANIME) { id title { romaji english } seasonYear genres description averageScore bannerImage coverImage { extraLarge large medium } bannerImage episodes nextAiringEpisode { episode } recommendations { edges { node { id mediaRecommendation { id title { romaji english } coverImage { extraLarge large medium } } } } } } }"
"query (\$id: Int = $id) { Media (id: \$id, type: ANIME) { id title { romaji english } startDate { year } genres description averageScore bannerImage coverImage { extraLarge large medium } bannerImage episodes nextAiringEpisode { episode } recommendations { edges { node { id mediaRecommendation { id title { romaji english } coverImage { extraLarge large medium } } } } } } }"
)
.data
.media
Expand All @@ -140,7 +140,7 @@ class AniList(val plugin: UltimaPlugin) : MainAPI() {
val linkData =
LinkData(
title = data.getTitle(),
year = data.seasonYear,
year = data.startDate.year,
season = 1,
episode = i,
isAnime = true
Expand All @@ -151,7 +151,7 @@ class AniList(val plugin: UltimaPlugin) : MainAPI() {
return newAnimeLoadResponse(data.getTitle(), url, TvType.Anime) {
addAniListId(id.toInt())
addEpisodes(DubStatus.Subbed, episodes)
this.year = data.seasonYear
this.year = data.startDate.year
this.plot = data.description
this.backgroundPosterUrl = data.bannerImage
this.posterUrl = data.getCoverImage()
Expand Down Expand Up @@ -199,7 +199,7 @@ class AniList(val plugin: UltimaPlugin) : MainAPI() {

data class anilistMedia(
@JsonProperty("id") val id: Int,
@JsonProperty("seasonYear") val seasonYear: Int,
@JsonProperty("startDate") val startDate: StartDate,
@JsonProperty("episodes") val episodes: Int?,
@JsonProperty("title") val title: Title,
@JsonProperty("genres") val genres: List<String>,
Expand All @@ -209,6 +209,8 @@ class AniList(val plugin: UltimaPlugin) : MainAPI() {
@JsonProperty("nextAiringEpisode") val nextAiringEpisode: SeasonNextAiringEpisode?,
@JsonProperty("recommendations") val recommendations: RecommendationConnection?,
) {
data class StartDate(@JsonProperty("year") val year: Int)

fun totalEpisodes(): Int {
return nextAiringEpisode?.episode?.minus(1)
?: episodes ?: throw Exception("Unable to calculate total episodes")
Expand Down

0 comments on commit 173261c

Please sign in to comment.