AquaStream/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMProvider.kt

116 lines
4.2 KiB
Kotlin
Raw Normal View History

2021-06-24 00:29:20 +00:00
package com.lagradost.cloudstream3.movieproviders
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import org.jsoup.Jsoup
2021-06-24 17:45:59 +00:00
class HDMProvider : MainAPI() {
2022-03-16 15:29:11 +00:00
override var name = "HD Movies"
override var mainUrl = "https://hdm.to"
override val hasMainPage = true
2021-06-24 00:29:20 +00:00
override val supportedTypes = setOf(
TvType.Movie,
)
2021-08-14 17:31:27 +00:00
2022-01-16 22:31:42 +00:00
override suspend fun search(query: String): List<SearchResponse> {
2021-06-24 00:29:20 +00:00
val url = "$mainUrl/search/$query"
val response = app.get(url).text
val document = Jsoup.parse(response)
2021-06-24 00:29:20 +00:00
val items = document.select("div.col-md-2 > article > a")
2022-03-03 11:26:26 +00:00
if (items.isEmpty()) return emptyList()
return items.map { i ->
2021-06-24 00:29:20 +00:00
val href = i.attr("href")
val data = i.selectFirst("> div.item")!!
val img = data.selectFirst("> img")!!.attr("src")
val name = data.selectFirst("> div.movie-details")!!.text()
2022-03-03 11:26:26 +00:00
MovieSearchResponse(name, href, this.name, TvType.Movie, img, null)
2021-06-24 00:29:20 +00:00
}
}
2022-01-16 22:31:42 +00:00
override suspend fun loadLinks(
2021-07-01 20:11:33 +00:00
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
2021-06-24 00:29:20 +00:00
if (data == "") return false
2022-02-27 01:03:01 +00:00
val slug = Regex(".*/(.*?)\\.mp4").find(data)?.groupValues?.get(1) ?: return false
val response = app.get(data).text
2022-02-27 01:03:01 +00:00
val key = Regex("playlist\\.m3u8(.*?)\"").find(response)?.groupValues?.get(1) ?: return false
2021-07-01 20:11:33 +00:00
callback.invoke(
ExtractorLink(
this.name,
this.name,
"https://hls.1o.to/vod/$slug/playlist.m3u8$key",
"",
2021-08-24 21:06:40 +00:00
Qualities.P720.value,
2021-07-01 20:11:33 +00:00
true
)
)
2021-06-24 00:29:20 +00:00
return true
}
2022-01-16 22:31:42 +00:00
override suspend fun load(url: String): LoadResponse? {
val response = app.get(url).text
val document = Jsoup.parse(response)
2021-08-09 14:40:20 +00:00
val title = document.selectFirst("h2.movieTitle")?.text() ?: throw ErrorLoadingException("No Data Found")
val poster = document.selectFirst("div.post-thumbnail > img")!!.attr("src")
val descript = document.selectFirst("div.synopsis > p")!!.text()
val year = document.select("div.movieInfoAll > div.row > div.col-md-6").getOrNull(1)?.selectFirst("> p > a")?.text()
2021-06-24 00:29:20 +00:00
?.toIntOrNull()
val data = "src/player/\\?v=(.*?)\"".toRegex().find(response)?.groupValues?.get(1) ?: return null
2021-06-24 00:29:20 +00:00
2021-07-01 20:11:33 +00:00
return MovieLoadResponse(
2021-07-30 14:09:57 +00:00
title, url, this.name, TvType.Movie,
"$mainUrl/src/player/?v=$data", poster, year, descript, null
2021-07-01 20:11:33 +00:00
)
2021-06-24 00:29:20 +00:00
}
2021-11-27 13:54:43 +00:00
2022-01-16 22:31:42 +00:00
override suspend fun getMainPage(): HomePageResponse {
2022-03-03 11:26:26 +00:00
val html = app.get(mainUrl, timeout = 25).text
2021-11-27 13:54:43 +00:00
val document = Jsoup.parse(html)
val all = ArrayList<HomePageList>()
val mainbody = document.getElementsByTag("body")
?.select("div.homeContentOuter > section > div.container > div")
// Fetch row title
val inner = mainbody?.select("div.col-md-2.col-sm-2.mrgb")
val title = mainbody?.select("div > div")?.firstOrNull()?.select("div.title.titleBar")?.text() ?: "Unnamed Row"
// Fetch list of items and map
if (inner != null) {
val elements: List<SearchResponse> = inner.map {
val aa = it.select("a").firstOrNull()
val item = aa?.select("div.item")
val href = aa?.attr("href")
val link = when (href != null) {
true -> fixUrl(href)
false -> ""
}
val name = item?.select("div.movie-details")?.text() ?: "<No Title>"
var image = item?.select("img")?.get(1)?.attr("src") ?: ""
val year = null
MovieSearchResponse(
name,
link,
this.name,
TvType.Movie,
image,
year,
null,
)
}
all.add(
HomePageList(
title, elements
)
)
}
return HomePageResponse(all)
}
2021-06-24 00:29:20 +00:00
}