sora: fixed ask4movies

This commit is contained in:
hexated 2023-07-24 21:25:57 +07:00
parent 22b5f99e48
commit c1d59c7f8e
13 changed files with 316 additions and 49 deletions

27
Nimegami/build.gradle.kts Normal file
View file

@ -0,0 +1,27 @@
// use an integer for version numbers
version = 1
cloudstream {
language = "id"
// All of these properties are optional, you can safely remove them
// description = "Lorem Ipsum"
authors = listOf("Hexated")
/**
* Status int as the following:
* 0: Down
* 1: Ok
* 2: Slow
* 3: Beta only
* */
status = 1 // will be 3 if unspecified
tvTypes = listOf(
"AnimeMovie",
"Anime",
"OVA",
)
iconUrl = "https://www.google.com/s2/favicons?domain=nimegami.id&sz=%size%"
}

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.hexated"/>

View file

@ -0,0 +1,60 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
open class Mitedrive : ExtractorApi() {
override val name = "Mitedrive"
override val mainUrl = "https://mitedrive.com"
override val requiresReferer = false
override suspend fun getUrl(
url: String,
referer: String?,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
val id = url.substringAfterLast("/")
val video = app.post(
"$mainUrl/api/generate",
referer = "$mainUrl/",
data = mapOf(
"short_url" to id
)
).parsedSafe<Responses>()?.data?.url
val headers = mapOf(
"Accept" to "*/*",
"Connection" to "keep-alive",
"Sec-Fetch-Dest" to "empty",
"Sec-Fetch-Mode" to "cors",
"Sec-Fetch-Site" to "cross-site",
"Origin" to mainUrl,
)
callback.invoke(
ExtractorLink(
this.name,
this.name,
video ?: return,
"$mainUrl/",
Qualities.Unknown.value,
headers = headers
)
)
}
data class Data(
@JsonProperty("url") val url: String? = null,
)
data class Responses(
@JsonProperty("data") val data: Data? = null,
)
}

View file

