From 1f0d642878ff46c47f54f5e7a867036b77b13c65 Mon Sep 17 00:00:00 2001 From: Lory-Stan TANASI Date: Mon, 21 Oct 2024 18:48:29 +0200 Subject: [PATCH] feat(tmdb-provider): implement Moviesapi server #195 --- .../streamflix/extractors/ChillxExtractor.kt | 5 ++ .../tanasi/streamflix/extractors/Extractor.kt | 1 + .../extractors/MoviesapiExtractor.kt | 57 +++++++++++++++++++ .../streamflix/providers/TmdbProvider.kt | 2 + 4 files changed, 65 insertions(+) create mode 100644 app/src/main/java/com/tanasi/streamflix/extractors/MoviesapiExtractor.kt diff --git a/app/src/main/java/com/tanasi/streamflix/extractors/ChillxExtractor.kt b/app/src/main/java/com/tanasi/streamflix/extractors/ChillxExtractor.kt index e42e682c..9cb83514 100644 --- a/app/src/main/java/com/tanasi/streamflix/extractors/ChillxExtractor.kt +++ b/app/src/main/java/com/tanasi/streamflix/extractors/ChillxExtractor.kt @@ -62,6 +62,11 @@ open class ChillxExtractor : Extractor() { override val mainUrl = "https://player.jeansaispasplus.homes/" } + class MoviesapiExtractor : ChillxExtractor() { + override val name = "Moviesapi" + override val mainUrl = "https://moviesapi.club/" + } + private interface Service { diff --git a/app/src/main/java/com/tanasi/streamflix/extractors/Extractor.kt b/app/src/main/java/com/tanasi/streamflix/extractors/Extractor.kt index 448b316f..2b2f3972 100644 --- a/app/src/main/java/com/tanasi/streamflix/extractors/Extractor.kt +++ b/app/src/main/java/com/tanasi/streamflix/extractors/Extractor.kt @@ -33,6 +33,7 @@ abstract class Extractor { TwoEmbedExtractor(), ChillxExtractor(), ChillxExtractor.JeanExtractor(), + MoviesapiExtractor(), ) suspend fun extract(link: String): Video { diff --git a/app/src/main/java/com/tanasi/streamflix/extractors/MoviesapiExtractor.kt b/app/src/main/java/com/tanasi/streamflix/extractors/MoviesapiExtractor.kt new file mode 100644 index 00000000..2f83ed8a --- /dev/null +++ b/app/src/main/java/com/tanasi/streamflix/extractors/MoviesapiExtractor.kt @@ -0,0 +1,57 @@ +package com.tanasi.streamflix.extractors + +import com.tanasi.retrofit_jsoup.converter.JsoupConverterFactory +import com.tanasi.streamflix.models.Video +import org.jsoup.nodes.Document +import retrofit2.Retrofit +import retrofit2.http.GET +import retrofit2.http.Header +import retrofit2.http.Url + +class MoviesapiExtractor : Extractor() { + + override val name = "Moviesapi" + override val mainUrl = "https://moviesapi.club/" + + fun server(videoType: Video.Type): Video.Server { + return Video.Server( + id = name, + name = name, + src = when (videoType) { + is Video.Type.Episode -> "$mainUrl/tv/${videoType.tvShow.id}-${videoType.season.number}-${videoType.number}" + is Video.Type.Movie -> "$mainUrl/movie/${videoType.id}" + }, + ) + } + + override suspend fun extract(link: String): Video { + val service = Service.build(mainUrl) + + val iframe = service.get(link, referer = "https://pressplay.top/") + .selectFirst("iframe") + ?.attr("src") + ?: throw Exception("Can't retrieve iframe") + + return ChillxExtractor.MoviesapiExtractor().extract(iframe) + } + + private interface Service { + + companion object { + fun build(baseUrl: String): Service { + val retrofit = Retrofit.Builder() + .baseUrl(baseUrl) + .addConverterFactory(JsoupConverterFactory.create()) + .build() + + return retrofit.create(Service::class.java) + } + } + + @GET + suspend fun get( + @Url url: String, + @Header("referer") referer: String = "", + ): Document + } +} \ No newline at end of file diff --git a/app/src/main/java/com/tanasi/streamflix/providers/TmdbProvider.kt b/app/src/main/java/com/tanasi/streamflix/providers/TmdbProvider.kt index 15d91975..f957b3fb 100644 --- a/app/src/main/java/com/tanasi/streamflix/providers/TmdbProvider.kt +++ b/app/src/main/java/com/tanasi/streamflix/providers/TmdbProvider.kt @@ -3,6 +3,7 @@ package com.tanasi.streamflix.providers import com.tanasi.streamflix.adapters.AppAdapter import com.tanasi.streamflix.extractors.Extractor import com.tanasi.streamflix.extractors.MoflixExtractor +import com.tanasi.streamflix.extractors.MoviesapiExtractor import com.tanasi.streamflix.extractors.MyFileStorageExtractor import com.tanasi.streamflix.extractors.TwoEmbedExtractor import com.tanasi.streamflix.extractors.VidsrcNetExtractor @@ -803,6 +804,7 @@ object TmdbProvider : Provider { override suspend fun getServers(id: String, videoType: Video.Type): List { val servers = listOf( + MoviesapiExtractor().server(videoType), VidsrcNetExtractor().server(videoType), MyFileStorageExtractor().nowTvServer(videoType), MoflixExtractor().server(videoType),