forked from recloudstream/cloudstream
removed trailers.to
This commit is contained in:
parent
d49384a4cd
commit
b8cb0de233
4 changed files with 42 additions and 13 deletions
|
@ -27,11 +27,11 @@ object APIHolder {
|
|||
private const val defProvider = 0
|
||||
|
||||
val apis = arrayListOf(
|
||||
TrailersToProvider(),
|
||||
GogoanimeProvider(),
|
||||
//ShiroProvider(), // v2 fucked me
|
||||
//AnimePaheProvider(), //ddos guard
|
||||
AnimeFlickProvider(),
|
||||
GogoanimeProvider(),
|
||||
|
||||
TenshiProvider(),
|
||||
WcoProvider(),
|
||||
// MeloMovieProvider(), // Captcha for links
|
||||
|
@ -46,6 +46,7 @@ object APIHolder {
|
|||
|
||||
val restrictedApis = arrayListOf(
|
||||
NyaaProvider(),
|
||||
TrailersToProvider(),
|
||||
)
|
||||
|
||||
fun getApiFromName(apiName: String?): MainAPI {
|
||||
|
|
|
@ -10,8 +10,19 @@ class APIRepository(val api: MainAPI) {
|
|||
companion object {
|
||||
var providersActive = HashSet<String>()
|
||||
var typesActive = HashSet<TvType>()
|
||||
|
||||
val noneApi = object : MainAPI() {
|
||||
override val name: String
|
||||
get() = "None"
|
||||
}
|
||||
val randomApi = object : MainAPI() {
|
||||
override val name: String
|
||||
get() = "Random"
|
||||
}
|
||||
|
||||
val noneRepo = APIRepository(noneApi)
|
||||
}
|
||||
val hasMainPage: Boolean get() = api.hasMainPage
|
||||
val name: String get() = api.name
|
||||
val mainUrl: String get() = api.mainUrl
|
||||
val hasQuickSearch: Boolean get() = api.hasQuickSearch
|
||||
|
|
|
@ -22,6 +22,8 @@ import com.lagradost.cloudstream3.APIHolder.apis
|
|||
import com.lagradost.cloudstream3.MainActivity.Companion.backEvent
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.mvvm.observe
|
||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
|
||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
|
||||
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
||||
import com.lagradost.cloudstream3.ui.WatchType
|
||||
import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST
|
||||
|
@ -154,6 +156,8 @@ class HomeFragment : Fragment() {
|
|||
toggleMainVisibility(false)
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
toggleMainVisibility(false)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
@ -173,10 +177,11 @@ class HomeFragment : Fragment() {
|
|||
}
|
||||
|
||||
private val apiChangeClickListener = View.OnClickListener { view ->
|
||||
val validAPIs = apis.filter { api -> api.hasMainPage }
|
||||
|
||||
val validAPIs = apis.filter { api -> api.hasMainPage }.toMutableList()
|
||||
validAPIs.add(0, randomApi)
|
||||
validAPIs.add(0, noneApi)
|
||||
view.popupMenuNoIconsAndNoStringRes(validAPIs.mapIndexed { index, api -> Pair(index, api.name) }) {
|
||||
homeViewModel.loadAndCancel(validAPIs[itemId])
|
||||
homeViewModel.loadAndCancel(validAPIs[itemId].name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -379,7 +384,7 @@ class HomeFragment : Fragment() {
|
|||
}
|
||||
if (itemId == 0) {
|
||||
val card = callback.card
|
||||
if(card is DataStoreHelper.ResumeWatchingResult) {
|
||||
if (card is DataStoreHelper.ResumeWatchingResult) {
|
||||
context?.removeLastWatched(card.parentId)
|
||||
reloadStored()
|
||||
}
|
||||
|
|
|
@ -12,6 +12,9 @@ import com.lagradost.cloudstream3.MainAPI
|
|||
import com.lagradost.cloudstream3.SearchResponse
|
||||
import com.lagradost.cloudstream3.mvvm.Resource
|
||||
import com.lagradost.cloudstream3.ui.APIRepository
|
||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
|
||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneRepo
|
||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
|
||||
import com.lagradost.cloudstream3.ui.WatchType
|
||||
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
|
||||
import com.lagradost.cloudstream3.utils.DataStore.getKey
|
||||
|
@ -131,19 +134,28 @@ class HomeViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private fun load(api: MainAPI?) = viewModelScope.launch {
|
||||
repo = if (api?.hasMainPage == true) {
|
||||
repo = if (api != null) {
|
||||
APIRepository(api)
|
||||
} else {
|
||||
autoloadRepo()
|
||||
}
|
||||
|
||||
_apiName.postValue(repo?.name)
|
||||
if (repo?.hasMainPage == true) {
|
||||
_page.postValue(Resource.Loading())
|
||||
_page.postValue(repo?.getMainPage())
|
||||
} else {
|
||||
_page.postValue(Resource.Success(HomePageResponse(emptyList())))
|
||||
}
|
||||
}
|
||||
|
||||
fun loadAndCancel(preferredApiName: String?) = viewModelScope.launch {
|
||||
val api = getApiFromNameNull(preferredApiName)
|
||||
if (preferredApiName == noneApi.name)
|
||||
loadAndCancel(noneApi)
|
||||
else if(preferredApiName == randomApi.name || api == null) {
|
||||
loadAndCancel(apis.filter { it.hasMainPage }.random())
|
||||
} else {
|
||||
loadAndCancel(api)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue