mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
code cleanup
This commit is contained in:
parent
a2cb9946f1
commit
fa1e2f7eeb
3 changed files with 27 additions and 30 deletions
|
@ -1,6 +1,5 @@
|
||||||
package com.lagradost.cloudstream3
|
package com.lagradost.cloudstream3
|
||||||
|
|
||||||
import ThenosProvider
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature
|
import com.fasterxml.jackson.databind.DeserializationFeature
|
||||||
|
@ -11,7 +10,6 @@ import com.lagradost.cloudstream3.movieproviders.*
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
|
||||||
const val USER_AGENT =
|
const val USER_AGENT =
|
||||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"
|
||||||
//val baseHeader = mapOf("User-Agent" to USER_AGENT)
|
//val baseHeader = mapOf("User-Agent" to USER_AGENT)
|
||||||
|
|
|
@ -24,8 +24,6 @@ import com.google.android.gms.cast.framework.CastButtonFactory
|
||||||
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
|
||||||
import com.lagradost.cloudstream3.APIHolder.apis
|
import com.lagradost.cloudstream3.APIHolder.apis
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiSettings
|
|
||||||
import com.lagradost.cloudstream3.APIHolder.getApiTypeSettings
|
|
||||||
import com.lagradost.cloudstream3.APIHolder.restrictedApis
|
import com.lagradost.cloudstream3.APIHolder.restrictedApis
|
||||||
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
|
import com.lagradost.cloudstream3.receivers.VideoDownloadRestartReceiver
|
||||||
import com.lagradost.cloudstream3.ui.APIRepository
|
import com.lagradost.cloudstream3.ui.APIRepository
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
|
package com.lagradost.cloudstream3.movieproviders
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.fasterxml.jackson.module.kotlin.readValue
|
import com.fasterxml.jackson.module.kotlin.readValue
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.utils.ExtractorLink
|
import com.lagradost.cloudstream3.utils.ExtractorLink
|
||||||
import com.lagradost.cloudstream3.utils.getQualityFromName
|
import com.lagradost.cloudstream3.utils.getQualityFromName
|
||||||
import org.jsoup.Jsoup
|
|
||||||
import org.jsoup.nodes.Element
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
|
|
||||||
class ThenosProvider : MainAPI() {
|
class ThenosProvider : MainAPI() {
|
||||||
|
@ -31,7 +31,7 @@ class ThenosProvider : MainAPI() {
|
||||||
override val vpnStatus: VPNStatus
|
override val vpnStatus: VPNStatus
|
||||||
get() = VPNStatus.None
|
get() = VPNStatus.None
|
||||||
|
|
||||||
override fun getMainPage(): HomePageResponse? {
|
override fun getMainPage(): HomePageResponse {
|
||||||
val map = mapOf(
|
val map = mapOf(
|
||||||
"New Releases" to "released",
|
"New Releases" to "released",
|
||||||
"Recently Added in Movies" to "recent",
|
"Recently Added in Movies" to "recent",
|
||||||
|
@ -44,8 +44,8 @@ class ThenosProvider : MainAPI() {
|
||||||
val response = khttp.get(url)
|
val response = khttp.get(url)
|
||||||
val mapped = mapper.readValue<ThenosLoadResponse>(response.text)
|
val mapped = mapper.readValue<ThenosLoadResponse>(response.text)
|
||||||
|
|
||||||
mapped.Metadata?.mapNotNull {
|
mapped.Metadata?.mapNotNull { meta ->
|
||||||
it?.toSearchResponse()
|
meta?.toSearchResponse()
|
||||||
}?.let { searchResponses ->
|
}?.let { searchResponses ->
|
||||||
list.add(
|
list.add(
|
||||||
HomePageList(
|
HomePageList(
|
||||||
|
@ -61,7 +61,7 @@ class ThenosProvider : MainAPI() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun secondsToReadable(seconds: Int, completedValue: String): String {
|
private fun secondsToReadable(seconds: Int, completedValue: String): String {
|
||||||
var secondsLong = seconds.toLong()
|
var secondsLong = seconds.toLong()
|
||||||
val days = TimeUnit.SECONDS
|
val days = TimeUnit.SECONDS
|
||||||
.toDays(secondsLong)
|
.toDays(secondsLong)
|
||||||
|
@ -214,9 +214,9 @@ class ThenosProvider : MainAPI() {
|
||||||
val returnValue = ArrayList<SearchResponse>()
|
val returnValue = ArrayList<SearchResponse>()
|
||||||
|
|
||||||
test.Hub?.forEach {
|
test.Hub?.forEach {
|
||||||
it.Metadata?.forEach metadata@{
|
it.Metadata?.forEach metadata@{ meta ->
|
||||||
if (it.ratingKey == null || it.title == null) return@metadata
|
if (meta.ratingKey == null || meta.title == null) return@metadata
|
||||||
it.toSearchResponse()?.let { response -> returnValue.add(response) }
|
meta.toSearchResponse()?.let { response -> returnValue.add(response) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,24 +254,25 @@ class ThenosProvider : MainAPI() {
|
||||||
subtitleCallback: (SubtitleFile) -> Unit,
|
subtitleCallback: (SubtitleFile) -> Unit,
|
||||||
callback: (ExtractorLink) -> Unit
|
callback: (ExtractorLink) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val url = "https://api.thenos.org/library/watch/$data"
|
val url = "$apiUrl/library/watch/$data"
|
||||||
val response = khttp.get(url)
|
val response = khttp.get(url)
|
||||||
val mapped = mapper.readValue<ThenosSource>(response.text)
|
val mapped = mapper.readValue<ThenosSource>(response.text)
|
||||||
|
|
||||||
mapped.sources?.forEach {
|
mapped.sources?.forEach { source ->
|
||||||
val isM3u8 = it.type != "video/mp4"
|
val isM3u8 = source.type != "video/mp4"
|
||||||
val token = khttp.get("https://token.noss.workers.dev/").text
|
val token = khttp.get("https://token.noss.workers.dev/").text
|
||||||
val authorization =
|
val authorization =
|
||||||
String(android.util.Base64.decode(token, android.util.Base64.DEFAULT), Charsets.ISO_8859_1)
|
String(android.util.Base64.decode(token, android.util.Base64.DEFAULT), Charsets.ISO_8859_1)
|
||||||
|
|
||||||
callback.invoke(
|
callback.invoke(
|
||||||
ExtractorLink(
|
ExtractorLink(
|
||||||
this.name,
|
this.name,
|
||||||
"${this.name} ${it.label ?: ""}",
|
"${this.name} ${source.label ?: ""}",
|
||||||
(it.file)?.split("/")?.lastOrNull()?.let {
|
(source.file)?.split("/")?.lastOrNull()?.let {
|
||||||
"https://www.googleapis.com/drive/v3/files/$it?alt=media"
|
"https://www.googleapis.com/drive/v3/files/$it?alt=media"
|
||||||
} ?: return@forEach,
|
} ?: return@forEach,
|
||||||
"https://www.thenos.org/",
|
"https://www.thenos.org/",
|
||||||
getQualityFromName(it.label ?: ""),
|
getQualityFromName(source.label ?: ""),
|
||||||
isM3u8,
|
isM3u8,
|
||||||
mapOf("authorization" to "Bearer $authorization")
|
mapOf("authorization" to "Bearer $authorization")
|
||||||
)
|
)
|
||||||
|
@ -424,21 +425,21 @@ class ThenosProvider : MainAPI() {
|
||||||
val url = "$apiUrl/library/metadata/$id/children"
|
val url = "$apiUrl/library/metadata/$id/children"
|
||||||
val response = khttp.get(url)
|
val response = khttp.get(url)
|
||||||
val mapped = mapper.readValue<ThenosSeriesResponse>(response.text)
|
val mapped = mapper.readValue<ThenosSeriesResponse>(response.text)
|
||||||
mapped.Metadata?.forEach {
|
mapped.Metadata?.forEach { series_meta ->
|
||||||
val fixedUrl = "https://api.thenos.org" + it.key
|
val fixedUrl = apiUrl + series_meta.key
|
||||||
val child = khttp.get(fixedUrl)
|
val child = khttp.get(fixedUrl)
|
||||||
val mappedSeason = mapper.readValue<SeasonResponse>(child.text)
|
val mappedSeason = mapper.readValue<SeasonResponse>(child.text)
|
||||||
mappedSeason.Metadata?.forEach mappedSeason@{
|
mappedSeason.Metadata?.forEach mappedSeason@{ meta ->
|
||||||
episodes.add(
|
episodes.add(
|
||||||
TvSeriesEpisode(
|
TvSeriesEpisode(
|
||||||
it.title,
|
meta.title,
|
||||||
it.parentIndex,
|
meta.parentIndex,
|
||||||
it.index,
|
meta.index,
|
||||||
it.ratingKey ?: return@mappedSeason,
|
meta.ratingKey ?: return@mappedSeason,
|
||||||
it.thumb?.let { "$apiUrl$it" },
|
meta.thumb?.let { "$apiUrl$it" },
|
||||||
it.originallyAvailableAt,
|
meta.originallyAvailableAt,
|
||||||
(it.audienceRating?.times(10))?.toInt(),
|
(meta.audienceRating?.times(10))?.toInt(),
|
||||||
it.summary
|
meta.summary
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue