Arabic channels support

This commit is contained in:
KingLucius 2023-07-10 16:08:02 +03:00
parent 81fd1e6c25
commit 177c97ed70

View file

@ -36,13 +36,14 @@ class YacienTV : MainAPI() {
} }
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
//"$yacienTVAPI/events" to "Live Events",
"$yacienTVAPI/categories/4/channels" to "beIN SPORTS (1080P)", "$yacienTVAPI/categories/4/channels" to "beIN SPORTS (1080P)",
"$yacienTVAPI/categories/5/channels" to "beIN SPORTS (720P)", "$yacienTVAPI/categories/5/channels" to "beIN SPORTS (720P)",
"$yacienTVAPI/categories/6/channels" to "beIN SPORTS (360P)", "$yacienTVAPI/categories/6/channels" to "beIN SPORTS (360P)",
"$yacienTVAPI/categories/7/channels" to "beIN SPORTS (244P)", "$yacienTVAPI/categories/7/channels" to "beIN SPORTS (244P)",
"$yacienTVAPI/categories/8/channels" to "beIN ENTERTAINMENT", "$yacienTVAPI/categories/8/channels" to "beIN ENTERTAINMENT",
"$yacienTVAPI/categories/86/channels" to "SSC SPORTS", "$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/10/channels" to "OSN CHANNELS",
"$yacienTVAPI/categories/11/channels" to "MBC CHANNELS", "$yacienTVAPI/categories/11/channels" to "MBC CHANNELS",
"$yacienTVAPI/categories/12/channels" to "FRANCE CHANNELS", "$yacienTVAPI/categories/12/channels" to "FRANCE CHANNELS",
@ -51,70 +52,68 @@ class YacienTV : MainAPI() {
"$yacienTVAPI/categories/87/channels" to "WEYYAK", "$yacienTVAPI/categories/87/channels" to "WEYYAK",
"$yacienTVAPI/categories/94/channels" to "SHAHID VIP", "$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<Channel>? = arrayListOf(),
)
data class ChannelResults(
@JsonProperty("data") val links: ArrayList<Links>? = 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 { override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val items = mutableListOf<HomePageList>() val items = mutableListOf<HomePageList>()
if (page <= 1) { if (page <= 1) {
//Log.d("King", "request:$request") //Log.d("King", "request:$request")
val decodedbody = getDecoded(request.data) val decodedbody = getDecoded(request.data)
Log.d("King", "decodedbody:$decodedbody")
val list = parseJson<Results>(decodedbody).results?.mapNotNull { element -> val list = parseJson<Results>(decodedbody).results?.mapNotNull { element ->
element.toSearchResponse(request) element.toSearchResponse(request)
} ?: throw ErrorLoadingException("Invalid Json reponse") } ?: throw ErrorLoadingException("Invalid Json response")
if (list.isNotEmpty()) items.add(HomePageList(request.name, list, true)) if (list.isNotEmpty()) items.add(HomePageList(request.name, list, true))
} }
return newHomePageResponse(items) 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? { private fun Channel.toSearchResponse(request: MainPageRequest, type: String? = null): SearchResponse? {
return LiveSearchResponse( return LiveSearchResponse(
name ?: return null, 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, this@YacienTV.name,
TvType.Live, TvType.Live,
logo, 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 { override suspend fun load(url: String): LoadResponse {
//Log.d("King", "Load:$url") Log.d("King", "Load:$url")
val data = parseJson<LinksData>(url) val data = parseJson<LinksData>(url)
if (data.category == "ARABIC CHANNELS"){
val decodedbody = getDecoded("$yacienTVAPI/categories/${data.id}/channels")
//Log.d("King", "Arabicdecodedbody:$decodedbody")
var channels = parseJson<Results>(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( return LiveStreamLoadResponse(
name = data.name, name = data.name,
url = Data(id = data.id, name = data.name, posterUrl = data.posterUrl, category = data.category).toJson(), url = Data(id = data.id, name = data.name, posterUrl = data.posterUrl, category = data.category).toJson(),
@ -122,17 +121,16 @@ class YacienTV : MainAPI() {
apiName = name, apiName = name,
posterUrl = data.posterUrl, posterUrl = data.posterUrl,
type = TvType.Live, 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( override suspend fun loadLinks(
data: String, data: String,
isCasting: Boolean, isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
): Boolean { ): Boolean {
//Log.d("King", "loadLinks:$data") Log.d("King", "loadLinks:$data")
val decodedbody = getDecoded("$yacienTVAPI/channel/$data") val decodedbody = getDecoded("$yacienTVAPI/channel/$data")
@ -167,5 +165,50 @@ class YacienTV : MainAPI() {
return decrypt(req.body.string(), req.headers["t"].toString()) 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<Team>? = arrayListOf(),
@JsonProperty("team_2") val team_2: ArrayList<Team>? = arrayListOf(),
)
data class EventsResults(
@JsonProperty("data") val results: ArrayList<Event>? = 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<Channel>? = arrayListOf(),
)
data class ChannelResults(
@JsonProperty("data") val links: ArrayList<Links>? = 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,
)
} }