Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include Dub/Sub selection for MovieLoadResponse #1545

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1817,11 +1817,15 @@ class ResultViewModel2 : ViewModel() {
postEpisodeRange(currentIndex?.copy(season = season), currentRange)
}

private fun getMovie(): ResultEpisode? {
return currentEpisodes.entries.firstOrNull()?.value?.firstOrNull()?.let { ep ->
val posDur = getViewPos(ep.id)
ep.copy(position = posDur?.position ?: 0, duration = posDur?.duration ?: 0)
}
private fun getMovie(dubStatus: DubStatus?): ResultEpisode? {
if(dubStatus == null) return null
return currentEpisodes.entries
.firstOrNull { it.key.dubStatus == dubStatus }
?.value?.firstOrNull()
?.let { ep ->
val posDur = getViewPos(ep.id)
ep.copy(position = posDur?.position ?: 0, duration = posDur?.duration ?: 0)
}
}

private fun getEpisodes(indexer: EpisodeIndexer, range: EpisodeRange): List<ResultEpisode> {
Expand Down Expand Up @@ -1867,7 +1871,7 @@ class ResultViewModel2 : ViewModel() {
}
}
)
val data = getMovie()
val data = getMovie(preferDubStatus)
_episodes.postValue(null)
if (text == null || data == null) {
_movie.postValue(null)
Expand Down Expand Up @@ -2000,7 +2004,7 @@ class ResultViewModel2 : ViewModel() {

_selectedDubStatus.postValue(

if (isMovie || currentDubStatus.size <= 1) null else
if (currentDubStatus.size <= 1) null else
txt(indexer.dubStatus)

)
Expand All @@ -2016,7 +2020,7 @@ class ResultViewModel2 : ViewModel() {
preferDubStatus = indexer.dubStatus

generator = if (isMovie) {
getMovie()?.let { RepoLinkGenerator(listOf(it), page = currentResponse) }
getMovie(preferDubStatus)?.let { RepoLinkGenerator(listOf(it), page = currentResponse) }
} else {
val episodes = currentEpisodes.filter { it.key.dubStatus == indexer.dubStatus }
.toList()
Expand Down Expand Up @@ -2183,26 +2187,58 @@ class ResultViewModel2 : ViewModel() {
}

is MovieLoadResponse -> {
singleMap(
buildResultEpisode(
loadResponse.name,
loadResponse.name,
null,
0,
null,
null,
loadResponse.dataUrl,
loadResponse.apiName,
(mainId), // HAS SAME ID
0,
null,
null,
null,
loadResponse.type,
mainId,
null,
val movieLoadResponse = loadResponse as MovieLoadResponse
val movieLoadResponseTracks = movieLoadResponse.tracks
if(movieLoadResponseTracks == null){
singleMap(
buildResultEpisode(
loadResponse.name,
loadResponse.name,
null,
0,
null,
null,
loadResponse.dataUrl,
loadResponse.apiName,
(mainId), // HAS SAME ID
0,
null,
null,
null,
loadResponse.type,
mainId,
null,
)
)
)
}else{
val tracks: MutableMap<EpisodeIndexer, MutableList<ResultEpisode>> =
mutableMapOf()
movieLoadResponseTracks.map { (dubStatus, data) ->
tracks.getOrPut(EpisodeIndexer(dubStatus,0),{ mutableListOf() }).add(
buildResultEpisode(
loadResponse.name + dubStatus.toString(),
loadResponse.name + dubStatus.toString(),
null,
0,
null,
null,
data,
loadResponse.apiName,
(mainId+dubStatus.id),
0,
null,
null,
null,
loadResponse.type,
mainId,
null,
)
)
}
tracks
}


}

is LiveStreamLoadResponse -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2026,6 +2026,7 @@ constructor(
override var apiName: String,
override var type: TvType,
var dataUrl: String,
var tracks: MutableMap<DubStatus, String>? = null,

override var posterUrl: String? = null,
override var year: Int? = null,
Expand Down Expand Up @@ -2058,6 +2059,7 @@ constructor(
apiName: String,
type: TvType,
dataUrl: String,
tracks: MutableMap<DubStatus, String>?,
posterUrl: String? = null,
year: Int? = null,
plot: String? = null,
Expand All @@ -2072,7 +2074,7 @@ constructor(
posterHeaders: Map<String, String>? = null,
backgroundPosterUrl: String? = null,
) : this(
name, url, apiName, type, dataUrl, posterUrl, year, plot, rating, tags, duration, trailers,
name, url, apiName, type, dataUrl, tracks, posterUrl, year, plot, rating, tags, duration, trailers,
recommendations, actors, comingSoon, syncData, posterHeaders, backgroundPosterUrl, null
)
}
Expand Down