@@ -66,7 +66,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
66
66
with (json) {
67
67
authClient.newCall(
68
68
POST (
69
- " ${ BASE_URL } library-entries " ,
69
+ LIBRARY_URL ,
70
70
headers = headersOf(
71
71
" Content-Type" ,
72
72
" application/vnd.api+json" ,
@@ -104,7 +104,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
104
104
with (json) {
105
105
authClient.newCall(
106
106
Request .Builder ()
107
- .url(" ${BASE_URL } library-entries /${track.remote_id} " )
107
+ .url(" ${LIBRARY_URL } /${track.remote_id} " )
108
108
.headers(
109
109
headersOf(
110
110
" Content-Type" ,
@@ -130,7 +130,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
130
130
authClient
131
131
.newCall(
132
132
DELETE (
133
- " ${BASE_URL } library-entries /${track.remoteId} " ,
133
+ " ${LIBRARY_URL } /${track.remoteId} " ,
134
134
headers = headersOf(
135
135
" Content-Type" ,
136
136
" application/vnd.api+json" ,
@@ -143,7 +143,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
143
143
suspend fun search (query : String ): List <TrackSearch > {
144
144
return withIOContext {
145
145
with (json) {
146
- authClient.newCall(GET (ALGOLIA_KEY_URL ))
146
+ authClient.newCall(GET (BASE_ALGOLIA_KEY_URL ))
147
147
.awaitSuccess()
148
148
.parseAs<JsonObject >()
149
149
.let {
@@ -163,7 +163,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
163
163
with (json) {
164
164
client.newCall(
165
165
POST (
166
- ALGOLIA_URL ,
166
+ BASE_ALGOLIA_URL ,
167
167
headers = headersOf(
168
168
" X-Algolia-Application-Id" ,
169
169
ALGOLIA_APP_ID ,
@@ -177,17 +177,17 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
177
177
.parseAs<JsonObject >()
178
178
.let {
179
179
it[" hits" ]!! .jsonArray
180
- .map { KitsuSearchManga (it.jsonObject) }
181
- .filter { it.subType != " novel" }
182
- .map { it.toTrack() }
180
+ .map { it -> KitsuSearchManga (it.jsonObject) }
181
+ .filter { it -> it .subType != " novel" }
182
+ .map { it -> it .toTrack() }
183
183
}
184
184
}
185
185
}
186
186
}
187
187
188
188
suspend fun findLibManga (track : Track , userId : String ): Track ? {
189
189
return withIOContext {
190
- val url = " ${ BASE_URL } library-entries " .toUri().buildUpon()
190
+ val url = LIBRARY_URL .toUri().buildUpon()
191
191
.encodedQuery(" filter[manga_id]=${track.remote_id} &filter[user_id]=$userId " )
192
192
.appendQueryParameter(" include" , " manga" )
193
193
.build()
@@ -210,7 +210,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
210
210
211
211
suspend fun getLibManga (track : Track ): Track {
212
212
return withIOContext {
213
- val url = " ${ BASE_URL } library-entries " .toUri().buildUpon()
213
+ val url = LIBRARY_URL .toUri().buildUpon()
214
214
.encodedQuery(" filter[id]=${track.remote_id} " )
215
215
.appendQueryParameter(" include" , " manga" )
216
216
.build()
@@ -250,7 +250,7 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
250
250
251
251
suspend fun getCurrentUser (): String {
252
252
return withIOContext {
253
- val url = " ${ BASE_URL } users " .toUri().buildUpon()
253
+ val url = USERS_URL .toUri().buildUpon()
254
254
.encodedQuery(" filter[self]=true" )
255
255
.build()
256
256
with (json) {
@@ -270,12 +270,14 @@ class KitsuApi(private val client: OkHttpClient, interceptor: KitsuInterceptor)
270
270
private const val CLIENT_SECRET =
271
271
" 54d7307928f63414defd96399fc31ba847961ceaecef3a5fd93144e960c0e151"
272
272
273
- private const val BASE_URL = " https://kitsu.io/api/edge/"
274
- private const val LOGIN_URL = " https://kitsu.io/api/oauth/token"
275
- private const val BASE_MANGA_URL = " https://kitsu.io/manga/"
276
- private const val ALGOLIA_KEY_URL = " https://kitsu.io/api/edge/algolia-keys/media/"
273
+ private const val BASE_URL = " https://kitsu.io"
274
+ private const val LIBRARY_URL = " ${BASE_URL } /api/edge/library-entries"
275
+ private const val USERS_URL = " ${BASE_URL } /api/edge/users"
276
+ private const val LOGIN_URL = " ${BASE_URL } /api/oauth/token"
277
+ private const val BASE_MANGA_URL = " ${BASE_URL } /manga/"
278
+ private const val BASE_ALGOLIA_KEY_URL = " ${BASE_URL } /api/edge/algolia-keys/media/"
277
279
278
- private const val ALGOLIA_URL =
280
+ private const val BASE_ALGOLIA_URL =
279
281
" https://AWQO5J657S-dsn.algolia.net/1/indexes/production_media/query/"
280
282
private const val ALGOLIA_APP_ID = " AWQO5J657S"
281
283
private const val ALGOLIA_FILTER =
0 commit comments