unimay: Update models and add new MainPage
All checks were successful
Build / build (push) Successful in 1m23s

This commit is contained in:
CakesTwix 2024-08-11 12:02:19 +03:00
parent b0c94febf5
commit 752f95fe38
Signed by: CakesTwix
GPG key ID: 7B11051D5CE19825
5 changed files with 183 additions and 66 deletions

View file

@ -1,5 +1,9 @@
// use an integer for version numbers // use an integer for version numbers
version = 6 version = 7
dependencies{
implementation("com.google.code.gson:gson:2.9.0")
}
cloudstream { cloudstream {
language = "uk" language = "uk"

View file

@ -1,5 +1,8 @@
package com.lagradost package com.lagradost
import android.util.Log
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.DubStatus
import com.lagradost.cloudstream3.Episode import com.lagradost.cloudstream3.Episode
import com.lagradost.cloudstream3.HomePageResponse import com.lagradost.cloudstream3.HomePageResponse
@ -21,8 +24,8 @@ import com.lagradost.cloudstream3.newHomePageResponse
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 com.lagradost.models.Releases import com.lagradost.models.Releases
import com.lagradost.models.SearchGet
import com.lagradost.models.SearchModel import com.lagradost.models.SearchModel
import com.lagradost.models.Updates
class UnimayProvider : MainAPI() { class UnimayProvider : MainAPI() {
@ -39,13 +42,15 @@ class UnimayProvider : MainAPI() {
private val apiUrl = "https://api.unimay.media" private val apiUrl = "https://api.unimay.media"
private val findUrl = "$apiUrl/v1/release/search?title=" private val findUrl = "$apiUrl/v1/release/search?title="
private val imagesUrl = "$apiUrl/storage/images/" private val imagesUrl = "https://img.unimay.media/"
private val TAG = name private val TAG = name
private val listUpdatesModel = object : TypeToken<List<Updates>>() { }.type
// Sections // Sections
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
"$apiUrl/api/release/all?page=" to "Останні релізи", "$apiUrl/v1/list/series/updates?size=15" to "Останні релізи",
"$apiUrl/v1/release/search?page_size=10&page=" to "Наши проєкти",
) )
// Done // Done
@ -53,19 +58,29 @@ class UnimayProvider : MainAPI() {
page: Int, page: Int,
request: MainPageRequest request: MainPageRequest
): HomePageResponse { ): HomePageResponse {
val homeList = app.get("${request.data}$page").parsedSafe<Releases>()!!.releases.map{ if (page != 1 && request.data.contains("updates")) return HomePageResponse(emptyList())
newAnimeSearchResponse(it.name, "$apiUrl/api/release/${it.code}", TvType.Anime) { if (request.data.contains("updates")){
this.posterUrl = "$imagesUrl${it.imageId}" val homeList = Gson().fromJson<List<Updates>>(app.get("${request.data}").text, listUpdatesModel).map{
addDubStatus("${it.playlistSize}/${it.episodes}", it.playlistSize) newAnimeSearchResponse(it.release.name, "$apiUrl/v1/release?code=${it.release.code}", TvType.Anime) {
this.posterUrl = "$imagesUrl${it.release.posterUuid}"
addDubStatus(DubStatus.Dubbed, it.series.number)
} }
} }
return newHomePageResponse(request.name, homeList)
}
val homeList = Gson().fromJson(app.get("${request.data}${page}").text, SearchModel::class.java).content.map{
newAnimeSearchResponse(it.names.ukr, "$apiUrl/v1/release?code=${it.code}", TvType.Anime) {
this.posterUrl = "$imagesUrl${it.images.poster}"
addDubStatus(DubStatus.Dubbed, it.playlistSize)
}
}
return newHomePageResponse(request.name, homeList) return newHomePageResponse(request.name, homeList)
} }
override suspend fun search(query: String): List<SearchResponse> { override suspend fun search(query: String): List<SearchResponse> {
return app.get("$findUrl$query&page=0").parsedSafe<SearchGet>()!!.content.map{ return Gson().fromJson(app.get("$findUrl$query&page=0").text, SearchModel::class.java).content.map{
newAnimeSearchResponse(it.names.ukr, "$apiUrl/api/release/${it.code}", TvType.Anime) { newAnimeSearchResponse(it.names.ukr, "$apiUrl/v1/release?code=${it.code}", TvType.Anime) {
this.posterUrl = "$imagesUrl${it.images.poster}" this.posterUrl = "$imagesUrl${it.images.poster}"
addDubStatus("${it.playlistSize}/${it.playlistSize}", it.playlistSize) addDubStatus("${it.playlistSize}/${it.playlistSize}", it.playlistSize)
} }
@ -75,7 +90,7 @@ class UnimayProvider : MainAPI() {
// Detailed information // Detailed information
override suspend fun load(url: String): LoadResponse { override suspend fun load(url: String): LoadResponse {
// Log.d("CakesTwix-Debug", url) // Log.d("CakesTwix-Debug", url)
val anime = app.get(url).parsedSafe<SearchModel>()!! val anime = Gson().fromJson(app.get(url).text, Releases::class.java)
// val anime = Gson().fromJson(app.get("$apiUrl/api/release/${url.substringAfterLast("/")}").text, SearchModel::class.java) // val anime = Gson().fromJson(app.get("$apiUrl/api/release/${url.substringAfterLast("/")}").text, SearchModel::class.java)
val showStatus = when(anime.statusCode){ val showStatus = when(anime.statusCode){
@ -96,17 +111,17 @@ class UnimayProvider : MainAPI() {
"${anime.code}, ${it.number}", "${anime.code}, ${it.number}",
it.title, it.title,
episode = it.number, episode = it.number,
posterUrl = if(it.previewId != null) { "$imagesUrl${it.previewId}" } else null, posterUrl = if(it.imageUuid != null) { "$imagesUrl${it.imageUuid}" } else null,
) )
} }
return newAnimeLoadResponse( return newAnimeLoadResponse(
anime.name, anime.names.ukr,
"$mainUrl/projects/${anime.code}", "$mainUrl/projects/${anime.code}",
tvType, tvType,
) { ) {
this.engName = anime.engName this.engName = anime.names.eng
this.posterUrl = "$imagesUrl${anime.posterId}" this.posterUrl = "$imagesUrl${anime.images.banner}"
this.tags = anime.genres this.tags = anime.genres
this.plot = anime.description this.plot = anime.description
this.showStatus = showStatus this.showStatus = showStatus
@ -126,16 +141,13 @@ class UnimayProvider : MainAPI() {
): Boolean { ): Boolean {
// anime_id, episode number // anime_id, episode number
val dataList = data.split(", ") val dataList = data.split(", ")
// Log.d("CakesTwix-Debug", dataList.toString()) val anime = Gson().fromJson(app.get("$apiUrl/v1/release?code=${dataList[0]}").text, Releases::class.java)
val anime = app.get("$apiUrl/api/release/${dataList[0]}").parsedSafe<SearchModel>()!!
// val anime = Gson().fromJson(app.get("$apiUrl/api/release/${dataList[0]}").text, SearchModel::class.java)
val episode = anime.playlist.first { it.number == dataList[1].toInt() } val episode = anime.playlist.first { it.number == dataList[1].toInt() }
if (episode.playlist != null) { if (episode.hls != null) {
M3u8Helper.generateM3u8( M3u8Helper.generateM3u8(
source = "Unimay", source = "Unimay",
streamUrl = episode.playlist, streamUrl = episode.hls.master,
referer = "https://www.unimay.media" referer = "https://www.unimay.media"
).forEach(callback) ).forEach(callback)
return true return true

View file

@ -2,22 +2,95 @@ package com.lagradost.models
data class Releases( data class Releases(
val titleCount : Int,
val releases : List<Release>
)
data class Release (
val id : Int, val id : Int,
val imageId : Int, val aniListId : Int,
// val lastUpdate : Int,
// val lastEdit : Int,
val statusCode : Int,
val episodes : Int, val episodes : Int,
val playlistSize : Int,
val episodeLength : Int, val episodeLength : Int,
val year : Int, val year : Int,
val playlistSize : Int,
val commentsCount : Int,
val restricted : Boolean, val restricted : Boolean,
val adult : Boolean,
val partOfFranchise : Boolean,
val announcement : String,
val collaboration : String,
val code : String, val code : String,
val description : String, val imdbId : String,
val name : String, val tgCode : String,
val trailer : String,
val type : String,
val season : String, val season : String,
val statusCode : Int val description : String,
val names : Names,
val images : Images,
val genres : List<String>,
val playlist : List<Playlist>,
val actors : List<Actors>,
val translators : List<Translators>,
val soundmen : List<Soundmen>
)
data class Actors (
val id : Int,
val imageUuid : String,
val nickName : String
)
data class Hls (
val qualities : Qualities,
val master : String
)
data class Images (
val banner : String,
val logo : String,
val poster : String
)
data class Names (
val romaji : String,
val ukr : String,
val eng : String
)
data class Playlist (
val id : Int,
val imageUuid : String,
val number : Int,
val duration : Int,
val premium : Boolean,
val thumbnails : Boolean,
val uuid : String,
val title : String,
// val creationTimestamp : Int,
val hls : Hls
)
data class Qualities (
val fhd : String,
val hd : String,
val qhd : String
)
data class Soundmen (
val id : Int,
val imageUuid : String,
val nickName : String
)
data class Translators (
val id : Int,
val imageUuid : String,
val nickName : String
) )

View file

@ -2,53 +2,52 @@ package com.lagradost.models
data class SearchModel ( data class SearchModel (
val code : String,
val year : Int,
val description : String,
val type : String,
val engName : String,
// val translators : List<Translators>,
val playlist : List<Playlist>,
val genres : List<String>,
val aniListId : Int,
val imageId : Int,
val name : String,
val posterId : Int,
val statusCode : Int,
val episodeLength : Int,
)
data class Playlist (
val preview : Int,
val title : String,
val number : Int,
val previewId : Int,
val playlist : String,
)
data class SearchGet (
val content : List<Content>, val content : List<Content>,
val pageable : Pageable,
val totalElements : Int,
val last : Boolean,
val totalPages : Int,
val size : Int,
val number : Int,
val sort : Sort,
val numberOfElements : Int,
val first : Boolean,
val empty : Boolean
) )
data class Content ( data class Content (
val id : Int, val id : Int,
val aniListId : Int,
// val lastUpdate : Int,
val episodes : Int,
val playlistSize : Int, val playlistSize : Int,
val statusCode : Int,
val year : Int,
val adult : Boolean,
val restricted : Boolean,
val code : String, val code : String,
val type : String,
val season : String,
val description : String,
val names : Names, val names : Names,
val images : Images, val images : Images,
val genres : List<String>
) )
data class Images ( data class Pageable (
val banner : Int?, val sort : Sort,
val poster : Int val pageNumber : Int,
val pageSize : Int,
val offset : Int,
val paged : Boolean,
val unpaged : Boolean
) )
data class Names ( data class Sort (
val romaji : String, val sorted : Boolean,
val ukr : String, val empty : Boolean,
val eng : String val unsorted : Boolean
) )

View file

@ -0,0 +1,29 @@
package com.lagradost.models
data class Updates (
val series : Series,
val release : Release
)
data class Release (
val id : Int,
// vval lastUpdate : Int,
val posterUuid : String,
val code : String,
val name : String,
val type : String
)
data class Series (
val id : Int,
val imageUuid : String,
val number : Int,
val premium : Boolean,
val duration : Int,
val title : String,
// val creationTimestamp : Int,
val releaseId : Int
)