Skip to content

Commit

Permalink
Added playback to StreamingCommunity
Browse files Browse the repository at this point in the history
  • Loading branch information
doGior committed Oct 1, 2024
1 parent 86234a7 commit 1f31eb2
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Repository for Cloudstream 3 providing streams from websites I like (mostly ital
| **Plugin** | **Website** | **Content** | **Language** | **Functioning** |
|--------------------|-------------------------------------|------------------|:------------:|:---------------:|
| Streamed | https://streamed.su | Live Sports | 🇮🇹 🇬🇧 ||
| StreamingCommunity | https://streamingcommunity.computer | Movies, TV Shows | 🇮🇹 | |
| StreamingCommunity | https://streamingcommunity.computer | Movies, TV Shows | 🇮🇹 | |

## Install
Click on the pizza to install
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package it.dogior.doesStream

import android.util.Log
import com.lagradost.cloudstream3.APIHolder.capitalize
import com.lagradost.cloudstream3.SubtitleFile
import com.lagradost.cloudstream3.app
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.ExtractorApi
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.Qualities
import okhttp3.HttpUrl.Companion.toHttpUrl

class StreamedExtractor : ExtractorApi() {
class StreamingCommunityExtractor : ExtractorApi() {
override val mainUrl = StreamingCommunity.mainUrl
override val name = StreamingCommunity.name
override val requiresReferer = false
Expand All @@ -23,34 +23,65 @@ class StreamedExtractor : ExtractorApi() {
val TAG = "StreaminCommunityExtractor:getUrl"
Log.d(TAG,"REFERER: $referer URL: $url")

// if (url.isNotEmpty()) {
// try {
// val rawSource = app.get(url).body.string()
//// Log.d(TAG, rawSource)
// val source = parseJson<List<StreamingCommunity.Source>>(rawSource)
// val serverDomain = "https://rr.vipstreams.in"
// if (source.isNotEmpty()) {
// source.forEach{ s ->
// val isHdString = if(s.isHD) "HD" else "SD"
// val contentUrl = "$serverDomain/${s.source}/js/${s.id}/${s.streamNumber}/playlist.m3u8"
//// Log.d(TAG, "Content URL: $contentUrl")
// callback.invoke(
// ExtractorLink(
// source = s.source!!,
// name = "${s.source.capitalize()} $isHdString \t ${s.language}",
// url = contentUrl,
// referer = referer!!,
// isM3u8 = true,
// quality = Qualities.Unknown.value
// )
// )
// }
// }
// } catch (e: Exception) {
// Log.d(TAG, "Error: ${e.message}")
// }
// }
if (url.isNotEmpty()) {
val playlistUrl = getPlaylistLink(url)
callback.invoke(
ExtractorLink(
source = "Vixcloud",
name = "Streaming Community ITA",
url = playlistUrl,
referer = referer!!,
isM3u8 = true,
quality = Qualities.Unknown.value
)
)
}

}

suspend fun getPlaylistLink(data: String): String {
val TAG = "StreaminCommunityExtractor:getPlaylistLink"
val iframeUrl = app.get(data).document
.select("iframe").attr("src")
Log.w(TAG, "IFRAME URL: $iframeUrl")
val headers = mapOf(
"Accept" to "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
"Host" to iframeUrl.toHttpUrl().host,
"Referer" to "$mainUrl/"
)

val iframe = app.get(iframeUrl, headers = headers).document
val script =
iframe.selectFirst("script:containsData(masterPlaylist)")!!.data().replace("\\", "")
.replace("\n", "").replace("\t", "")
// val windowVideo = script.substringAfter("= ").substringBefore(";")
val windowStreams = script.substringAfter("window.streams = ")
.substringBefore("; window.masterPlaylist = ")
val windowMasterPlaylist = script.substringAfter("window.masterPlaylist = ")
.substringBefore(" window.canPlayFHD")
// val windowCanPlayFHD = script.substringAfter("window.canPlayFHD = ")
Log.d(TAG, "SCRIPT: $script")
// Log.d(TAG, "windowVideo: $windowVideo")
// Log.d(TAG, "windowStreams: $windowStreams")
Log.d(TAG, "windowMasterPlaylist: $windowMasterPlaylist")
// Log.d(TAG, "windowCanPlayFHD: $windowCanPlayFHD")

val servers = parseJson<List<Server>>(windowStreams)
Log.d(TAG, "Server List: $servers")

// Hopefully different streams will have the same format errors
val mP = windowMasterPlaylist
.replace("params", "'params'")
.replace("url", "'url'")
.replace("'", "\"")
.replace(" ", "")
.replace(",}", "}")

val masterPlaylist = parseJson<MasterPlaylist>(mP)
Log.d(TAG, "MasterPlaylist Obj: $masterPlaylist")

val masterPlaylistUrl = "${masterPlaylist.url}&token=${masterPlaylist.params.token}&expires=${masterPlaylist.params.expires}&b=1"
return masterPlaylistUrl
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.lagradost.cloudstream3.mainPageOf
import com.lagradost.cloudstream3.newHomePageResponse
import com.lagradost.cloudstream3.utils.AppUtils.parseJson
import com.lagradost.cloudstream3.utils.ExtractorLink
import okhttp3.HttpUrl.Companion.toHttpUrl


class StreamingCommunity : MainAPI() {
Expand Down Expand Up @@ -183,7 +184,7 @@ class StreamingCommunity : MainAPI() {
val genres = title.genres.map { it.name.capitalize() }
val domain = mainUrl.substringAfter("://")
val tags = listOf("IMDB: ${title.score}") + genres
val actors = title.mainActors.map{ac -> ActorData(actor = Actor(ac.name))}
val actors = title.mainActors.map { ac -> ActorData(actor = Actor(ac.name)) }
if (title.type == "tv") {
val episodes: List<Episode> = getEpisodes(props)
Log.d(TAG, "Episode List: $episodes")
Expand All @@ -205,7 +206,7 @@ class StreamingCommunity : MainAPI() {
val movie = MovieLoadResponse(
name = title.name,
url = url,
dataUrl = "$mainUrl/watch/${title.id}",
dataUrl = "$mainUrl/iframe/${title.id}",
type = TvType.Movie,
apiName = this.name,
plot = title.plot,
Expand All @@ -225,24 +226,24 @@ class StreamingCommunity : MainAPI() {
val episodeList = mutableListOf<Episode>()
val title = props.title

title?.seasons?.forEach{ season ->
title?.seasons?.forEach { season ->
val responseEpisodes = emptyList<it.dogior.doesStream.Episode>().toMutableList()
if(season.id == props.loadedSeason!!.id) {
if (season.id == props.loadedSeason!!.id) {
responseEpisodes.addAll(props.loadedSeason.episodes!!)
} else{
} else {
if (this.inertiaVersion == "") {
setInertiaVersion()
}
val url = "$mainUrl/titles/${title.id}-${title.slug}/stagione-${season.number}"
val obj = parseJson<InertiaResponse>(app.get(url, headers = this.headers).body.string())
val obj =
parseJson<InertiaResponse>(app.get(url, headers = this.headers).body.string())
Log.d(TAG, "Parsed Response: $obj")
responseEpisodes.addAll(obj.props.loadedSeason?.episodes!!)

}
responseEpisodes.forEach{ ep ->
responseEpisodes.forEach { ep ->
episodeList.add(
Episode(
data = "$mainUrl/watch/${season.id}?e=${ep.id}",
data = "$mainUrl/iframe/${title.id}?episode_id=${ep.id}",
name = ep.name,
posterUrl = props.cdnUrl + "/images/" + ep.getCover(),
description = ep.plot,
Expand All @@ -265,8 +266,14 @@ class StreamingCommunity : MainAPI() {
): Boolean {
val TAG = "STREAMINGCOMMUNITY:Links"

Log.d(TAG, "Url : $data")


return true
StreamingCommunityExtractor().getUrl(
url = data,
referer = mainUrl,
subtitleCallback = subtitleCallback,
callback = callback
)
return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ data class TitleProp(
@JsonProperty("release_date") val releaseDate: String,
@JsonProperty("age") val age: Int,
@JsonProperty("seasons_count") val seasonsCount: Int,
@JsonProperty("scws_id") val scwsId: Int?,
@JsonProperty("seasons") val seasons: List<Season>,
@JsonProperty("images") val images: List<PosterImage>,
@JsonProperty("genres") val genres: List<Genre>,
Expand All @@ -146,4 +147,20 @@ data class TitleProp(
}
return null
}
}
}

data class Server(
@JsonProperty("name") val name: String,
@JsonProperty("active") val active: Boolean,
@JsonProperty("url") val url: String
)

data class MasterPlaylist(
@JsonProperty("params") val params: Params,
@JsonProperty("url") val url: String
)

data class Params(
@JsonProperty("token") val token: String,
@JsonProperty("expires") val expires: String
)

0 comments on commit 1f31eb2

Please sign in to comment.