From f49d9de09be37e26633a8449e637a2525e8c8c48 Mon Sep 17 00:00:00 2001 From: Blatzar <46196380+Blatzar@users.noreply.github.com> Date: Sun, 16 Oct 2022 19:42:32 +0200 Subject: [PATCH] Added CineGrabber Extractor --- .../cloudstream3/extractors/GuardareStream.kt | 81 +++++++++++++++---- .../cloudstream3/utils/ExtractorApi.kt | 1 + 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt b/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt index 57435161..f25cb5ba 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt @@ -1,36 +1,83 @@ package com.lagradost.cloudstream3.extractors + import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* +class CineGrabber : GuardareStream() { + override var name = "CineGrabber" + override var mainUrl = "https://cinegrabber.com" +} + open class GuardareStream : ExtractorApi() { override var name = "Guardare" override var mainUrl = "https://guardare.stream" override val requiresReferer = false - data class GuardareJsonData ( - @JsonProperty("data") val data : List, + data class GuardareJsonData( + @JsonProperty("data") val data: List, + @JsonProperty("captions") val captions: List?, ) - data class GuardareData ( - @JsonProperty("file") val file : String, - @JsonProperty("label") val label : String, - @JsonProperty("type") val type : String + data class GuardareData( + @JsonProperty("file") val file: String, + @JsonProperty("label") val label: String, + @JsonProperty("type") val type: String ) - override suspend fun getUrl(url: String, referer: String?): List? { - val response = app.post(url.replace("/v/","/api/source/"), data = mapOf("d" to mainUrl)).text - val jsonvideodata = AppUtils.parseJson(response) - return jsonvideodata.data.map { - ExtractorLink( - it.file+".${it.type}", - this.name, - it.file+".${it.type}", - mainUrl, - it.label.filter{ it.isDigit() }.toInt(), - false + + // https://cinegrabber.com/asset/userdata/224879/caption/gqdmzh-71ez76z8/876438.srt + data class GuardareCaptions( + @JsonProperty("id") val id: String, + @JsonProperty("hash") val hash: String, + @JsonProperty("language") val language: String?, + @JsonProperty("extension") val extension: String + ) { + fun getUrl(mainUrl: String, userId: String): String { + return "$mainUrl/asset/userdata/$userId/caption/$hash/$id.$extension" + } + } + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val response = + app.post(url.replace("/v/", "/api/source/"), data = mapOf("d" to mainUrl)).text + + val jsonVideoData = AppUtils.parseJson(response) + jsonVideoData.data.forEach { + callback.invoke( + ExtractorLink( + it.file + ".${it.type}", + this.name, + it.file + ".${it.type}", + mainUrl, + it.label.filter { it.isDigit() }.toInt(), + false + ) ) } + + if (!jsonVideoData.captions.isNullOrEmpty()){ + val iframe = app.get(url) + // var USER_ID = '224879'; + val userIdRegex = Regex("""USER_ID.*?(\d+)""") + val userId = userIdRegex.find(iframe.text)?.groupValues?.getOrNull(1) ?: return + jsonVideoData.captions.forEach { + if (it == null) return@forEach + val subUrl = it.getUrl(mainUrl, userId) + subtitleCallback.invoke( + SubtitleFile( + it.language ?: "", + subUrl + ) + ) + } + } } } \ 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 ebaaa12b..8d6b1b82 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt @@ -283,6 +283,7 @@ val extractorApis: MutableList = arrayListOf( Userload(), Supervideo(), GuardareStream(), + CineGrabber(), // StreamSB.kt works // SBPlay(),