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

123 lines
4.4 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.network.text
2021-06-24 00:29:20 +00:00
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() {
2021-06-24 00:29:20 +00:00
override val name: String
get() = "HD Movies"
override val mainUrl: String
get() = "https://hdm.to"
2021-08-14 17:31:27 +00:00
override val supportedTypes: Set<TvType>
get() = setOf(
TvType.Movie,
)
2021-11-27 13:54:43 +00:00
override val hasMainPage: Boolean
get() = true
2021-08-14 17:31:27 +00:00
2021-08-19 20:05:18 +00:00
override 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")
if (items.isEmpty()) return ArrayList()
val returnValue = ArrayList<SearchResponse>()
for (i in items) {
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()
2021-07-30 14:09:57 +00:00
returnValue.add(MovieSearchResponse(name, href, this.name, TvType.Movie, img, null))
2021-06-24 00:29:20 +00:00
}
return returnValue
}
2021-07-01 20:11:33 +00:00
override fun loadLinks(
data: String,
isCasting: Boolean,
subtitleCallback: (SubtitleFile) -> Unit,
callback: (ExtractorLink) -> Unit
): Boolean {
2021-06-24 00:29:20 +00:00
if (data == "") return false
val slug = ".*/(.*?)\\.mp4".toRegex().find(data)?.groupValues?.get(1) ?: return false
val response = app.get(data).text
val key = "playlist\\.m3u8(.*?)\"".toRegex().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
}
2021-07-30 14:09:57 +00:00
override 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")
2021-06-24 00:29:20 +00:00
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")?.get(1)?.selectFirst("> p > a")?.text()
?.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,
2021-07-02 18:46:18 +00:00
"$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
override fun getMainPage(): HomePageResponse {
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
}