mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed trailers.to hopefully
This commit is contained in:
parent
94150cb7c6
commit
59efb8816c
2 changed files with 18 additions and 8 deletions
|
@ -42,13 +42,13 @@ object APIHolder {
|
||||||
WatchCartoonOnlineProvider(),
|
WatchCartoonOnlineProvider(),
|
||||||
AllMoviesForYouProvider(),
|
AllMoviesForYouProvider(),
|
||||||
AsiaFlixProvider(),
|
AsiaFlixProvider(),
|
||||||
ThenosProvider(),
|
TrailersToProvider(), // be aware that this is fuckery
|
||||||
VidEmbedProvider()
|
VidEmbedProvider()
|
||||||
)
|
)
|
||||||
|
|
||||||
val restrictedApis = arrayListOf(
|
val restrictedApis = arrayListOf(
|
||||||
//NyaaProvider(), //torrents in cs3 is wack
|
//NyaaProvider(), //torrents in cs3 is wack
|
||||||
TrailersToProvider(),
|
ThenosProvider(),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun getApiFromName(apiName: String?): MainAPI {
|
fun getApiFromName(apiName: String?): MainAPI {
|
||||||
|
|
|
@ -200,9 +200,10 @@ class TrailersToProvider : MainAPI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun load(url: String): LoadResponse {
|
override fun load(url: String): LoadResponse {
|
||||||
val response = get(url).text
|
val response = get(if (url.endsWith("?preview=1")) url else "$url?preview=1").text
|
||||||
val document = Jsoup.parse(response)
|
val document = Jsoup.parse(response)
|
||||||
var title = document?.selectFirst("h2.breadcrumbs-custom-title > a")?.text() ?: throw ErrorLoadingException("Service might be unavailable")
|
var title = document?.selectFirst("h2.breadcrumbs-custom-title > a")?.text()
|
||||||
|
?: throw ErrorLoadingException("Service might be unavailable")
|
||||||
|
|
||||||
val metaInfo = document.select("div.post-info-meta > ul.post-info-meta-list > li")
|
val metaInfo = document.select("div.post-info-meta > ul.post-info-meta-list > li")
|
||||||
val year = metaInfo?.get(0)?.selectFirst("> span.small-text")?.text()?.takeLast(4)?.toIntOrNull()
|
val year = metaInfo?.get(0)?.selectFirst("> span.small-text")?.text()?.takeLast(4)?.toIntOrNull()
|
||||||
|
@ -228,20 +229,23 @@ class TrailersToProvider : MainAPI() {
|
||||||
|
|
||||||
val isTvShow = url.contains("/tvshow/")
|
val isTvShow = url.contains("/tvshow/")
|
||||||
if (isTvShow) {
|
if (isTvShow) {
|
||||||
val episodes = document.select("#seasons-accordion .card-body > .tour-modern") ?: throw ErrorLoadingException("No Episodes found")
|
val episodes = document.select("#seasons-accordion .card-body > .tour-modern")
|
||||||
|
?: throw ErrorLoadingException("No Episodes found")
|
||||||
val parsedEpisodes = episodes.withIndex().map { (index, item) ->
|
val parsedEpisodes = episodes.withIndex().map { (index, item) ->
|
||||||
val epPoster = item.selectFirst("img").attr("src")
|
val epPoster = item.selectFirst("img").attr("src")
|
||||||
val main = item.selectFirst(".tour-modern-main")
|
val main = item.selectFirst(".tour-modern-main")
|
||||||
val titleHeader = main.selectFirst("a")
|
val titleHeader = main.selectFirst("a")
|
||||||
val titleName = titleHeader.text()
|
val titleName = titleHeader.text()
|
||||||
val href = fixUrl(titleHeader.attr("href"))
|
val href = fixUrl(titleHeader.attr("href"))
|
||||||
val gValues = Regex(""".*?[\w\s]+ ([0-9]+)(?::[\w\s]+)?\s-\s(?:Episode )?([0-9]+)?(?:: )?(.*)""").find(titleName)?.destructured
|
val gValues =
|
||||||
|
Regex(""".*?[\w\s]+ ([0-9]+)(?::[\w\s]+)?\s-\s(?:Episode )?([0-9]+)?(?:: )?(.*)""").find(titleName)?.destructured
|
||||||
val season = gValues?.component1()?.toIntOrNull()
|
val season = gValues?.component1()?.toIntOrNull()
|
||||||
var episode = gValues?.component2()?.toIntOrNull()
|
var episode = gValues?.component2()?.toIntOrNull()
|
||||||
if (episode == null) {
|
if (episode == null) {
|
||||||
episode = index + 1
|
episode = index + 1
|
||||||
}
|
}
|
||||||
val epName = if (gValues?.component3()?.isNotEmpty() == true) gValues.component3() else "Episode $episode"
|
val epName =
|
||||||
|
if (gValues?.component3()?.isNotEmpty() == true) gValues.component3() else "Episode $episode"
|
||||||
val infoHeaders = main.select("span.small-text")
|
val infoHeaders = main.select("span.small-text")
|
||||||
val date = infoHeaders?.get(0)?.text()
|
val date = infoHeaders?.get(0)?.text()
|
||||||
val ratingText = infoHeaders?.get(1)?.text()?.replace("/ 10", "")
|
val ratingText = infoHeaders?.get(1)?.text()?.replace("/ 10", "")
|
||||||
|
@ -286,7 +290,13 @@ class TrailersToProvider : MainAPI() {
|
||||||
} else ""
|
} else ""
|
||||||
|
|
||||||
val data = mapper.writeValueAsString(
|
val data = mapper.writeValueAsString(
|
||||||
Pair(subUrl, fixUrl(document?.selectFirst("content")?.attr("data-url") ?: throw ErrorLoadingException("Link not found")))
|
Pair(
|
||||||
|
subUrl,
|
||||||
|
fixUrl(
|
||||||
|
document?.selectFirst("content")?.attr("data-url")
|
||||||
|
?: throw ErrorLoadingException("Link not found")
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return MovieLoadResponse(
|
return MovieLoadResponse(
|
||||||
title,
|
title,
|
||||||
|
|
Loading…
Reference in a new issue