From 7060843ebc4ecec466db29b1eb6a83f483ce31ec Mon Sep 17 00:00:00 2001 From: LagradOst Date: Thu, 24 Jun 2021 02:29:20 +0200 Subject: [PATCH] HDM Provider --- .../com/lagradost/cloudstream3/AllProvider.kt | 8 +-- .../com/lagradost/cloudstream3/MainAPI.kt | 8 ++- .../animeproviders/DubbedAnimeProvider.kt | 11 ++-- .../animeproviders/ShiroProvider.kt | 10 ++-- .../movieproviders/HDMMoveProvider.kt | 59 +++++++++++++++++++ .../movieproviders/MeloMovieProvider.kt | 8 +-- 6 files changed, 82 insertions(+), 22 deletions(-) create mode 100644 app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMMoveProvider.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/AllProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/AllProvider.kt index f1a5a64e..69904319 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/AllProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/AllProvider.kt @@ -10,7 +10,7 @@ class AllProvider : MainAPI() { var providersActive = HashSet() - override fun quickSearch(query: String): ArrayList? { + override fun quickSearch(query: String): ArrayList? { val list = apis.filter { a -> a.name != this.name && (providersActive.size == 0 || providersActive.contains(a.name)) }.filter { a -> a.hasQuickSearch }.pmap { a -> @@ -34,7 +34,7 @@ class AllProvider : MainAPI() { if (providerCount == 0) return null if (maxCount == 0) return ArrayList() - val result = ArrayList() + val result = ArrayList() for (i in 0..maxCount) { for (res in list) { if (res != null) { @@ -48,7 +48,7 @@ class AllProvider : MainAPI() { return result } - override fun search(query: String): ArrayList? { + override fun search(query: String): ArrayList? { val list = apis.filter { a -> a.name != this.name && (providersActive.size == 0 || providersActive.contains(a.name)) }.pmap { a -> @@ -71,7 +71,7 @@ class AllProvider : MainAPI() { if (providerCount == 0) return null if (maxCount == 0) return ArrayList() - val result = ArrayList() + val result = ArrayList() for (i in 0..maxCount) { for (res in list) { if (res != null) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index c8092449..cb30f6da 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.KotlinModule import com.lagradost.cloudstream3.animeproviders.DubbedAnimeProvider import com.lagradost.cloudstream3.animeproviders.ShiroProvider +import com.lagradost.cloudstream3.movieproviders.HDMMoveProvider import com.lagradost.cloudstream3.movieproviders.MeloMovieProvider import com.lagradost.cloudstream3.utils.ExtractorLink import java.util.* @@ -29,6 +30,7 @@ object APIHolder { ShiroProvider(), MeloMovieProvider(), DubbedAnimeProvider(), + HDMMoveProvider(), ) fun getApiFromName(apiName: String?): MainAPI { @@ -53,15 +55,15 @@ abstract class MainAPI { open val mainUrl = "NONE" open val instantLinkLoading = false // THIS IS IF THE LINK IS STORED IN THE "DATA" open val hasQuickSearch = false - open fun search(query: String): ArrayList? { // SearchResponse + open fun search(query: String): ArrayList? { // SearchResponse return null } - open fun quickSearch(query: String) : ArrayList? { + open fun quickSearch(query: String) : ArrayList? { return null } - open fun load(slug: String): Any? { //LoadResponse + open fun load(slug: String): LoadResponse? { return null } diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt index 1ad0dad6..570892bb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/DubbedAnimeProvider.kt @@ -10,7 +10,6 @@ import org.jsoup.Jsoup import java.util.* import kotlin.collections.ArrayList - class DubbedAnimeProvider : MainAPI() { override val mainUrl: String get() = "https://bestdubbedanime.com" @@ -70,13 +69,13 @@ class DubbedAnimeProvider : MainAPI() { return href.replace("$mainUrl/", "") } - override fun quickSearch(query: String): ArrayList { + override fun quickSearch(query: String): ArrayList { val url = "$mainUrl/xz/searchgrid.php?p=1&limit=12&s=$query&_=${unixTime}" val response = khttp.get(url) val document = Jsoup.parse(response.text) val items = document.select("div.grid__item > a") if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() + val returnValue = ArrayList() for (i in items) { val href = fixUrl(i.attr("href")) val title = i.selectFirst("div.gridtitlek").text() @@ -103,13 +102,13 @@ class DubbedAnimeProvider : MainAPI() { return returnValue } - override fun search(query: String): ArrayList { + override fun search(query: String): ArrayList { val url = "$mainUrl/search/$query" val response = khttp.get(url) val document = Jsoup.parse(response.text) val items = document.select("div.resultinner > a.resulta") if (items.isEmpty()) return ArrayList() - val returnValue = ArrayList() + val returnValue = ArrayList() for (i in items) { val innerDiv = i.selectFirst("> div.result") val href = fixUrl(i.attr("href")) @@ -168,7 +167,7 @@ class DubbedAnimeProvider : MainAPI() { return true } - override fun load(slug: String): Any { + override fun load(slug: String): LoadResponse { if (getIsMovie(slug)) { val realSlug = slug.replace("movies/", "") val episode = getAnimeEpisode(realSlug, true) diff --git a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ShiroProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ShiroProvider.kt index 4d5b56ff..c7a9a79f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ShiroProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/animeproviders/ShiroProvider.kt @@ -164,8 +164,8 @@ class ShiroProvider : MainAPI() { ) } - override fun quickSearch(query: String): ArrayList { - val returnValue: ArrayList = ArrayList() + override fun quickSearch(query: String): ArrayList { + val returnValue: ArrayList = ArrayList() val response = khttp.get("https://tapi.shiro.is/anime/auto-complete/${ URLEncoder.encode( @@ -184,9 +184,9 @@ class ShiroProvider : MainAPI() { return returnValue } - override fun search(query: String): ArrayList? { + override fun search(query: String): ArrayList? { if (!autoLoadToken()) return null - val returnValue: ArrayList = ArrayList() + val returnValue: ArrayList = ArrayList() val response = khttp.get("https://tapi.shiro.is/advanced?search=${ URLEncoder.encode( query, @@ -202,7 +202,7 @@ class ShiroProvider : MainAPI() { return returnValue } - override fun load(slug: String): Any? { + override fun load(slug: String): LoadResponse? { if (!autoLoadToken()) return null val rurl = "https://tapi.shiro.is/anime/slug/${slug}?token=${token}" val response = khttp.get(rurl, timeout = 120.0) diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMMoveProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMMoveProvider.kt new file mode 100644 index 00000000..63c1a3e4 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMMoveProvider.kt @@ -0,0 +1,59 @@ +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 + +class HDMMoveProvider : MainAPI() { + override val name: String + get() = "HD Movies" + override val mainUrl: String + get() = "https://hdm.to" + + override fun search(query: String): ArrayList { + val url = "$mainUrl/search/$query" + val response = khttp.get(url) + val document = Jsoup.parse(response.text) + val items = document.select("div.col-md-2 > article > a") + if (items.isEmpty()) return ArrayList() + val returnValue = ArrayList() + 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() + returnValue.add(MovieSearchResponse(name, href, href, this.name, TvType.Movie, img, null)) + } + + return returnValue + } + + override fun loadLinks(data: String, isCasting: Boolean, callback: (ExtractorLink) -> Unit): Boolean { + if (data == "") return false + val slug = ".*/(.*?)\\.mp4".toRegex().find(data)?.groupValues?.get(1) ?: return false + val response = khttp.get(data) + val key = "playlist\\.m3u8(.*?)\"".toRegex().find(response.text)?.groupValues?.get(1) ?: return false + callback.invoke(ExtractorLink(this.name, + this.name, + "https://hls.1o.to/vod/$slug/playlist.m3u8$key", + "", + Qualities.HD.value, + true)) + return true + } + + override fun load(slug: String): LoadResponse? { + val response = khttp.get(slug) + val document = Jsoup.parse(response.text) + val title = document.selectFirst("h2.movieTitle").text() + 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.text)?.groupValues?.get(1) ?: return null + + return MovieLoadResponse(title, slug, this.name, TvType.Movie, + "$mainUrl/src/player/?v=$data", poster, year, descript, null) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MeloMovieProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MeloMovieProvider.kt index 64791b44..9be28748 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MeloMovieProvider.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/MeloMovieProvider.kt @@ -29,13 +29,13 @@ class MeloMovieProvider : MainAPI() { data class MeloMovieLink(val name: String, val link: String) - override fun quickSearch(query: String): ArrayList? { + override fun quickSearch(query: String): ArrayList { return search(query) } - override fun search(query: String): ArrayList? { + override fun search(query: String): ArrayList { val url = "$mainUrl/movie/search/?name=$query" - val returnValue: ArrayList = ArrayList() + val returnValue: ArrayList = ArrayList() val response = khttp.get(url) val mapped = response.let { mapper.readValue>(it.text) } if (mapped.isEmpty()) return returnValue @@ -101,7 +101,7 @@ class MeloMovieProvider : MainAPI() { return true } - override fun load(slug: String): Any? { + override fun load(slug: String): LoadResponse? { val response = khttp.get(slug).text //backdrop = imgurl