-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tmdb-provider): implement Moviesapi server #195
- Loading branch information
1 parent
c42699c
commit 1f0d642
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
app/src/main/java/com/tanasi/streamflix/extractors/MoviesapiExtractor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters