forked from recloudstream/cloudstream
mini fix
This commit is contained in:
parent
4596afee06
commit
84493b7f3b
2 changed files with 16 additions and 17 deletions
|
@ -82,7 +82,7 @@ object APIHolder {
|
||||||
initMap()
|
initMap()
|
||||||
return apiMap?.get(apiName)?.let { apis.getOrNull(it) }
|
return apiMap?.get(apiName)?.let { apis.getOrNull(it) }
|
||||||
// Leave the ?. null check, it can crash regardless
|
// Leave the ?. null check, it can crash regardless
|
||||||
?: allProviders.firstOrNull { it?.name == apiName }
|
?: allProviders.firstOrNull { it.name == apiName }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1465,12 +1465,17 @@ class ResultViewModel2 : ViewModel() {
|
||||||
argamap(
|
argamap(
|
||||||
{
|
{
|
||||||
if (this !is AnimeLoadResponse) return@argamap
|
if (this !is AnimeLoadResponse) return@argamap
|
||||||
|
// already exist, no need to run getTracker
|
||||||
|
if (this.getAniListId() != null && this.getMalId() != null) return@argamap
|
||||||
|
|
||||||
val res = APIHolder.getTracker(
|
val res = APIHolder.getTracker(
|
||||||
listOfNotNull(
|
listOfNotNull(
|
||||||
this.engName,
|
this.engName,
|
||||||
this.name,
|
this.name,
|
||||||
this.japName
|
this.japName
|
||||||
).distinct(), TrackerType.getTypes(this.type), this.year
|
).filter { it.length > 2 }.distinct(), // the reason why we filter is due to not wanting smth like " " or "?"
|
||||||
|
TrackerType.getTypes(this.type),
|
||||||
|
this.year
|
||||||
)
|
)
|
||||||
|
|
||||||
val ids = arrayOf(
|
val ids = arrayOf(
|
||||||
|
@ -1499,7 +1504,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
backgroundPosterUrl = backgroundPosterUrl ?: res?.cover
|
backgroundPosterUrl = backgroundPosterUrl ?: res?.cover
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
if(meta == null) return@argamap
|
if (meta == null) return@argamap
|
||||||
addTrailer(meta.trailers)
|
addTrailer(meta.trailers)
|
||||||
}, {
|
}, {
|
||||||
if (this !is AnimeLoadResponse) return@argamap
|
if (this !is AnimeLoadResponse) return@argamap
|
||||||
|
@ -2162,7 +2167,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
autostart: AutoResume?,
|
autostart: AutoResume?,
|
||||||
loadTrailers: Boolean = true,
|
loadTrailers: Boolean = true,
|
||||||
) =
|
) =
|
||||||
viewModelScope.launchSafe {
|
ioSafe {
|
||||||
_page.postValue(Resource.Loading(url))
|
_page.postValue(Resource.Loading(url))
|
||||||
_episodes.postValue(ResourceSome.Loading())
|
_episodes.postValue(ResourceSome.Loading())
|
||||||
|
|
||||||
|
@ -2180,7 +2185,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
"This provider does not exist"
|
"This provider does not exist"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return@launchSafe
|
return@ioSafe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2191,21 +2196,15 @@ class ResultViewModel2 : ViewModel() {
|
||||||
api
|
api
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// TODO: fix
|
|
||||||
// val validUrlResource = safeApiCall {
|
|
||||||
// SyncRedirector.redirect(
|
|
||||||
// url,
|
|
||||||
// api.mainUrl.replace(NineAnimeProvider().mainUrl, "9anime")
|
|
||||||
// .replace(GogoanimeProvider().mainUrl, "gogoanime")
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
if (validUrlResource !is Resource.Success) {
|
if (validUrlResource !is Resource.Success) {
|
||||||
if (validUrlResource is Resource.Failure) {
|
if (validUrlResource is Resource.Failure) {
|
||||||
_page.postValue(validUrlResource)
|
_page.postValue(validUrlResource)
|
||||||
}
|
}
|
||||||
|
|
||||||
return@launchSafe
|
return@ioSafe
|
||||||
}
|
}
|
||||||
|
|
||||||
val validUrl = validUrlResource.value
|
val validUrl = validUrlResource.value
|
||||||
val repo = APIRepository(api)
|
val repo = APIRepository(api)
|
||||||
currentRepo = repo
|
currentRepo = repo
|
||||||
|
@ -2215,11 +2214,11 @@ class ResultViewModel2 : ViewModel() {
|
||||||
_page.postValue(data)
|
_page.postValue(data)
|
||||||
}
|
}
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
if (!isActive) return@launchSafe
|
if (!isActive) return@ioSafe
|
||||||
val loadResponse = ioWork {
|
val loadResponse = ioWork {
|
||||||
applyMeta(data.value, currentMeta, currentSync).first
|
applyMeta(data.value, currentMeta, currentSync).first
|
||||||
}
|
}
|
||||||
if (!isActive) return@launchSafe
|
if (!isActive) return@ioSafe
|
||||||
val mainId = loadResponse.getId()
|
val mainId = loadResponse.getId()
|
||||||
|
|
||||||
preferDubStatus = getDub(mainId) ?: preferDubStatus
|
preferDubStatus = getDub(mainId) ?: preferDubStatus
|
||||||
|
@ -2247,7 +2246,7 @@ class ResultViewModel2 : ViewModel() {
|
||||||
updateFillers = showFillers,
|
updateFillers = showFillers,
|
||||||
apiRepository = repo
|
apiRepository = repo
|
||||||
)
|
)
|
||||||
if (!isActive) return@launchSafe
|
if (!isActive) return@ioSafe
|
||||||
handleAutoStart(activity, autostart)
|
handleAutoStart(activity, autostart)
|
||||||
}
|
}
|
||||||
is Resource.Loading -> {
|
is Resource.Loading -> {
|
||||||
|
|
Loading…
Reference in a new issue