From 36700b90f703167ce60946de29a7d124adadb78d Mon Sep 17 00:00:00 2001 From: Stormunblessed <86633626+Stormunblessed@users.noreply.github.com> Date: Sun, 13 Mar 2022 00:44:02 -0600 Subject: [PATCH] ApiMDB and extractor (#783) --- .../com/lagradost/cloudstream3/MainAPI.kt | 1 + .../cloudstream3/extractors/PlayerVoxzer.kt | 38 ++++++++++++ .../movieproviders/ApiMDBProvider.kt | 60 +++++++++++++++++++ .../cloudstream3/utils/ExtractorApi.kt | 1 + 4 files changed, 100 insertions(+) create mode 100644 app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt create mode 100644 app/src/main/java/com/lagradost/cloudstream3/movieproviders/ApiMDBProvider.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt index 9a69b95a..b5174fbf 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt @@ -57,6 +57,7 @@ object APIHolder { VMoveeProvider(), WatchCartoonOnlineProvider(), AllMoviesForYouProvider(), + ApiMDBProvider(), MonoschinosProvider(), diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt new file mode 100644 index 00000000..782ad578 --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt @@ -0,0 +1,38 @@ +package com.lagradost.cloudstream3.extractors + +import com.lagradost.cloudstream3.apmap +import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.app + + +open class PlayerVoxzer : ExtractorApi() { + override val name = "Voxzer" + override val mainUrl = "https://player.voxzer.org" + override val requiresReferer = false + + override suspend fun getUrl(url: String, referer: String?): List? { + val listurl = url.replace("/view/","/list/") + val urltext = app.get(listurl, referer = url).text + val m3u8regex = Regex("((https:|http:)\\/\\/.*\\.m3u8)") + val sources = mutableListOf() + val listm3 = m3u8regex.find(urltext)?.value + if (listm3?.contains("m3u8") == true) M3u8Helper().m3u8Generation( + M3u8Helper.M3u8Stream( + listm3, + headers = app.get(url).headers.toMap() + ), true + ) + .map { stream -> + val qualityString = if ((stream.quality ?: 0) == 0) "" else "${stream.quality}p" + sources.add( ExtractorLink( + name, + "$name $qualityString", + stream.streamUrl, + url, + getQualityFromName(stream.quality.toString()), + true + )) + } + return sources + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ApiMDBProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ApiMDBProvider.kt new file mode 100644 index 00000000..44d407de --- /dev/null +++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/ApiMDBProvider.kt @@ -0,0 +1,60 @@ +package com.lagradost.cloudstream3.movieproviders + +import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.extractors.Vidstream +import com.lagradost.cloudstream3.metaproviders.TmdbLink +import com.lagradost.cloudstream3.metaproviders.TmdbProvider +import com.lagradost.cloudstream3.utils.AppUtils.parseJson +import com.lagradost.cloudstream3.utils.ExtractorLink +import com.lagradost.cloudstream3.utils.loadExtractor + +class ApiMDBProvider : TmdbProvider() { + override val apiName = "ApiMDB" + override val name = "ApiMDB" + override val mainUrl = "https://v2.apimdb.net" + override val useMetaLoadResponse = true + override val instantLinkLoading = false + override val supportedTypes = setOf( + TvType.Movie, + TvType.TvSeries, + ) + + override suspend fun loadLinks( + data: String, + isCasting: Boolean, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ): Boolean { + val mappedData = parseJson(data) + val (id, site) = if (mappedData.imdbID != null) listOf( + mappedData.imdbID, + "imdb" + ) else listOf(mappedData.tmdbID.toString(), "tmdb") + val isMovie = mappedData.episode == null && mappedData.season == null + val embedUrl = if (isMovie) { + if(site == "imdb") "$mainUrl/e/movie/$id" else + "$mainUrl/e/tmdb/movie/$id" + } else { + val suffix = "$id/${mappedData.season ?: 1}/${mappedData.episode ?: 1}" + if (site == "imdb") "$mainUrl/e/tv/$suffix" else + "$mainUrl/e/tmdb/tv/$suffix" + } + val document = app.get(embedUrl, referer = mainUrl).document + val servers = document.select(".servers-list div.server").map { it.attr("data-src") } + servers.apmap { serverID -> + val serverdoc = app.get("$mainUrl$serverID", referer = embedUrl).document + serverdoc.select("html body iframe").map { + val link = it.attr("src") + .replace("https://vidembed.cc/load.php","https://vidembed.io/streaming.php") + .replace(Regex("(https://cloudemb\\.com/play/.*\\?auto=1&referer=)"),"") + if (link.contains("vidembed", ignoreCase = true)) { + val vidstreamid = link.substringAfter("https://vidembed.io/streaming.php?id=") + val vidstreamObject = Vidstream("https://vidembed.io") + vidstreamObject.getUrl(vidstreamid, isCasting, callback) + } else + loadExtractor(link, embedUrl, callback) + } + } + return true + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt index 70e248ce..5d313c49 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt @@ -150,6 +150,7 @@ val extractorApis: Array = arrayOf( // SBPlay1(), // SBPlay2(), + PlayerVoxzer(), ) fun getExtractorApiFromName(name: String): ExtractorApi {