fixed json from github issue

This commit is contained in:
LagradOst 2022-06-03 00:51:41 +02:00
parent d4f33eecde
commit ada48f2a98
8 changed files with 50 additions and 40 deletions

View file

@ -15,7 +15,6 @@
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>

View file

@ -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<MainAPI> = arrayListOf()
private var apiMap: Map<String, Int>? = null
var apiMap: Map<String, Int>? = 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<String, ProvidersInfoJson>? = 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)
}

View file

@ -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<String, ProvidersInfoJson>): java.util.HashMap<String, ProvidersInfoJson>? {
fun addNginxToJson(data: java.util.HashMap<String, ProvidersInfoJson>): java.util.HashMap<String, ProvidersInfoJson> {
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)

View file

@ -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(

View file

@ -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<PlayerAjaxResponse>().embedURL ?: return@apmapIndexed false
)
// println("TEXT::::: ${p.text}")
val html = p.parsedSafe<PlayerAjaxResponse>()?.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)
}
}

View file

@ -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)

View file

@ -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,

View file

@ -46,7 +46,6 @@ object SearchHelper {
activity.loadSearchResult(card, START_ACTION_LOAD_EP, id)
}
}
} else {
handleSearchClickCallback(
activity,