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 @@ -25,4 +25,11 @@ class AnimeApi internal constructor(retrofit: Retrofit) {
2525 fun link (streamId : String ): LinkEndpoint {
2626 return LinkEndpoint (internalApi, streamId)
2727 }
28+
29+ /* *
30+ * Returns the respective endpoint.
31+ */
32+ fun vastLink (streamId : String ): VastLinkEndpoint {
33+ return VastLinkEndpoint (internalApi, streamId)
34+ }
2835}
Original file line number Diff line number Diff line change @@ -27,9 +27,13 @@ internal interface InternalApi {
2727 @Query(" language" ) language : AnimeLanguage ?
2828 ): ProxerCall <List <Stream >>
2929
30- @GET(" anime/link2 " )
30+ @GET(" anime/link " )
3131 fun link (
32- @Query(" id" ) id : String? ,
33- @Query(" adFlag" ) adFlag : Int?
32+ @Query(" id" ) id : String?
33+ ): ProxerCall <String >
34+
35+ @GET(" anime/linkvast" )
36+ fun vastLink (
37+ @Query(" id" ) id : String?
3438 ): ProxerCall <LinkContainer >
3539}
Original file line number Diff line number Diff line change @@ -2,8 +2,6 @@ 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
75
86/* *
97 * Endpoint for retrieving the link to the uploaded anime. This may be null, if the link is broken or has been deleted.
@@ -15,19 +13,9 @@ import me.proxer.library.internal.util.toIntOrNull
1513class LinkEndpoint internal constructor(
1614 private val internalApi : InternalApi ,
1715 private val id : String
18- ) : Endpoint<LinkContainer > {
16+ ) : Endpoint<String > {
1917
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())
18+ override fun build (): ProxerCall <String > {
19+ return internalApi.link(id)
3220 }
3321}
Original file line number Diff line number Diff line change 1+ package me.proxer.library.api.anime
2+
3+ import me.proxer.library.ProxerCall
4+ import me.proxer.library.api.Endpoint
5+ import me.proxer.library.entity.anime.LinkContainer
6+
7+ /* *
8+ * Endpoint similar to [LinkEndpoint], but additionally returns a VAST ad tag. This requires the highest authorization
9+ * level and should only be used by official applications.
10+ *
11+ * @author Ruben Gees
12+ */
13+ class VastLinkEndpoint internal constructor(
14+ private val internalApi : InternalApi ,
15+ private val id : String
16+ ) : Endpoint<LinkContainer> {
17+
18+ override fun build (): ProxerCall <LinkContainer > {
19+ return internalApi.vastLink(id)
20+ }
21+ }
Original file line number Diff line number Diff line change @@ -7,11 +7,10 @@ import com.squareup.moshi.JsonClass
77 * Entity representing a link to an anime.
88 *
99 * @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.
10+ * @property adTag The VAST tag of the ad to show. Is empty if no ad is available or none should be shown.
1211 */
1312@JsonClass(generateAdapter = true )
1413data class LinkContainer (
1514 @Json(name = " link" ) val link : String ,
16- @Json(name = " adFlag " ) val shouldShowAd : Boolean
15+ @Json(name = " adTag " ) val adTag : String
1716)
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
54import me.proxer.library.fromResource
65import okhttp3.mockwebserver.MockResponse
76import org.assertj.core.api.Assertions.assertThat
@@ -21,22 +20,17 @@ class LinkEndpointTest : ProxerTest() {
2120 .build()
2221 .execute()
2322
24- assertThat(result).isEqualTo(buildTestLink() )
23+ assertThat(result).isEqualTo(" //www.dailymotion.com/embed/video/k4D1tfdhKG " )
2524 }
2625
2726 @Test
2827 fun testPath () {
2928 server.enqueue(MockResponse ().setBody(fromResource(" link.json" )))
3029
3130 api.anime.link(" 13" )
32- .enableAds(true )
3331 .build()
3432 .execute()
3533
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 )
34+ assertThat(server.takeRequest().path).isEqualTo(" /api/v1/anime/link?id=13" )
4135 }
4236}
Original file line number Diff line number Diff line change 1+ package me.proxer.library.api.anime
2+
3+ import me.proxer.library.ProxerTest
4+ import me.proxer.library.entity.anime.LinkContainer
5+ import me.proxer.library.fromResource
6+ import okhttp3.mockwebserver.MockResponse
7+ import org.assertj.core.api.Assertions.assertThat
8+ import org.junit.jupiter.api.Test
9+
10+ class VastLinkEndpointTest : ProxerTest () {
11+
12+ @Test
13+ fun testDefault () {
14+ server.enqueue(MockResponse ().setBody(fromResource(" link_vast.json" )))
15+
16+ val result = api.anime
17+ .vastLink(" 4" )
18+ .build()
19+ .execute()
20+
21+ assertThat(result).isEqualTo(buildTestLinkContainer())
22+ }
23+
24+ @Test
25+ fun testPath () {
26+ server.enqueue(MockResponse ().setBody(fromResource(" link_vast.json" )))
27+
28+ api.anime.vastLink(" 9" )
29+ .build()
30+ .execute()
31+
32+ assertThat(server.takeRequest().path).isEqualTo(" /api/v1/anime/linkvast?id=9" )
33+ }
34+
35+ private fun buildTestLinkContainer (): LinkContainer {
36+ return LinkContainer (" //www.dailymotion.com/embed/video/k4D1tLdhKG" , " https://example.com" )
37+ }
38+ }
Original file line number Diff line number Diff line change 11{
22 "error" : 0 ,
33 "message" : " Abfrage erfolgreich" ,
4- "data" : {
5- "link" : " //www.dailymotion.com/embed/video/k4D1tfdhKG" ,
6- "adFlag" : true
7- }
4+ "data" : " //www.dailymotion.com/embed/video/k4D1tfdhKG"
85}
Original file line number Diff line number Diff line change 1+ {
2+ "error" : 0 ,
3+ "message" : " Abfrage erfolgreich" ,
4+ "data" : {
5+ "link" : " //www.dailymotion.com/embed/video/k4D1tLdhKG" ,
6+ "adTag" : " https://example.com"
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments