-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathSync.java
More file actions
597 lines (551 loc) · 22.3 KB
/
Sync.java
File metadata and controls
597 lines (551 loc) · 22.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
/*
* Copyright 2024 Uwe Trottmann
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uwetrottmann.trakt5.services;
import com.uwetrottmann.trakt5.TraktV2;
import com.uwetrottmann.trakt5.entities.BaseMovie;
import com.uwetrottmann.trakt5.entities.BaseShow;
import com.uwetrottmann.trakt5.entities.HistoryEntry;
import com.uwetrottmann.trakt5.entities.LastActivities;
import com.uwetrottmann.trakt5.entities.PlaybackResponse;
import com.uwetrottmann.trakt5.entities.RatedEpisode;
import com.uwetrottmann.trakt5.entities.RatedMovie;
import com.uwetrottmann.trakt5.entities.RatedSeason;
import com.uwetrottmann.trakt5.entities.RatedShow;
import com.uwetrottmann.trakt5.entities.SyncItems;
import com.uwetrottmann.trakt5.entities.SyncResponse;
import com.uwetrottmann.trakt5.entities.UserSlug;
import com.uwetrottmann.trakt5.entities.WatchlistedEpisode;
import com.uwetrottmann.trakt5.entities.WatchlistedSeason;
import com.uwetrottmann.trakt5.enums.Extended;
import com.uwetrottmann.trakt5.enums.HistoryType;
import com.uwetrottmann.trakt5.enums.PlaybackType;
import com.uwetrottmann.trakt5.enums.RatingsFilter;
import org.threeten.bp.OffsetDateTime;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;
import javax.annotation.Nonnull;
import java.util.List;
public interface Sync {
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* This method is a useful first step in the syncing process. We recommended caching these dates locally, then you
* can compare to know exactly what data has changed recently. This can greatly optimize your syncs so you don't
* pull down a ton of data only to see nothing has actually changed.
*/
@GET("sync/last_activities")
Call<LastActivities> lastActivities();
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get all movies in a user's library (formerly collection). A collected item indicates availability to watch
* digitally or on physical media.
*
* @deprecated Use {@link #collectionMovies(int, int, Extended)} instead.
*/
@Deprecated
@GET("sync/collection/movies")
Call<List<BaseMovie>> collectionMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#collectionMovies(UserSlug, int, int, Extended)}.
*/
@GET("sync/collection/movies")
Call<List<BaseMovie>> collectionMovies(
@Query("page") int page,
@Query("limit") int limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get all shows in a user's library (formerly collection). A collected item indicates availability to watch
* digitally or on physical media.
*
* @deprecated Use {@link #collectionShows(int, int, Extended)} instead.
*/
@Deprecated
@GET("sync/collection/shows")
Call<List<BaseShow>> collectionShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#collectionShows(UserSlug, int, int, Extended)}.
*/
@GET("sync/collection/shows")
Call<List<BaseShow>> collectionShows(
@Query("page") int page,
@Query("limit") int limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Add one or more items to a user's library (formerly collection) including the format of the item.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/collection")
Call<SyncResponse> addItemsToCollection(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Remove one or more items from a user's library (formerly collection).
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/collection/remove")
Call<SyncResponse> deleteItemsFromCollection(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Returns all movies a user has watched.
*/
@GET("sync/watched/movies")
Call<List<BaseMovie>> watchedMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Whenever a scrobble is paused, the playback progress is saved. Use this progress to sync up playback across
* different media centers or apps. For example, you can start watching a movie in a media center, stop it, then
* resume on your tablet from the same spot. Each item will have the progress percentage between 0 and 100.
* <p>
* Use {@link #playback(PlaybackType, OffsetDateTime, OffsetDateTime, Integer, Integer)} to specify a type to only
* get movies or episodes.
* <p>
* By default, all results will be returned. Pagination is optional and can be used for something like an "on deck"
* feature, or if you only need a limited data set.
* <p>
* Note: Trakt only saves playback progress for the last 6 months.
*
* @see #playback(PlaybackType, OffsetDateTime, OffsetDateTime, Integer, Integer)
*/
@GET("sync/playback")
Call<List<PlaybackResponse>> playback(
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link #playback(OffsetDateTime, OffsetDateTime, Integer, Integer)}, but allows to specify a type to only
* get movies or episodes.
*
* @see #playback(OffsetDateTime, OffsetDateTime, Integer, Integer)
*/
@GET("sync/playback/{type}")
Call<List<PlaybackResponse>> playback(
@Path("type") PlaybackType type,
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Returns all playbacks;
*
* @deprecated Use {@link #playback(OffsetDateTime, OffsetDateTime, Integer, Integer)} instead.
*/
@Deprecated
@GET("sync/playback")
Call<List<PlaybackResponse>> getPlayback(
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Returns all playbacks;
*
* @deprecated Use {@link #playback(PlaybackType, OffsetDateTime, OffsetDateTime, Integer, Integer)} instead.
*/
@Deprecated
@GET("sync/playback/episodes")
Call<List<PlaybackResponse>> getPlaybackEpisodes(
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Returns all playbacks;
*
* @deprecated Use {@link #playback(PlaybackType, OffsetDateTime, OffsetDateTime, Integer, Integer)} instead.
*/
@Deprecated
@GET("sync/playback/movies")
Call<List<PlaybackResponse>> getPlaybackMovies(
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Remove a playback item from a user's playback progress list. A 404 will be returned if the id is invalid.
* <p>
* <a href="https://trakt.docs.apiary.io/#reference/sync/remove-playback/remove-a-playback-item">Online
* documentation</a>
*/
@DELETE("sync/playback/{id}")
Call<Void> removePlayback(
@Path("id") long id
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Returns all shows a user has watched.
*/
@GET("sync/watched/shows")
Call<List<BaseShow>> watchedShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#history(UserSlug, Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)}.
*
* @see Sync#history(HistoryType, Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)
*/
@GET("sync/history")
Call<List<HistoryEntry>> history(
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link #history(Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)}, but allows to set a type to
* only return movies or episodes.
*
* @see Users#history(UserSlug, HistoryType, Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)
* @see Sync#history(Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)
*/
@GET("sync/history/{type}")
Call<List<HistoryEntry>> history(
@Path("type") HistoryType type,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like
* {@link Users#history(UserSlug, HistoryType, int, Integer, Integer, Extended, OffsetDateTime, OffsetDateTime)}.
*/
@GET("sync/history/{type}/{id}")
Call<List<HistoryEntry>> history(
@Path("type") HistoryType type,
@Path("id") int id,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended,
@Query("start_at") OffsetDateTime startAt,
@Query("end_at") OffsetDateTime endAt
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Add items to a user's watch history. Accepts shows, seasons, episodes and movies. If only a show is passed,
* assumes all seasons are to be marked watched. Same for seasons. Send a <code>watched_at</code> UTC datetime to
* mark items as watched in the past. This is useful for syncing past watches from a media center.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/history")
Call<SyncResponse> addItemsToWatchedHistory(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Remove items from a user's watch history including all watches, scrobbles, and checkins. Accepts shows, seasons,
* episodes and movies. If only a show is passed, assumes all seasons are to be removed from history. Same for
* seasons.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/history/remove")
Call<SyncResponse> deleteItemsFromWatchedHistory(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get a user's ratings filtered by movies. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/movies{rating}")
Call<List<RatedMovie>> ratingsMovies(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get a user's ratings filtered by shows. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are not paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/shows{rating}")
Call<List<RatedShow>> ratingsShows(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get a user's ratings filtered by seasons. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/seasons{rating}")
Call<List<RatedSeason>> ratingsSeasons(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Get a user's ratings filtered by episodes. You can filter for a specific rating between 1 and 10.
*
* @param filter Filter for a specific rating.
* @param page Number of page of results to be returned. If {@code null} but {@code limit} is provided defaults to
* 1, otherwise items are paginated.
* @param limit Number of results to return per page. If {@code null} but {@code page} is provided defaults to 10,
* otherwise all items are returned.
*/
@GET("sync/ratings/episodes{rating}")
Call<List<RatedEpisode>> ratingsEpisodes(
@Path(value = "rating", encoded = true) RatingsFilter filter,
@Query(value = "extended", encoded = true) Extended extended,
@Query("page") Integer page,
@Query("limit") Integer limit
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Rate one or more items.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/ratings")
Call<SyncResponse> addRatings(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Delete ratings for one or more items.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/ratings/remove")
Call<SyncResponse> deleteRatings(
@Body SyncItems items
);
/**
* @deprecated Use {@link #watchlistMovies(Integer, Integer, Extended)} instead.
*/
@Deprecated
@GET("sync/watchlist/movies")
Call<List<BaseMovie>> watchlistMovies(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistMovies(UserSlug, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/movies")
Call<List<BaseMovie>> watchlistMovies(
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistMovies(UserSlug, String, String, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/movies/{sort_by}/{sort_how}")
Call<List<BaseMovie>> watchlistMovies(
@Nonnull @Path("sort_by") String sortBy,
@Nonnull @Path("sort_how") String sortHow,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* @deprecated Use {@link #watchlistShows(Integer, Integer, Extended)} instead.
*/
@Deprecated
@GET("sync/watchlist/shows")
Call<List<BaseShow>> watchlistShows(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistShows(UserSlug, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/shows")
Call<List<BaseShow>> watchlistShows(
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistShows(UserSlug, String, String, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/shows/{sort_by}/{sort_how}")
Call<List<BaseShow>> watchlistShows(
@Nonnull @Path("sort_by") String sortBy,
@Nonnull @Path("sort_how") String sortHow,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* @deprecated Use {@link #watchlistSeasons(Integer, Integer, Extended)} instead.
*/
@Deprecated
@GET("sync/watchlist/seasons")
Call<List<WatchlistedSeason>> watchlistSeasons(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistSeasons(UserSlug, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/seasons")
Call<List<WatchlistedSeason>> watchlistSeasons(
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistSeasons(UserSlug, String, String, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/seasons/{sort_by}/{sort_how}")
Call<List<WatchlistedSeason>> watchlistSeasons(
@Nonnull @Path("sort_by") String sortBy,
@Nonnull @Path("sort_how") String sortHow,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* @deprecated Use {@link #watchlistEpisodes(Integer, Integer, Extended)} instead.
*/
@Deprecated
@GET("sync/watchlist/episodes")
Call<List<WatchlistedEpisode>> watchlistEpisodes(
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistEpisodes(UserSlug, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/episodes")
Call<List<WatchlistedEpisode>> watchlistEpisodes(
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Like {@link Users#watchlistEpisodes(UserSlug, String, String, Integer, Integer, Extended)}.
*/
@GET("sync/watchlist/episodes/{sort_by}/{sort_how}")
Call<List<WatchlistedEpisode>> watchlistEpisodes(
@Nonnull @Path("sort_by") String sortBy,
@Nonnull @Path("sort_how") String sortHow,
@Query("page") Integer page,
@Query("limit") Integer limit,
@Query(value = "extended", encoded = true) Extended extended
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Add one of more items to a user's watchlist.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/watchlist")
Call<SyncResponse> addItemsToWatchlist(
@Body SyncItems items
);
/**
* <b>OAuth {@link TraktV2#accessToken(String) access token} required</b>
* <p>
* Delete one or more items from a user's watchlist.
*
* @param items A list of movies, shows, seasons or episodes.
*/
@POST("sync/watchlist/remove")
Call<SyncResponse> deleteItemsFromWatchlist(
@Body SyncItems items
);
}