diff --git a/YacienTVProvider/src/main/kotlin/com/yacientv/YacienTVProvider.kt b/YacienTVProvider/src/main/kotlin/com/yacientv/YacienTVProvider.kt index 128935c4..9e7da3cb 100644 --- a/YacienTVProvider/src/main/kotlin/com/yacientv/YacienTVProvider.kt +++ b/YacienTVProvider/src/main/kotlin/com/yacientv/YacienTVProvider.kt @@ -36,13 +36,14 @@ class YacienTV : MainAPI() { } override val mainPage = mainPageOf( + //"$yacienTVAPI/events" to "Live Events", "$yacienTVAPI/categories/4/channels" to "beIN SPORTS (1080P)", "$yacienTVAPI/categories/5/channels" to "beIN SPORTS (720P)", "$yacienTVAPI/categories/6/channels" to "beIN SPORTS (360P)", "$yacienTVAPI/categories/7/channels" to "beIN SPORTS (244P)", "$yacienTVAPI/categories/8/channels" to "beIN ENTERTAINMENT", "$yacienTVAPI/categories/86/channels" to "SSC SPORTS", - //"$yacienTVAPI/categories/9/channels" to "ARABIC CHANNELS", + "$yacienTVAPI/categories/9" to "ARABIC CHANNELS", "$yacienTVAPI/categories/10/channels" to "OSN CHANNELS", "$yacienTVAPI/categories/11/channels" to "MBC CHANNELS", "$yacienTVAPI/categories/12/channels" to "FRANCE CHANNELS", @@ -51,70 +52,68 @@ class YacienTV : MainAPI() { "$yacienTVAPI/categories/87/channels" to "WEYYAK", "$yacienTVAPI/categories/94/channels" to "SHAHID VIP", ) - - data class Channel( - @JsonProperty("id") val id: String? = null, - @JsonProperty("name") val name: String? = null, - @JsonProperty("logo") val logo: String? = null, - ) - - data class Results( - @JsonProperty("data") val results: ArrayList? = arrayListOf(), - ) - - data class ChannelResults( - @JsonProperty("data") val links: ArrayList? = arrayListOf(), - ) - - data class Links( - @JsonProperty("name") val name: String, - @JsonProperty("url") val url: String, - @JsonProperty("url_type") val urltype: String, - @JsonProperty("user_agent") val useragent: String, - @JsonProperty("referer") val referer: String, - ) - override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { val items = mutableListOf() if (page <= 1) { //Log.d("King", "request:$request") val decodedbody = getDecoded(request.data) - + Log.d("King", "decodedbody:$decodedbody") val list = parseJson(decodedbody).results?.mapNotNull { element -> element.toSearchResponse(request) - } ?: throw ErrorLoadingException("Invalid Json reponse") + } ?: throw ErrorLoadingException("Invalid Json response") if (list.isNotEmpty()) items.add(HomePageList(request.name, list, true)) } return newHomePageResponse(items) } - - data class Data( - val id: String? = null, - val name: String, - val posterUrl: String? = null, - val category: String, - ) - - data class LinksData( - val id: String, - val name: String, - val posterUrl: String? = null, - val category: String, - ) - private fun Channel.toSearchResponse(request: MainPageRequest, type: String? = null): SearchResponse? { return LiveSearchResponse( name ?: return null, - Data(id = id, name = this.name, posterUrl = logo, category = request.name).toJson(), + Data(id = id, name = name, posterUrl = logo, category = request.name).toJson(), this@YacienTV.name, TvType.Live, logo, ) } - + private fun Event.toSearchResponse(request: MainPageRequest, type: String? = null): SearchResponse? { + return LiveSearchResponse( + name ?: return null, + Data(id = id, name = name, posterUrl = "logo", category = request.name).toJson(), + this@YacienTV.name, + TvType.Live, + "logo", + ) + } override suspend fun load(url: String): LoadResponse { - //Log.d("King", "Load:$url") + Log.d("King", "Load:$url") val data = parseJson(url) + + if (data.category == "ARABIC CHANNELS"){ + val decodedbody = getDecoded("$yacienTVAPI/categories/${data.id}/channels") + //Log.d("King", "Arabicdecodedbody:$decodedbody") + + var channels = parseJson(decodedbody).results?.map { element -> + Episode( + name = element.name, + posterUrl = element.logo, + data = element.id.toString(), + ) + } ?: throw ErrorLoadingException("Invalid Json response") + return newTvSeriesLoadResponse( + name = data.name, + url = Data( + id = data.id, + name = data.name, + posterUrl = data.posterUrl, + category = data.category, + ).toJson(), + type = TvType.TvSeries, + episodes = channels, + ) { + this.posterUrl = data.posterUrl + this.plot = "${data.name} livestreams of ${data.category} category." + } + } + return LiveStreamLoadResponse( name = data.name, url = Data(id = data.id, name = data.name, posterUrl = data.posterUrl, category = data.category).toJson(), @@ -122,17 +121,16 @@ class YacienTV : MainAPI() { apiName = name, posterUrl = data.posterUrl, type = TvType.Live, - plot = "${data.name} live stream of ${data.category} category." + plot = "${data.name} channel livestream of ${data.category} category." ) } - override suspend fun loadLinks( data: String, isCasting: Boolean, subtitleCallback: (SubtitleFile) -> Unit, callback: (ExtractorLink) -> Unit ): Boolean { - //Log.d("King", "loadLinks:$data") + Log.d("King", "loadLinks:$data") val decodedbody = getDecoded("$yacienTVAPI/channel/$data") @@ -167,5 +165,50 @@ class YacienTV : MainAPI() { return decrypt(req.body.string(), req.headers["t"].toString()) } - + data class Team( + @JsonProperty("name") val name: String? = null, + @JsonProperty("logo") val logo: String? = null, + ) + data class Event( + @JsonProperty("id") val id: String? = null, + @JsonProperty("start_time") val start_time: String? = null, + @JsonProperty("end_time") val end_time: String? = null, + @JsonProperty("champions") val champions: String? = null, + @JsonProperty("channel") val channel: String? = null, + @JsonProperty("team_1") val team_1: ArrayList? = arrayListOf(), + @JsonProperty("team_2") val team_2: ArrayList? = arrayListOf(), + ) + data class EventsResults( + @JsonProperty("data") val results: ArrayList? = arrayListOf(), + ) + data class Channel( + @JsonProperty("id") val id: String? = null, + @JsonProperty("name") val name: String? = null, + @JsonProperty("logo") val logo: String? = null, + ) + data class Results( + @JsonProperty("data") val results: ArrayList? = arrayListOf(), + ) + data class ChannelResults( + @JsonProperty("data") val links: ArrayList? = arrayListOf(), + ) + data class Links( + @JsonProperty("name") val name: String, + @JsonProperty("url") val url: String, + @JsonProperty("url_type") val urltype: String, + @JsonProperty("user_agent") val useragent: String, + @JsonProperty("referer") val referer: String, + ) + data class Data( + val id: String? = null, + val name: String, + val posterUrl: String? = null, + val category: String, + ) + data class LinksData( + val id: String, + val name: String, + val posterUrl: String? = null, + val category: String, + ) } \ No newline at end of file