@ -0,0 +1,197 @@
package com.hexated
import com.fasterxml.jackson.annotation.JsonProperty
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import org.jsoup.nodes.Element
import org.jsoup.select.Elements
import java.net.URI
class Nimegami : MainAPI() {
override var mainUrl = "https://nimegami.id"
override var name = "Nimegami"
override val hasMainPage = true
override var lang = "id"
override val supportedTypes = setOf(
TvType.Anime,
TvType.AnimeMovie,
TvType.OVA
)
companion object {
fun getType(t: String): TvType {
return if (t.contains("OVA", true) || t.contains("Special", true)) TvType.OVA
else if (t.contains("Movie", true)) TvType.AnimeMovie
else TvType.Anime
}
fun getStatus(t: String?): ShowStatus {
return when {
t?.contains("On-Going", true) == true -> ShowStatus.Ongoing
else -> ShowStatus.Completed
}
}
}
override val mainPage = mainPageOf(
"" to "Updated Anime",
"/type/tv" to "Anime",
"/type/movie" to "Movie",
"/type/ona" to "ONA",
"/type/live-action" to "Live Action",
)
override suspend fun getMainPage(
page: Int,
request: MainPageRequest
): HomePageResponse {
val document = app.get("$mainUrl${request.data}/page/$page").document
val home = document.select("div.post-article article, div.archive article").mapNotNull {
it.toSearchResult()
}
return newHomePageResponse(
list = HomePageList(
name = request.name,
list = home,
isHorizontalImages = request.name != "Updated Anime"
),
hasNext = true
)
}
private fun Element.toSearchResult(): AnimeSearchResponse? {
val href = fixUrl(this.selectFirst("a")!!.attr("href"))
val title = this.selectFirst("h2 a")?.text() ?: return null
val posterUrl = (this.selectFirst("noscript img") ?: this.selectFirst("img"))?.attr("src")
val episode = this.selectFirst("ul li:contains(Episode), div.eps-archive")?.ownText()
?.filter { it.isDigit() }?.toIntOrNull()
return newAnimeSearchResponse(title, href, TvType.Anime) {
this.posterUrl = posterUrl
addSub(episode)
}
}
override suspend fun search(query: String): List<SearchResponse> {
return app.get("$mainUrl/?s=$query&post_type=post").document.select("div.archive article")
.mapNotNull {
it.toSearchResult()
}
}
override suspend fun load(url: String): LoadResponse {
val document = app.get(url).document
val table = document.select("div#Info table tbody")
val title = table.getContent("Judul :").text()
val poster = document.selectFirst("div.coverthumbnail img")?.attr("src")
val bgPoster = document.selectFirst("div.thumbnail-a img")?.attr("src")
val tags = table.getContent("Kategori").select("a").map { it.text() }
val year = table.getContent("Musim / Rilis").text().filter { it.isDigit() }.toIntOrNull()
val status = getStatus(document.selectFirst("h1[itemprop=headline]")?.text())
val type = table.getContent("Type").text()
val description = document.select("div#Sinopsis p").text().trim()
val episodes = document.select("div.list_eps_stream li")
.mapNotNull {
val name = it.text()
val link = it.attr("data")
Episode(link, name)
}
val recommendations = document.select("div#randomList > a").mapNotNull {
val epHref = it.attr("href")
val epTitle = it.select("h5.sidebar-title-h5.px-2.py-2").text()
val epPoster = it.select(".product__sidebar__view__item.set-bg").attr("data-setbg")
newAnimeSearchResponse(epTitle, epHref, TvType.Anime) {
this.posterUrl = epPoster
addDubStatus(dubExist = false, subExist = true)
}
}
return newAnimeLoadResponse(title, url, getType(type)) {
engName = title
posterUrl = poster
backgroundPosterUrl = bgPoster
this.year = year
addEpisodes(DubStatus.Subbed, episodes)
showStatus = status
plot = description
this.tags = tags
this.recommendations = recommendations
}
}
override suspend fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
tryParseJson<ArrayList<Sources>>(base64Decode(data))?.map { sources ->
sources.url?.apmap { url ->
loadFixedExtractor(url.fixIframe(), sources.format, "$mainUrl/", subtitleCallback, callback)
}
}
return true
}
private suspend fun loadFixedExtractor(
url: String,
quality: String?,
referer: String? = null,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
) {
loadExtractor(url, referer, subtitleCallback) { link ->
callback.invoke(
ExtractorLink(
link.name,
link.name,
link.url,
link.referer,
getQualityFromName(quality),
link.isM3u8,
link.headers,
link.extractorData
)
)
}
}
private fun getBaseUrl(url: String): String {
return URI(url).let {
"${it.scheme}://${it.host}"
}
}
private fun Elements.getContent(css: String) : Elements {
return this.select("tr:contains($css) td:last-child")
}
private fun String.fixIframe() : String {
val url = base64Decode(this.substringAfter("url=").substringAfter("id="))
val host = getBaseUrl(url)
return when {
url.contains("hxfile") -> {
val id = url.substringAfterLast("/")
"$host/embed-$id.html"
}
else -> fixUrl(url)
}
}
data class Sources(
@JsonProperty("format") val format: String? = null,
@JsonProperty("url") val url: ArrayList<String>? = arrayListOf(),
)
}

View file

@ -0,0 +1,15 @@
package com.hexated
import com.lagradost.cloudstream3.plugins.CloudstreamPlugin
import com.lagradost.cloudstream3.plugins.Plugin
import android.content.Context
@CloudstreamPlugin
class NimegamiPlugin: Plugin() {
override fun load(context: Context) {
// All providers should be added in this manner. Please don't edit the providers list directly.
registerMainAPI(Nimegami())
registerExtractorAPI(Mitedrive())
}
}