Skip to content

Commit

Permalink
fix(providers): fix scoped capabilities to create grouped providers
Browse files Browse the repository at this point in the history
In order to fix this, the whole film object is necessary to be passed instead of just the film title, id, etc. to the majority of the methods the provider api class.
  • Loading branch information
rhenwinch committed May 29, 2024
1 parent a031da4 commit 77cf887
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 217 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class DefaultSourceLinksRepository @Inject constructor(
override suspend fun getSourceLinks(
mediaId: String,
providerApi: ProviderApi,
film: Film,
season: Int?,
episode: Int?,
onLinkLoaded: (SourceLink) -> Unit,
Expand All @@ -33,6 +34,7 @@ class DefaultSourceLinksRepository @Inject constructor(
try {
providerApi.getSourceLinks(
filmId = mediaId,
film = film,
episode = episode,
season = season,
onLinkLoaded = onLinkLoaded,
Expand Down Expand Up @@ -70,9 +72,8 @@ class DefaultSourceLinksRepository @Inject constructor(
}

val searchResponse = providerApi.search(
query = film.title,
page = i,
filmType = film.filmType
film = film
)

if (searchResponse.results.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface SourceLinksRepository {
suspend fun getSourceLinks(
mediaId: String,
providerApi: ProviderApi,
film: Film,
season: Int? = null,
episode: Int? = null,
onLinkLoaded: (SourceLink) -> Unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class SourceLinksProviderUseCase @Inject constructor(

val result = sourceLinksRepository.getSourceLinks(
mediaId = mediaIdToUse,
film = film,
season = episodeToUse?.season,
episode = episodeToUse?.episode,
providerApi = provider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.flixclusive.feature.mobile.player.controls.common.ListContentHolder
import com.flixclusive.feature.mobile.player.controls.common.PlayerDialogButton
import com.flixclusive.model.provider.SourceLink
import com.flixclusive.model.provider.Subtitle
import com.flixclusive.model.tmdb.Film
import com.flixclusive.provider.ProviderApi
import com.flixclusive.provider.dto.FilmInfo
import com.flixclusive.provider.dto.SearchResults
Expand Down Expand Up @@ -108,11 +109,7 @@ private fun PlayerServersDialogPreview() {
override val name: String
get() = "Provider #$it"

override suspend fun search(
query: String,
page: Int,
filmType: FilmType
): SearchResults {
override suspend fun search(film: Film, page: Int): SearchResults {
TODO("Not yet implemented")
}

Expand All @@ -122,14 +119,14 @@ private fun PlayerServersDialogPreview() {

override suspend fun getSourceLinks(
filmId: String,
film: Film,
season: Int?,
episode: Int?,
onLinkLoaded: (SourceLink) -> Unit,
onSubtitleLoaded: (Subtitle) -> Unit
) {
TODO("Not yet implemented")
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.flixclusive.model.datastore.AppSettings
import com.flixclusive.model.provider.SourceDataState
import com.flixclusive.model.provider.SourceLink
import com.flixclusive.model.provider.Subtitle
import com.flixclusive.model.tmdb.Film
import com.flixclusive.model.tmdb.TMDBEpisode
import com.flixclusive.provider.ProviderApi
import com.flixclusive.provider.dto.FilmInfo
Expand Down Expand Up @@ -356,28 +357,24 @@ private fun PlaybackControlsPreview() {
override val name: String
get() = "Provider #$it"

override suspend fun search(
query: String,
page: Int,
filmType: FilmType
): SearchResults {
override suspend fun getFilmInfo(filmId: String, filmType: FilmType): FilmInfo {
TODO("Not yet implemented")
}

override suspend fun getFilmInfo(filmId: String, filmType: FilmType): FilmInfo {
override suspend fun search(film: Film, page: Int): SearchResults {
TODO("Not yet implemented")
}

override suspend fun getSourceLinks(
filmId: String,
film: Film,
season: Int?,
episode: Int?,
onLinkLoaded: (SourceLink) -> Unit,
onSubtitleLoaded: (Subtitle) -> Unit
) {
TODO("Not yet implemented")
}

}
}

Expand Down
14 changes: 8 additions & 6 deletions provider/src/main/kotlin/com/flixclusive/provider/ProviderApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import com.flixclusive.core.util.film.FilmType
import com.flixclusive.model.provider.SourceLink
import com.flixclusive.model.provider.Subtitle
import com.flixclusive.model.tmdb.Film
import com.flixclusive.model.tmdb.Movie
import com.flixclusive.model.tmdb.TMDBEpisode
import com.flixclusive.model.tmdb.TvShow
import com.flixclusive.provider.dto.FilmInfo
import com.flixclusive.provider.dto.SearchResults
import com.flixclusive.provider.extractor.Extractor
Expand Down Expand Up @@ -42,20 +44,18 @@ abstract class ProviderApi(

/**
* Performs a search for films based on the provided query.
* @param query The search query.
* @param film The [Film] object of the film. It could either be a [Movie] or [TvShow].
* @param page The page number for paginated results. Defaults to 1.
* @param filmType The type of film being searched for.
* @return a [SearchResults] instance containing the search results.
*/
abstract suspend fun search(
query: String,
film: Film,
page: Int = 1,
filmType: FilmType,
): SearchResults

/**
* Retrieves detailed information about a film.
* @param filmId The ID of the film.
* @param filmId The ID of the film. The ID must come from the [search] method.
* @param filmType The type of film.
* @return a [FilmInfo] instance containing the film's information.
*/
Expand All @@ -66,14 +66,16 @@ abstract class ProviderApi(

/**
* Obtains source links for the provided film, season, and episode.
* @param filmId The ID of the film.
* @param filmId The ID of the film. The ID must come from the [search] method.
* @param film The [Film] object of the film. It could either be a [Movie] or [TvShow].
* @param season The season number. Defaults to null if the film is a movie.
* @param episode The episode number. Defaults to null if the film is a movie.
* @param onLinkLoaded A callback function invoked when a [SourceLink] is loaded.
* @param onSubtitleLoaded A callback function invoked when a [Subtitle] is loaded.
*/
abstract suspend fun getSourceLinks(
filmId: String,
film: Film,
season: Int? = null,
episode: Int? = null,
onLinkLoaded: (SourceLink) -> Unit,
Expand Down

This file was deleted.

0 comments on commit 77cf887

Please sign in to comment.