fixed Hdfilmcehennemi sub & fixed Xcinetop home

This commit is contained in:
hexated 2022-10-09 22:12:43 +07:00
parent 07438e1621
commit cf25b6fd64
4 changed files with 68 additions and 24 deletions

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 3 version = 4
cloudstream { cloudstream {

View file

@ -6,6 +6,7 @@ import com.lagradost.cloudstream3.LoadResponse.Companion.addActors
import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer
import com.lagradost.cloudstream3.mvvm.safeApiCall import com.lagradost.cloudstream3.mvvm.safeApiCall
import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.*
import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson
import org.jsoup.nodes.Element import org.jsoup.nodes.Element
class Hdfilmcehennemi : MainAPI() { class Hdfilmcehennemi : MainAPI() {
@ -20,6 +21,10 @@ class Hdfilmcehennemi : MainAPI() {
TvType.TvSeries, TvType.TvSeries,
) )
companion object {
private const val vidmolyServer = "https://vidmoly.to"
}
override val mainPage = mainPageOf( override val mainPage = mainPageOf(
"$mainUrl/category/tavsiye-filmler-izle1/page/" to "Tavsiye Filmler Kategorisi", "$mainUrl/category/tavsiye-filmler-izle1/page/" to "Tavsiye Filmler Kategorisi",
"$mainUrl/yabancidiziizle/page/" to "Son Eklenen Yabancı Diziler", "$mainUrl/yabancidiziizle/page/" to "Son Eklenen Yabancı Diziler",
@ -152,36 +157,65 @@ class Hdfilmcehennemi : MainAPI() {
} }
} }
private fun fixSubUrl(url: String): String {
if (url.startsWith("http") ||
// Do not fix JSON objects when passed as urls.
url.startsWith("{\"")
) {
return url
}
if (url.isEmpty()) {
return ""
}
val startsWithNoHttp = url.startsWith("//")
if (startsWithNoHttp) {
return "https:$url"
} else {
if (url.startsWith('/')) {
return vidmolyServer + url
}
return "$vidmolyServer/$url"
}
}
private fun String.addMarks(str: String): String {
return this.replace(Regex("\"?$str\"?"), "\"$str\"")
}
private suspend fun invokeLocalSource( private suspend fun invokeLocalSource(
source: String, source: String,
url: String, url: String,
subtitleCallback: (SubtitleFile) -> Unit, subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit callback: (ExtractorLink) -> Unit
) { ) {
val res = app.get(url, referer = "$mainUrl/") val script = app.get(
val m3uLink = res.document.select("script") url,
.find { referer = "${mainUrl}/"
it.data().contains("var sources = [];") || it.data() ).document.select("script")
.contains("playerInstance =") .find { it.data().contains("sources:") }?.data()
}?.data() val videoData = script?.substringAfter("sources: [")
?.substringAfter("[{file:\"")?.substringBefore("\"}]") ?: return ?.substringBefore("],")?.addMarks("file")
val subData = script?.substringAfter("tracks: [")?.substringBefore("]")?.addMarks("file")
?.addMarks("label")?.addMarks("kind")
M3u8Helper.generateM3u8( tryParseJson<Source>(videoData)?.file?.let { m3uLink ->
source, M3u8Helper.generateM3u8(
m3uLink, source,
if (url.startsWith(mainUrl)) "$mainUrl/" else "https://vidmoly.to/" m3uLink,
).forEach(callback) if (url.startsWith(mainUrl)) "$mainUrl/" else "$vidmolyServer/"
).forEach(callback)
}
Regex("\"(/srt\\S*?)\",\\slabel:\\s\"(\\S*?)\"").findAll(res.text) tryParseJson<List<SubSource>>("[${subData}]")
.map { it.groupValues[1] to it.groupValues[2] }.toList().map { (url, lang) -> ?.filter { it.kind == "captions" }?.map {
subtitleCallback.invoke( subtitleCallback.invoke(
SubtitleFile( SubtitleFile(
lang, it.label.toString(),
fixUrl(url) fixSubUrl(it.file.toString())
) )
) )
} }
} }
override suspend fun loadLinks( override suspend fun loadLinks(
@ -196,13 +230,23 @@ class Hdfilmcehennemi : MainAPI() {
safeApiCall { safeApiCall {
app.get(url).document.select("div.card-video > iframe").attr("data-src") app.get(url).document.select("div.card-video > iframe").attr("data-src")
.let { link -> .let { link ->
invokeLocalSource(source, link,subtitleCallback, callback) invokeLocalSource(source, link, subtitleCallback, callback)
} }
} }
} }
return true return true
} }
private data class Source(
@JsonProperty("file") val file: String? = null,
)
private data class SubSource(
@JsonProperty("file") val file: String? = null,
@JsonProperty("label") val label: String? = null,
@JsonProperty("kind") val kind: String? = null,
)
data class Result( data class Result(
@JsonProperty("result") val result: ArrayList<Media>? = arrayListOf(), @JsonProperty("result") val result: ArrayList<Media>? = arrayListOf(),
) )

View file

@ -1,5 +1,5 @@
// use an integer for version numbers // use an integer for version numbers
version = 1 version = 2
cloudstream { cloudstream {

View file

@ -30,7 +30,7 @@ class Xcinetop : MainAPI() {
) )
override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse { override suspend fun getMainPage(page: Int, request: MainPageRequest): HomePageResponse {
val document = app.get(request.data + page).document val document = app.get("${request.data}$page/").document
val home = document.select("div#dle-content div.movie-item").mapNotNull { val home = document.select("div#dle-content div.movie-item").mapNotNull {
it.toSearchResult() it.toSearchResult()
} }
@ -48,7 +48,7 @@ class Xcinetop : MainAPI() {
return newAnimeSearchResponse(title, href, TvType.TvSeries) { return newAnimeSearchResponse(title, href, TvType.TvSeries) {
addQuality(quantity) addQuality(quantity)
addDub(episode) addDub(episode)
addPoster(posterUrl, headers = mapOf("Referer" to "$mainUrl/")) this.posterUrl = posterUrl
} }
} }
@ -94,7 +94,7 @@ class Xcinetop : MainAPI() {
fixUrl(it.attr("data-link")) fixUrl(it.attr("data-link"))
} }
return newMovieLoadResponse(title, url, TvType.Movie, Links(link).toJson()) { return newMovieLoadResponse(title, url, TvType.Movie, Links(link).toJson()) {
addPoster(poster, headers = mapOf("Referer" to "$mainUrl/")) this.posterUrl = poster
this.year = year this.year = year
plot = description plot = description
this.tags = tags this.tags = tags
@ -115,7 +115,7 @@ class Xcinetop : MainAPI() {
) )
} }
return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes = episodes) { return newTvSeriesLoadResponse(title, url, TvType.TvSeries, episodes = episodes) {
addPoster(poster, headers = mapOf("Referer" to "$mainUrl/")) this.posterUrl = poster
this.year = year this.year = year
plot = description plot = description
this.tags = tags this.tags = tags