File tree Expand file tree Collapse file tree
main/kotlin/me/proxer/library
kotlin/me/proxer/library/api/anime Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package me.proxer.library.api.anime
22
33import me.proxer.library.ProxerCall
4+ import me.proxer.library.entity.anime.LinkContainer
45import me.proxer.library.entity.anime.Stream
56import me.proxer.library.enums.AnimeLanguage
67import retrofit2.http.GET
@@ -26,6 +27,9 @@ internal interface InternalApi {
2627 @Query(" language" ) language : AnimeLanguage ?
2728 ): ProxerCall <List <Stream >>
2829
29- @GET(" anime/link" )
30- fun link (@Query(" id" ) id : String? ): ProxerCall <String >
30+ @GET(" anime/link2" )
31+ fun link (
32+ @Query(" id" ) id : String? ,
33+ @Query(" adFlag" ) adFlag : Int?
34+ ): ProxerCall <LinkContainer >
3135}
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ package me.proxer.library.api.anime
22
33import me.proxer.library.ProxerCall
44import me.proxer.library.api.Endpoint
5+ import me.proxer.library.entity.anime.LinkContainer
6+ import me.proxer.library.internal.util.toIntOrNull
57
68/* *
79 * Endpoint for retrieving the link to the uploaded anime. This may be null, if the link is broken or has been deleted.
@@ -13,9 +15,19 @@ import me.proxer.library.api.Endpoint
1315class LinkEndpoint internal constructor(
1416 private val internalApi : InternalApi ,
1517 private val id : String
16- ) : Endpoint<String > {
18+ ) : Endpoint<LinkContainer > {
1719
18- override fun build (): ProxerCall <String > {
19- return internalApi.link(id)
20+ private var enableAds: Boolean? = null
21+
22+ /* *
23+ * Sets if the ad system of Proxer is supported and should be enabled.
24+ * Requires a special permission from the administration.
25+ */
26+ fun enableAds (enableAds : Boolean? = false) = this .apply {
27+ this .enableAds = enableAds
28+ }
29+
30+ override fun build (): ProxerCall <LinkContainer > {
31+ return internalApi.link(id, enableAds.toIntOrNull())
2032 }
2133}
Original file line number Diff line number Diff line change 1+ package me.proxer.library.entity.anime
2+
3+ import com.squareup.moshi.Json
4+ import com.squareup.moshi.JsonClass
5+
6+ /* *
7+ * Entity representing a link to an anime.
8+ *
9+ * @property link The actual link. This does point to the HTML embed and not the video itself.
10+ * @property shouldShowAd If an ad should be shown for this stream. This is part of the Proxers ad system and needs
11+ * special permission to use.
12+ */
13+ @JsonClass(generateAdapter = true )
14+ data class LinkContainer (
15+ @Json(name = " link" ) val link : String ,
16+ @Json(name = " adFlag" ) val shouldShowAd : Boolean
17+ )
Original file line number Diff line number Diff line change 11package me.proxer.library.api.anime
22
33import me.proxer.library.ProxerTest
4+ import me.proxer.library.entity.anime.LinkContainer
45import me.proxer.library.fromResource
56import okhttp3.mockwebserver.MockResponse
67import org.assertj.core.api.Assertions.assertThat
@@ -20,17 +21,22 @@ class LinkEndpointTest : ProxerTest() {
2021 .build()
2122 .execute()
2223
23- assertThat(result).isEqualTo(" //www.dailymotion.com/embed/video/k4D1tfdhKG " )
24+ assertThat(result).isEqualTo(buildTestLink() )
2425 }
2526
2627 @Test
2728 fun testPath () {
2829 server.enqueue(MockResponse ().setBody(fromResource(" link.json" )))
2930
3031 api.anime.link(" 13" )
32+ .enableAds(true )
3133 .build()
3234 .execute()
3335
34- assertThat(server.takeRequest().path).isEqualTo(" /api/v1/anime/link?id=13" )
36+ assertThat(server.takeRequest().path).isEqualTo(" /api/v1/anime/link2?id=13&adFlag=1" )
37+ }
38+
39+ private fun buildTestLink (): LinkContainer {
40+ return LinkContainer (" //www.dailymotion.com/embed/video/k4D1tfdhKG" , true )
3541 }
3642}
Original file line number Diff line number Diff line change 11{
22 "error" : 0 ,
33 "message" : " Abfrage erfolgreich" ,
4- "data" : " //www.dailymotion.com/embed/video/k4D1tfdhKG"
4+ "data" : {
5+ "link" : " //www.dailymotion.com/embed/video/k4D1tfdhKG" ,
6+ "adFlag" : true
7+ }
58}
You can’t perform that action at this time.
0 commit comments