removed trailers.to

This commit is contained in:
LagradOst 2021-09-05 13:56:25 +02:00
parent d49384a4cd
commit b8cb0de233
4 changed files with 42 additions and 13 deletions

View file

@ -27,11 +27,11 @@ object APIHolder {
private const val defProvider = 0 private const val defProvider = 0
val apis = arrayListOf( val apis = arrayListOf(
TrailersToProvider(), GogoanimeProvider(),
//ShiroProvider(), // v2 fucked me //ShiroProvider(), // v2 fucked me
//AnimePaheProvider(), //ddos guard //AnimePaheProvider(), //ddos guard
AnimeFlickProvider(), AnimeFlickProvider(),
GogoanimeProvider(),
TenshiProvider(), TenshiProvider(),
WcoProvider(), WcoProvider(),
// MeloMovieProvider(), // Captcha for links // MeloMovieProvider(), // Captcha for links
@ -46,6 +46,7 @@ object APIHolder {
val restrictedApis = arrayListOf( val restrictedApis = arrayListOf(
NyaaProvider(), NyaaProvider(),
TrailersToProvider(),
) )
fun getApiFromName(apiName: String?): MainAPI { fun getApiFromName(apiName: String?): MainAPI {

View file

@ -10,8 +10,19 @@ class APIRepository(val api: MainAPI) {
companion object { companion object {
var providersActive = HashSet<String>() var providersActive = HashSet<String>()
var typesActive = HashSet<TvType>() 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 name: String get() = api.name
val mainUrl: String get() = api.mainUrl val mainUrl: String get() = api.mainUrl
val hasQuickSearch: Boolean get() = api.hasQuickSearch val hasQuickSearch: Boolean get() = api.hasQuickSearch

View file

@ -22,6 +22,8 @@ import com.lagradost.cloudstream3.APIHolder.apis
import com.lagradost.cloudstream3.MainActivity.Companion.backEvent import com.lagradost.cloudstream3.MainActivity.Companion.backEvent
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.mvvm.observe 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.AutofitRecyclerView
import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.WatchType
import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST
@ -154,6 +156,8 @@ class HomeFragment : Fragment() {
toggleMainVisibility(false) toggleMainVisibility(false)
return null return null
} }
} else {
toggleMainVisibility(false)
} }
return null return null
} }
@ -173,10 +177,11 @@ class HomeFragment : Fragment() {
} }
private val apiChangeClickListener = View.OnClickListener { view -> 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) }) { view.popupMenuNoIconsAndNoStringRes(validAPIs.mapIndexed { index, api -> Pair(index, api.name) }) {
homeViewModel.loadAndCancel(validAPIs[itemId]) homeViewModel.loadAndCancel(validAPIs[itemId].name)
} }
} }
@ -378,8 +383,8 @@ class HomeFragment : Fragment() {
reloadStored() reloadStored()
} }
if (itemId == 0) { if (itemId == 0) {
val card = callback.card val card = callback.card
if(card is DataStoreHelper.ResumeWatchingResult) { if (card is DataStoreHelper.ResumeWatchingResult) {
context?.removeLastWatched(card.parentId) context?.removeLastWatched(card.parentId)
reloadStored() reloadStored()
} }

View file

@ -12,6 +12,9 @@ import com.lagradost.cloudstream3.MainAPI
import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.Resource
import com.lagradost.cloudstream3.ui.APIRepository 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.ui.WatchType
import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE
import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKey
@ -131,19 +134,28 @@ class HomeViewModel : ViewModel() {
} }
private fun load(api: MainAPI?) = viewModelScope.launch { private fun load(api: MainAPI?) = viewModelScope.launch {
repo = if (api?.hasMainPage == true) { repo = if (api != null) {
APIRepository(api) APIRepository(api)
} else { } else {
autoloadRepo() autoloadRepo()
} }
_apiName.postValue(repo?.name) _apiName.postValue(repo?.name)
_page.postValue(Resource.Loading()) if (repo?.hasMainPage == true) {
_page.postValue(repo?.getMainPage()) _page.postValue(Resource.Loading())
_page.postValue(repo?.getMainPage())
} else {
_page.postValue(Resource.Success(HomePageResponse(emptyList())))
}
} }
fun loadAndCancel(preferredApiName: String?) = viewModelScope.launch { fun loadAndCancel(preferredApiName: String?) = viewModelScope.launch {
val api = getApiFromNameNull(preferredApiName) val api = getApiFromNameNull(preferredApiName)
loadAndCancel(api) if (preferredApiName == noneApi.name)
loadAndCancel(noneApi)
else if(preferredApiName == randomApi.name || api == null) {
loadAndCancel(apis.filter { it.hasMainPage }.random())
} else {
loadAndCancel(api)
}
} }
} }