diff --git a/CHANGELOG.md b/CHANGELOG.md index 4beefeee..07a6cf20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ Change Log ========== + +## next + +* Add `Sync.removePlayback(id)`. ## 6.14.0 _2024-07-12_ diff --git a/src/main/java/com/uwetrottmann/trakt5/services/Sync.java b/src/main/java/com/uwetrottmann/trakt5/services/Sync.java index 64c4553c..b9c57f6e 100644 --- a/src/main/java/com/uwetrottmann/trakt5/services/Sync.java +++ b/src/main/java/com/uwetrottmann/trakt5/services/Sync.java @@ -32,6 +32,7 @@ import com.uwetrottmann.trakt5.enums.RatingsFilter; import retrofit2.Call; import retrofit2.http.Body; +import retrofit2.http.DELETE; import retrofit2.http.GET; import retrofit2.http.POST; import retrofit2.http.Path; @@ -137,6 +138,18 @@ Call> getPlaybackMovies( @Query("limit") Integer limit ); + /** + * OAuth Required + *

+ * Remove a playback item from a user's playback progress list. A 404 will be returned if the id is invalid. + *

+ * Online documentation + */ + @DELETE("sync/playback/{id}") + Call removePlayback( + @Path("id") long id + ); + /** * OAuth Required * diff --git a/src/test/java/com/uwetrottmann/trakt5/services/SyncTest.java b/src/test/java/com/uwetrottmann/trakt5/services/SyncTest.java index dc0b2710..d1c657eb 100644 --- a/src/test/java/com/uwetrottmann/trakt5/services/SyncTest.java +++ b/src/test/java/com/uwetrottmann/trakt5/services/SyncTest.java @@ -83,8 +83,8 @@ public void test_lastActivites() throws IOException { @Test public void test_getPlayback() throws IOException, InterruptedException { // Make sure there are paused entries. - int agentsOfShield = 4420028; /* S01E01 */ - SyncEpisode episode = new SyncEpisode().id(EpisodeIds.tvdb(agentsOfShield)); + int agentsOfShield = 74005; /* S01E01 */ + SyncEpisode episode = new SyncEpisode().id(EpisodeIds.trakt(agentsOfShield)); ScrobbleProgress episodeProgress = new ScrobbleProgress(episode, 25.0, null, null); PlaybackResponse episodeResponse = executeCall(getTrakt().scrobble().pauseWatching(episodeProgress)); assertThat(episodeResponse.action).isEqualTo("pause"); @@ -109,8 +109,8 @@ public void test_getPlayback() throws IOException, InterruptedException { for (PlaybackResponse playback : playbacks) { assertThat(playback.type).isNotNull(); - if (playback.episode != null && playback.episode.ids != null && playback.episode.ids.tvdb != null - && playback.episode.ids.tvdb == agentsOfShield) { + if (playback.episode != null && playback.episode.ids != null && playback.episode.ids.trakt != null + && playback.episode.ids.trakt == agentsOfShield) { foundEpisode = true; assertThat(playback.paused_at).isNotNull(); assertThat(playback.progress).isEqualTo(25.0); @@ -124,10 +124,17 @@ public void test_getPlayback() throws IOException, InterruptedException { } } - if (!foundEpisode) //noinspection ResultOfMethodCallIgnored + if (!foundEpisode) { fail("Agents of Shield episode not paused."); - if (!foundMovie) //noinspection ResultOfMethodCallIgnored + } + if (!foundMovie) { fail("Interstellar movie not paused."); + } + + for (PlaybackResponse playback : playbacks) { + assertThat(playback.id).isNotNull(); + executeVoidCall(getTrakt().sync().removePlayback(playback.id)); + } } private void assertLastActivityMore(LastActivityMore activityMore) {