mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
sff idk
This commit is contained in:
parent
68605fb563
commit
c5364ecd9a
14 changed files with 92 additions and 35 deletions
|
@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature
|
|||
import com.fasterxml.jackson.databind.json.JsonMapper
|
||||
import com.fasterxml.jackson.module.kotlin.KotlinModule
|
||||
import com.lagradost.cloudstream3.animeproviders.ShiroProvider
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
|
@ -51,7 +52,8 @@ abstract class MainAPI {
|
|||
return null
|
||||
}
|
||||
|
||||
open fun loadLinks(data: Any, id: Int): Boolean {
|
||||
// callback is fired once a link is found, will return true if method is executed successfully
|
||||
open fun loadLinks(data: Any, isCasting : Boolean, callback: (ExtractorLink) -> Unit): Boolean {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.lagradost.cloudstream3
|
||||
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import java.util.*
|
||||
import java.util.concurrent.ExecutorService
|
||||
import java.util.concurrent.Executors
|
||||
|
@ -26,3 +28,7 @@ fun <T, R> Iterable<T>.pmap(
|
|||
|
||||
return ArrayList<R>(destination)
|
||||
}
|
||||
|
||||
fun <A, B>List<A>.apmap(f: suspend (A) -> B): List<B> = runBlocking {
|
||||
map { async { f(it) } }.map { it.await() }
|
||||
}
|
|
@ -3,6 +3,8 @@ package com.lagradost.cloudstream3.animeproviders
|
|||
import com.fasterxml.jackson.annotation.JsonProperty
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.extractors.Vidstream
|
||||
import java.net.URLEncoder
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
@ -202,4 +204,13 @@ class ShiroProvider : MainAPI() {
|
|||
null,
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadLinks(data: Any, isCasting: Boolean, callback: (ExtractorLink) -> Unit): Boolean {
|
||||
if (data is ShiroEpisodes) {
|
||||
return Vidstream().getUrl(data._id, isCasting) {
|
||||
callback.invoke(it)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
|
@ -10,24 +10,24 @@ import android.widget.TextView
|
|||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lagradost.cloudstream3.*
|
||||
import com.lagradost.cloudstream3.APIHolder.getApiFromName
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import kotlinx.android.synthetic.main.result_episode.view.*
|
||||
|
||||
|
||||
class EpisodeAdapter(
|
||||
activity: Activity,
|
||||
animeList: ArrayList<ResultEpisode>,
|
||||
resView: RecyclerView,
|
||||
private var activity: Activity,
|
||||
var cardList: ArrayList<ResultEpisode>,
|
||||
val resView: RecyclerView,
|
||||
val clickCallback: (ResultEpisode) -> Unit
|
||||
) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
var cardList = animeList
|
||||
private var activity: Activity = activity
|
||||
var resView: RecyclerView? = resView
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
return CardViewHolder(
|
||||
LayoutInflater.from(parent.context).inflate(R.layout.result_episode, parent, false),
|
||||
activity,
|
||||
resView!!
|
||||
resView,
|
||||
clickCallback
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -44,13 +44,14 @@ class EpisodeAdapter(
|
|||
}
|
||||
|
||||
class CardViewHolder
|
||||
constructor(itemView: View, _activity: Activity, resView: RecyclerView) : RecyclerView.ViewHolder(itemView) {
|
||||
constructor(itemView: View, _activity: Activity, resView: RecyclerView, clickCallback: (ResultEpisode) -> Unit) : RecyclerView.ViewHolder(itemView) {
|
||||
val activity = _activity
|
||||
val episode_view_procentage: View = itemView.episode_view_procentage
|
||||
val episode_view_procentage_off: View = itemView.episode_view_procentage_off
|
||||
val episode_text: TextView = itemView.episode_text
|
||||
val episode_extra: ImageView = itemView.episode_extra
|
||||
val episode_play: ImageView = itemView.episode_play
|
||||
val clickCallback = clickCallback
|
||||
|
||||
fun bind(card: ResultEpisode) {
|
||||
episode_text.text = card.name ?: "Episode ${card.episode}"
|
||||
|
@ -67,7 +68,7 @@ class EpisodeAdapter(
|
|||
setWidth(episode_view_procentage_off, 1 - card.watchProgress)
|
||||
|
||||
episode_play.setOnClickListener {
|
||||
getApiFromName(card.apiName).loadLinks(card.data, card.id)
|
||||
clickCallback.invoke(card)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.load.model.GlideUrl
|
||||
import com.bumptech.glide.request.RequestOptions.bitmapTransform
|
||||
import com.lagradost.cloudstream3.APIHolder.getApiFromName
|
||||
import com.lagradost.cloudstream3.AnimeLoadResponse
|
||||
import com.lagradost.cloudstream3.LoadResponse
|
||||
import com.lagradost.cloudstream3.R
|
||||
|
@ -26,6 +27,8 @@ import com.lagradost.cloudstream3.UIHelper.fixPaddingStatusbar
|
|||
import com.lagradost.cloudstream3.UIHelper.getStatusBarHeight
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.mvvm.observe
|
||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import jp.wasabeef.glide.transformations.BlurTransformation
|
||||
import kotlinx.android.synthetic.main.fragment_result.*
|
||||
import kotlinx.android.synthetic.main.fragment_search.*
|
||||
|
@ -123,7 +126,9 @@ class ResultFragment : Fragment() {
|
|||
it,
|
||||
ArrayList(),
|
||||
result_episodes,
|
||||
)
|
||||
) {
|
||||
viewModel.loadEpisode(it)
|
||||
}
|
||||
}
|
||||
|
||||
result_episodes.adapter = adapter
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.lagradost.cloudstream3.APIHolder.getApiFromName
|
|||
import com.lagradost.cloudstream3.MainAPI
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.mvvm.safeApiCall
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class ResultViewModel : ViewModel() {
|
||||
|
@ -22,4 +23,20 @@ class ResultViewModel : ViewModel() {
|
|||
|
||||
_resultResponse.postValue(data)
|
||||
}
|
||||
|
||||
val allEpisodes : MutableLiveData<HashMap<Int,ArrayList<ExtractorLink>>> = MutableLiveData()
|
||||
private val _episodeResponse: MutableLiveData<Resource<Boolean>> = MutableLiveData()
|
||||
val episodeResponse: LiveData<Resource<Boolean>> get() = _episodeResponse
|
||||
|
||||
fun loadEpisode(episode: ResultEpisode) = viewModelScope.launch {
|
||||
if(allEpisodes.value?.contains(episode.id) == true) {
|
||||
allEpisodes.value?.remove(episode.id)
|
||||
}
|
||||
val data = safeApiCall {
|
||||
getApiFromName(episode.apiName).loadLinks(episode.data, false) { //TODO IMPLEMENT CASTING
|
||||
allEpisodes.value?.get(episode.id)?.add(it)
|
||||
}
|
||||
}
|
||||
_episodeResponse.postValue(data)
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import com.lagradost.cloudstream3.cloudstream3.extractors.StreamTape
|
|||
import com.lagradost.cloudstream3.utils.extractors.XStreamCdn
|
||||
|
||||
data class ExtractorLink(
|
||||
val source: String,
|
||||
val name: String,
|
||||
val url: String,
|
||||
val referer: String,
|
||||
|
@ -32,7 +33,7 @@ fun getAndUnpack(string: String): String? {
|
|||
return JsUnpacker(packedText).unpack()
|
||||
}
|
||||
|
||||
val APIS: Array<ExtractorApi> = arrayOf(
|
||||
val extractorApis: Array<ExtractorApi> = arrayOf(
|
||||
//AllProvider(),
|
||||
Shiro(),
|
||||
Mp4Upload(),
|
||||
|
@ -41,6 +42,17 @@ val APIS: Array<ExtractorApi> = arrayOf(
|
|||
XStreamCdn()
|
||||
)
|
||||
|
||||
fun getExtractorApiFromName(name: String): ExtractorApi {
|
||||
for (api in extractorApis) {
|
||||
if (api.name == name) return api
|
||||
}
|
||||
return extractorApis[0]
|
||||
}
|
||||
|
||||
fun requireReferer(name: String): Boolean {
|
||||
return getExtractorApiFromName(name).requiresReferer
|
||||
}
|
||||
|
||||
fun httpsify(url: String): String {
|
||||
return if (url.startsWith("//")) "https:$url" else url
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ class MixDrop : ExtractorApi() {
|
|||
srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link ->
|
||||
return listOf(
|
||||
ExtractorLink(
|
||||
name,
|
||||
name,
|
||||
httpsify(link),
|
||||
url,
|
||||
|
|
|
@ -15,6 +15,7 @@ class Mp4Upload : ExtractorApi() {
|
|||
srcRegex.find(unpackedText)?.groupValues?.get(1)?.let { link ->
|
||||
return listOf(
|
||||
ExtractorLink(
|
||||
name,
|
||||
name,
|
||||
link,
|
||||
url,
|
||||
|
|
|
@ -38,6 +38,7 @@ class MultiQuality : ExtractorApi() {
|
|||
m3u8Regex.findAll(this.text).forEach { match ->
|
||||
extractedLinksList.add(
|
||||
ExtractorLink(
|
||||
name,
|
||||
"$name ${match.groupValues[1]}p",
|
||||
urlRegex.find(this.url)!!.groupValues[1] + match.groupValues[0],
|
||||
url,
|
||||
|
@ -51,6 +52,7 @@ class MultiQuality : ExtractorApi() {
|
|||
} else if (extractedUrl.endsWith(".mp4")) {
|
||||
extractedLinksList.add(
|
||||
ExtractorLink(
|
||||
name,
|
||||
"$name ${sourceMatch.groupValues[2]}",
|
||||
extractedUrl,
|
||||
url.replace(" ", "%20"),
|
||||
|
|
|
@ -20,6 +20,7 @@ class Shiro : ExtractorApi() {
|
|||
Jsoup.parse(res).select("source").firstOrNull()?.attr("src")?.replace("&", "?")?.let {
|
||||
return listOf(
|
||||
ExtractorLink(
|
||||
name,
|
||||
name,
|
||||
it.replace(" ", "%20"),
|
||||
"https://cherry.subsplea.se/",
|
||||
|
|
|
@ -20,6 +20,7 @@ class StreamTape : ExtractorApi() {
|
|||
val extractedUrl = "https://streamtape.com/get_video?${it.groupValues[1]}".replace("""" + '""", "")
|
||||
return listOf(
|
||||
ExtractorLink(
|
||||
name,
|
||||
name,
|
||||
extractedUrl,
|
||||
url,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
package com.lagradost.cloudstream3.utils.extractors
|
||||
|
||||
import com.lagradost.cloudstream3.pmap
|
||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||
import com.lagradost.cloudstream3.utils.APIS
|
||||
import com.lagradost.cloudstream3.utils.extractors.MultiQuality
|
||||
import com.lagradost.cloudstream3.utils.extractors.Shiro
|
||||
import com.lagradost.cloudstream3.utils.extractorApis
|
||||
import org.jsoup.Jsoup
|
||||
|
||||
class Vidstream {
|
||||
|
@ -13,9 +12,10 @@ class Vidstream {
|
|||
private fun getExtractorUrl(id: String): String {
|
||||
return "$mainUrl/streaming.php?id=$id"
|
||||
}
|
||||
private val normalApis = arrayListOf(Shiro(), MultiQuality())
|
||||
|
||||
// https://gogo-stream.com/streaming.php?id=MTE3NDg5
|
||||
fun getUrl(id: String, isCasting: Boolean = false): List<ExtractorLink> {
|
||||
fun getUrl(id: String, isCasting: Boolean = false, callback: (ExtractorLink) -> Unit) : Boolean {
|
||||
try {
|
||||
val url = getExtractorUrl(id)
|
||||
with(khttp.get(url)) {
|
||||
|
@ -23,15 +23,11 @@ class Vidstream {
|
|||
val primaryLinks = document.select("ul.list-server-items > li.linkserver")
|
||||
val extractedLinksList: MutableList<ExtractorLink> = mutableListOf()
|
||||
|
||||
// --- Shiro ---
|
||||
val shiroUrl = Shiro().getExtractorUrl(id)
|
||||
val shiroSource = Shiro().getUrl(shiroUrl)
|
||||
shiroSource?.forEach { extractedLinksList.add(it) }
|
||||
// --- MultiQuality ---
|
||||
val multiQualityUrl = MultiQuality().getExtractorUrl(id)
|
||||
val multiQualitySource = MultiQuality().getUrl(multiQualityUrl)
|
||||
multiQualitySource?.forEach { extractedLinksList.add(it) }
|
||||
// --------------------
|
||||
normalApis.pmap { api ->
|
||||
val url = api.getExtractorUrl(id)
|
||||
val source = api.getUrl(url)
|
||||
source?.forEach { callback.invoke(it) }
|
||||
}
|
||||
|
||||
// All vidstream links passed to extractors
|
||||
primaryLinks.forEach { element ->
|
||||
|
@ -39,21 +35,21 @@ class Vidstream {
|
|||
//val name = element.text()
|
||||
|
||||
// Matches vidstream links with extractors
|
||||
APIS.filter { !it.requiresReferer || !isCasting}.forEach { api ->
|
||||
extractorApis.filter { !it.requiresReferer || !isCasting}.pmap { api ->
|
||||
if (link.startsWith(api.mainUrl)) {
|
||||
val extractedLinks = api.getUrl(link, url)
|
||||
if (extractedLinks?.isNotEmpty() == true) {
|
||||
extractedLinks.forEach {
|
||||
extractedLinksList.add(it)
|
||||
callback.invoke(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return extractedLinksList
|
||||
return true
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
return listOf()
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,6 +51,7 @@ class XStreamCdn : ExtractorApi() {
|
|||
it.data.forEach { data ->
|
||||
extractedLinksList.add(
|
||||
ExtractorLink(
|
||||
name,
|
||||
"$name ${data.label}",
|
||||
data.file,
|
||||
url,
|
||||
|
|
Loading…
Reference in a new issue