mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
fixed #652 (downloaded subtitles) and migration tool
This commit is contained in:
parent
59b0dc988b
commit
cd6c79b961
7 changed files with 61 additions and 34 deletions
|
@ -124,7 +124,7 @@ class WcoProvider : MainAPI() {
|
||||||
|
|
||||||
while (!document.select(".pagination").isEmpty()) {
|
while (!document.select(".pagination").isEmpty()) {
|
||||||
val link = document.select("a.page-link[rel=\"next\"]")
|
val link = document.select("a.page-link[rel=\"next\"]")
|
||||||
if (!link.isEmpty()) {
|
if (!link.isEmpty() && returnValue.size < 40) {
|
||||||
val extraResponse = app.get(fixUrl(link[0].attr("href"))).text
|
val extraResponse = app.get(fixUrl(link[0].attr("href"))).text
|
||||||
document = Jsoup.parse(extraResponse)
|
document = Jsoup.parse(extraResponse)
|
||||||
returnValue.addAll(parseSearchPage(document))
|
returnValue.addAll(parseSearchPage(document))
|
||||||
|
@ -132,7 +132,7 @@ class WcoProvider : MainAPI() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnValue
|
return returnValue.distinctBy { it.url }
|
||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun quickSearch(query: String): List<SearchResponse> {
|
override suspend fun quickSearch(query: String): List<SearchResponse> {
|
||||||
|
|
|
@ -129,8 +129,7 @@ object DownloadButtonSetup {
|
||||||
displayName = keyInfo.displayName,
|
displayName = keyInfo.displayName,
|
||||||
relativePath = keyInfo.relativePath,
|
relativePath = keyInfo.relativePath,
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
0
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
//R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
//R.id.global_to_navigation_player, PlayerFragment.newInstance(
|
||||||
|
|
|
@ -43,11 +43,23 @@ class ParentItemAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateList(newList: List<HomePageList>) {
|
fun updateList(newList: List<HomePageList>) {
|
||||||
|
// this moves all bad results to the bottom
|
||||||
|
val endList = mutableListOf<HomePageList>()
|
||||||
|
val newFilteredList = mutableListOf<HomePageList>()
|
||||||
|
for (item in newList) {
|
||||||
|
if(item.list.isEmpty()) {
|
||||||
|
endList.add(item)
|
||||||
|
} else {
|
||||||
|
newFilteredList.add(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
newFilteredList.addAll(endList)
|
||||||
|
|
||||||
val diffResult = DiffUtil.calculateDiff(
|
val diffResult = DiffUtil.calculateDiff(
|
||||||
SearchDiffCallback(this.items, newList))
|
SearchDiffCallback(this.items, newFilteredList))
|
||||||
|
|
||||||
items.clear()
|
items.clear()
|
||||||
items.addAll(newList)
|
items.addAll(newFilteredList)
|
||||||
|
|
||||||
diffResult.dispatchUpdatesTo(this)
|
diffResult.dispatchUpdatesTo(this)
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,14 +120,13 @@ class CS3IPlayer : IPlayer {
|
||||||
Handler(it).post {
|
Handler(it).post {
|
||||||
try {
|
try {
|
||||||
seekTime(1L)
|
seekTime(1L)
|
||||||
} catch (e : Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e : Exception) {
|
} catch (e: Exception) {
|
||||||
logError(e)
|
logError(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,7 +286,7 @@ class CS3IPlayer : IPlayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
var requestSubtitleUpdate : (() -> Unit)? = null
|
var requestSubtitleUpdate: (() -> Unit)? = null
|
||||||
|
|
||||||
private fun createOnlineSource(link: ExtractorLink): DataSource.Factory {
|
private fun createOnlineSource(link: ExtractorLink): DataSource.Factory {
|
||||||
// Because Trailers.to seems to fail with http/1.1 the normal one uses.
|
// Because Trailers.to seems to fail with http/1.1 the normal one uses.
|
||||||
|
@ -660,8 +659,8 @@ class CS3IPlayer : IPlayer {
|
||||||
val offlineSourceFactory = context.createOfflineSource()
|
val offlineSourceFactory = context.createOfflineSource()
|
||||||
|
|
||||||
val (subSources, activeSubtitles) = getSubSources(
|
val (subSources, activeSubtitles) = getSubSources(
|
||||||
offlineSourceFactory,
|
onlineSourceFactory = offlineSourceFactory,
|
||||||
offlineSourceFactory,
|
offlineSourceFactory = offlineSourceFactory,
|
||||||
subtitleHelper,
|
subtitleHelper,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -740,8 +739,8 @@ class CS3IPlayer : IPlayer {
|
||||||
val offlineSourceFactory = context.createOfflineSource()
|
val offlineSourceFactory = context.createOfflineSource()
|
||||||
|
|
||||||
val (subSources, activeSubtitles) = getSubSources(
|
val (subSources, activeSubtitles) = getSubSources(
|
||||||
offlineSourceFactory,
|
onlineSourceFactory = onlineSourceFactory,
|
||||||
onlineSourceFactory,
|
offlineSourceFactory = offlineSourceFactory,
|
||||||
subtitleHelper
|
subtitleHelper
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
|
import com.lagradost.cloudstream3.APIHolder.apis
|
||||||
|
import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings
|
||||||
import com.lagradost.cloudstream3.HomePageList
|
import com.lagradost.cloudstream3.HomePageList
|
||||||
import com.lagradost.cloudstream3.R
|
import com.lagradost.cloudstream3.R
|
||||||
import com.lagradost.cloudstream3.mvvm.Resource
|
import com.lagradost.cloudstream3.mvvm.Resource
|
||||||
|
@ -34,7 +36,16 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
fun pushSearch(activity: Activity?, autoSearch: String? = null) {
|
fun pushSearch(activity: Activity?, autoSearch: String? = null) {
|
||||||
activity.navigate(R.id.global_to_navigation_quick_search, Bundle().apply {
|
activity.navigate(R.id.global_to_navigation_quick_search, Bundle().apply {
|
||||||
putBoolean("mainapi", true)
|
putBoolean("mainapi", true)
|
||||||
putString("autosearch", autoSearch)
|
autoSearch?.let {
|
||||||
|
putString(
|
||||||
|
"autosearch",
|
||||||
|
it.trim()
|
||||||
|
.removeSuffix("(DUB)")
|
||||||
|
.removeSuffix("(SUB)")
|
||||||
|
.removeSuffix("(Dub)")
|
||||||
|
.removeSuffix("(Sub)").trim()
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,18 +131,24 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
})
|
})
|
||||||
|
|
||||||
val searchExitIcon =
|
val searchExitIcon =
|
||||||
quick_search.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
||||||
val searchMagIcon =
|
val searchMagIcon =
|
||||||
quick_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||||
|
|
||||||
searchMagIcon.scaleX = 0.65f
|
searchMagIcon?.scaleX = 0.65f
|
||||||
searchMagIcon.scaleY = 0.65f
|
searchMagIcon?.scaleY = 0.65f
|
||||||
quick_search.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
quick_search?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
override fun onQueryTextSubmit(query: String): Boolean {
|
override fun onQueryTextSubmit(query: String): Boolean {
|
||||||
|
val active = if (isMainApis) {
|
||||||
|
val langs = context?.getApiProviderLangSettings()
|
||||||
|
apis.filter { langs?.contains(it.lang) == true }.map { it.name }.toSet()
|
||||||
|
} else emptySet()
|
||||||
|
|
||||||
searchViewModel.searchAndCancel(
|
searchViewModel.searchAndCancel(
|
||||||
query = query,
|
query = query,
|
||||||
isMainApis = isMainApis,
|
isMainApis = isMainApis,
|
||||||
ignoreSettings = true
|
ignoreSettings = false,
|
||||||
|
providersActive = active
|
||||||
)
|
)
|
||||||
quick_search?.let {
|
quick_search?.let {
|
||||||
UIHelper.hideKeyboard(it)
|
UIHelper.hideKeyboard(it)
|
||||||
|
@ -152,26 +169,26 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
it.value.let { data ->
|
it.value.let { data ->
|
||||||
if (data.isNotEmpty()) {
|
if (data.isNotEmpty()) {
|
||||||
(search_autofit_results?.adapter as SearchAdapter?)?.updateList(data)
|
(search_autofit_results?.adapter as? SearchAdapter?)?.updateList(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
searchExitIcon.alpha = 1f
|
searchExitIcon?.alpha = 1f
|
||||||
quick_search_loading_bar.alpha = 0f
|
quick_search_loading_bar?.alpha = 0f
|
||||||
}
|
}
|
||||||
is Resource.Failure -> {
|
is Resource.Failure -> {
|
||||||
// Toast.makeText(activity, "Server error", Toast.LENGTH_LONG).show()
|
// Toast.makeText(activity, "Server error", Toast.LENGTH_LONG).show()
|
||||||
searchExitIcon.alpha = 1f
|
searchExitIcon?.alpha = 1f
|
||||||
quick_search_loading_bar.alpha = 0f
|
quick_search_loading_bar?.alpha = 0f
|
||||||
}
|
}
|
||||||
is Resource.Loading -> {
|
is Resource.Loading -> {
|
||||||
searchExitIcon.alpha = 0f
|
searchExitIcon?.alpha = 0f
|
||||||
quick_search_loading_bar.alpha = 1f
|
quick_search_loading_bar?.alpha = 1f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
quick_search_master_recycler.adapter = masterAdapter
|
quick_search_master_recycler?.adapter = masterAdapter
|
||||||
quick_search_master_recycler.layoutManager = GridLayoutManager(context, 1)
|
quick_search_master_recycler?.layoutManager = GridLayoutManager(context, 1)
|
||||||
|
|
||||||
//quick_search.setOnQueryTextFocusChangeListener { _, b ->
|
//quick_search.setOnQueryTextFocusChangeListener { _, b ->
|
||||||
// if (b) {
|
// if (b) {
|
||||||
|
@ -185,7 +202,7 @@ class QuickSearchFragment(var isMainApis: Boolean = false) : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
arguments?.getString("autosearch")?.let {
|
arguments?.getString("autosearch")?.let {
|
||||||
quick_search.setQuery(it, true)
|
quick_search?.setQuery(it, true)
|
||||||
arguments?.remove("autosearch")
|
arguments?.remove("autosearch")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ class EpisodeAdapter(
|
||||||
card.episode,
|
card.episode,
|
||||||
card.season,
|
card.season,
|
||||||
card.id,
|
card.id,
|
||||||
0,
|
card.parentId,
|
||||||
card.rating,
|
card.rating,
|
||||||
card.description,
|
card.description,
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
|
|
|
@ -118,7 +118,7 @@ data class ResultEpisode(
|
||||||
val description: String?,
|
val description: String?,
|
||||||
val isFiller: Boolean?,
|
val isFiller: Boolean?,
|
||||||
val tvType: TvType,
|
val tvType: TvType,
|
||||||
val parentId: Int?,
|
val parentId: Int,
|
||||||
)
|
)
|
||||||
|
|
||||||
fun ResultEpisode.getRealPosition(): Long {
|
fun ResultEpisode.getRealPosition(): Long {
|
||||||
|
@ -151,7 +151,7 @@ fun buildResultEpisode(
|
||||||
description: String?,
|
description: String?,
|
||||||
isFiller: Boolean?,
|
isFiller: Boolean?,
|
||||||
tvType: TvType,
|
tvType: TvType,
|
||||||
parentId: Int?,
|
parentId: Int,
|
||||||
): ResultEpisode {
|
): ResultEpisode {
|
||||||
val posDur = getViewPos(id)
|
val posDur = getViewPos(id)
|
||||||
return ResultEpisode(
|
return ResultEpisode(
|
||||||
|
|
Loading…
Reference in a new issue