From ada48f2a98aa159e07c3c3bfe2c211f9b82e5011 Mon Sep 17 00:00:00 2001
From: LagradOst <11805592+LagradOst@users.noreply.github.com>
Date: Fri, 3 Jun 2022 00:51:41 +0200
Subject: [PATCH] fixed json from github issue
---
.idea/gradle.xml | 1 -
.../com/lagradost/cloudstream3/MainAPI.kt | 39 +++++++++++--------
.../lagradost/cloudstream3/MainActivity.kt | 25 ++++++------
.../movieproviders/CineblogProvider.kt | 6 +--
.../cloudstream3/movieproviders/HDMovie5.kt | 10 +++--
.../cloudstream3/ui/home/HomeFragment.kt | 2 +-
.../cloudstream3/ui/result/ResultFragment.kt | 6 +--
.../cloudstream3/ui/search/SearchHelper.kt | 1 -
8 files changed, 50 insertions(+), 40 deletions(-)
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 673f5504..10c26704 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -15,7 +15,6 @@
-
diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt
index 760c3c0a..c3b0a963 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt
@@ -76,7 +76,7 @@ object APIHolder {
TwoEmbedProvider(),
DramaSeeProvider(),
WatchAsianProvider(),
- DramaidProvider(),
+ DramaidProvider(),
KdramaHoodProvider(),
AkwamProvider(),
MyCimaProvider(),
@@ -116,20 +116,27 @@ object APIHolder {
DubbedAnimeProvider(),
MonoschinosProvider(),
KawaiifuProvider(), // disabled due to cloudflare
- NeonimeProvider(),
+ NeonimeProvider(),
KuramanimeProvider(),
OploverzProvider(),
GomunimeProvider(),
NontonAnimeIDProvider(),
KuronimeProvider(),
//MultiAnimeProvider(),
- NginxProvider(),
+ NginxProvider(),
OlgplyProvider(),
)
}
+ fun initAll() {
+ for (api in allProviders) {
+ api.init()
+ }
+ APIHolder.apiMap = null
+ }
+
var apis: List = arrayListOf()
- private var apiMap: Map? = null
+ var apiMap: Map? = null
private fun initMap() {
if (apiMap == null)
@@ -143,7 +150,6 @@ object APIHolder {
fun getApiFromNameNull(apiName: String?): MainAPI? {
if (apiName == null) return null
initMap()
-
return apiMap?.get(apiName)?.let { apis.getOrNull(it) }
}
@@ -156,12 +162,12 @@ object APIHolder {
return null
}
- fun getLoadResponseIdFromUrl(url : String, apiName: String) : Int {
+ fun getLoadResponseIdFromUrl(url: String, apiName: String): Int {
return url.replace(getApiFromName(apiName).mainUrl, "").replace("/", "").hashCode()
}
fun LoadResponse.getId(): Int {
- return getLoadResponseIdFromUrl(url,apiName)
+ return getLoadResponseIdFromUrl(url, apiName)
}
/**
@@ -338,18 +344,19 @@ abstract class MainAPI {
var overrideData: HashMap? = null
}
- fun overrideWithNewData(data: ProvidersInfoJson) {
- this.name = data.name
- this.mainUrl = data.url
- this.storedCredentials = data.credentials
- }
-
- init {
+ fun init() {
overrideData?.get(this.javaClass.simpleName)?.let { data ->
overrideWithNewData(data)
}
}
+ fun overrideWithNewData(data: ProvidersInfoJson) {
+ this.name = data.name
+ this.name
+ this.mainUrl = data.url
+ this.storedCredentials = data.credentials
+ }
+
open var name = "NONE"
open var mainUrl = "NONE"
open var storedCredentials: String? = null
@@ -765,12 +772,12 @@ fun AnimeSearchResponse.addDubStatus(isDub: Boolean, episodes: Int? = null) {
}
fun AnimeSearchResponse.addDub(episodes: Int?) {
- if(episodes == null || episodes <= 0) return
+ if (episodes == null || episodes <= 0) return
addDubStatus(DubStatus.Dubbed, episodes)
}
fun AnimeSearchResponse.addSub(episodes: Int?) {
- if(episodes == null || episodes <= 0) return
+ if (episodes == null || episodes <= 0) return
addDubStatus(DubStatus.Subbed, episodes)
}
diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
index 431740d2..f5e5d781 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt
@@ -27,6 +27,7 @@ import com.jaredrummler.android.colorpicker.ColorPickerDialogListener
import com.lagradost.cloudstream3.APIHolder.allProviders
import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings
+import com.lagradost.cloudstream3.APIHolder.initAll
import com.lagradost.cloudstream3.CommonActivity.backEvent
import com.lagradost.cloudstream3.CommonActivity.loadThemes
import com.lagradost.cloudstream3.CommonActivity.onColorSelectedEvent
@@ -390,7 +391,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
false
}
- fun addNginxToJson(data: java.util.HashMap): java.util.HashMap? {
+ fun addNginxToJson(data: java.util.HashMap): java.util.HashMap {
try {
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
val nginxUrl =
@@ -402,18 +403,18 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
"nginx_credentials"
)
.toString()
- val StoredNginxProvider = NginxProvider()
+ val storedNginxProvider = NginxProvider()
if (nginxUrl == "nginx_url_key" || nginxUrl == "") { // if key is default value, or empty:
- data[StoredNginxProvider.javaClass.simpleName] = ProvidersInfoJson(
+ data[storedNginxProvider.javaClass.simpleName] = ProvidersInfoJson(
url = nginxUrl,
- name = StoredNginxProvider.name,
+ name = storedNginxProvider.name,
status = PROVIDER_STATUS_DOWN, // the provider will not be display
credentials = nginxCredentials
)
} else { // valid url
- data[StoredNginxProvider.javaClass.simpleName] = ProvidersInfoJson(
+ data[storedNginxProvider.javaClass.simpleName] = ProvidersInfoJson(
url = nginxUrl,
- name = StoredNginxProvider.name,
+ name = storedNginxProvider.name,
status = PROVIDER_STATUS_OK,
credentials = nginxCredentials
)
@@ -472,8 +473,8 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
MainAPI.overrideData = newCache // update all new providers
val newUpdatedCache =
- newCache?.let { addNginxToJson(it) ?: it }
-
+ newCache?.let { addNginxToJson(it) }
+ initAll()
for (api in apis) { // update current providers
newUpdatedCache?.get(api.javaClass.simpleName)
?.let { data ->
@@ -493,8 +494,9 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
newCache
}?.let { providersJsonMap ->
MainAPI.overrideData = providersJsonMap
- val providersJsonMapUpdated = addNginxToJson(providersJsonMap)
- ?: providersJsonMap // if return null, use unchanged one
+ val providersJsonMapUpdated =
+ addNginxToJson(providersJsonMap) // if return null, use unchanged one
+ initAll()
val acceptableProviders =
providersJsonMapUpdated.filter { it.value.status == PROVIDER_STATUS_OK || it.value.status == PROVIDER_STATUS_SLOW }
.map { it.key }.toSet()
@@ -517,11 +519,13 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
}
}
} catch (e: Exception) {
+ initAll()
apis = allProviders
e.printStackTrace()
logError(e)
}
} else {
+ initAll()
apis = allProviders
try {
val nginxProviderName = NginxProvider().name
@@ -533,7 +537,6 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
} catch (e: Exception) {
logError(e)
}
-
}
loadThemes(this)
diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt
index d3dc62e3..675da5b6 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/CineblogProvider.kt
@@ -2,13 +2,13 @@ package com.lagradost.cloudstream3.movieproviders
import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.mvvm.logError
-import com.lagradost.cloudstream3.app
-import com.lagradost.cloudstream3.utils.*
+import com.lagradost.cloudstream3.utils.ExtractorLink
+import com.lagradost.cloudstream3.utils.loadExtractor
class CineblogProvider : MainAPI() {
override val lang = "it"
override var mainUrl = "https://cb01.rip"
- override var name = "CineBlog01"
+ override var name = "CineBlog"
override val hasMainPage = true
override val hasChromecastSupport = true
override val supportedTypes = setOf(
diff --git a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt
index 9001f2c2..d20ed4b5 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/movieproviders/HDMovie5.kt
@@ -5,7 +5,6 @@ import com.lagradost.cloudstream3.*
import com.lagradost.cloudstream3.utils.ExtractorLink
import com.lagradost.cloudstream3.utils.httpsify
import com.lagradost.cloudstream3.utils.loadExtractor
-import okhttp3.Interceptor
import org.jsoup.Jsoup
class HDMovie5 : MainAPI() {
@@ -137,7 +136,8 @@ class HDMovie5 : MainAPI() {
callback: (ExtractorLink) -> Unit
): Boolean {
return data.split(",").apmapIndexed { index, it ->
- val html = app.post(
+ //println("loadLinks:::: $index $it")
+ val p = app.post(
"$mainUrl/wp-admin/admin-ajax.php",
data = mapOf(
"action" to "doo_player_ajax",
@@ -145,10 +145,12 @@ class HDMovie5 : MainAPI() {
"nume" to "${index + 1}",
"type" to "movie"
)
- ).parsed().embedURL ?: return@apmapIndexed false
+ )
+ // println("TEXT::::: ${p.text}")
+ val html = p.parsedSafe()?.embedURL ?: return@apmapIndexed false
val doc = Jsoup.parse(html)
val link = doc.select("iframe").attr("src")
- loadExtractor(httpsify(link), "$mainUrl/",callback)
+ loadExtractor(httpsify(link), "$mainUrl/", callback)
}.contains(true)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
index 56cacdb5..00727624 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt
@@ -227,7 +227,7 @@ class HomeFragment : Fragment() {
listView?.choiceMode = AbsListView.CHOICE_MODE_SINGLE
listView?.setOnItemClickListener { _, _, i, _ ->
- if (!currentValidApis.isNullOrEmpty()) {
+ if (currentValidApis.isNotEmpty()) {
currentApiName = currentValidApis[i].name
//to switch to apply simply remove this
currentApiName?.let(callback)
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
index f33141c9..39506e71 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt
@@ -1508,7 +1508,7 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
when (startAction) {
START_ACTION_RESUME_LATEST -> {
for (ep in episodeList) {
- println("WATCH STATUS::: S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
+ //println("WATCH STATUS::: S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
if (ep.getWatchProgress() > 0.90f) { // watched too much
continue
}
@@ -1528,7 +1528,7 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
var found = false
for (ep in episodeList) {
if (ep.id == startValue) { // watched too much
- println("WATCH STATUS::: START_ACTION_LOAD_EP S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
+ //println("WATCH STATUS::: START_ACTION_LOAD_EP S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
handleAction(EpisodeClickEvent(ACTION_PLAY_EPISODE_IN_PLAYER, ep))
found = true
break
@@ -1537,7 +1537,7 @@ class ResultFragment : Fragment(), PanelsChildGestureRegionObserver.GestureRegio
if (!found)
for (ep in episodeList) {
if (ep.episode == resumeEpisode && ep.season == resumeSeason) {
- println("WATCH STATUS::: START_ACTION_LOAD_EP S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
+ //println("WATCH STATUS::: START_ACTION_LOAD_EP S${ep.season} E ${ep.episode} - ${ep.getWatchProgress()}")
handleAction(
EpisodeClickEvent(
ACTION_PLAY_EPISODE_IN_PLAYER,
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt
index cbaed031..adfe151e 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt
@@ -46,7 +46,6 @@ object SearchHelper {
activity.loadSearchResult(card, START_ACTION_LOAD_EP, id)
}
}
-
} else {
handleSearchClickCallback(
activity,