Help with creating proper ITraktSyncHistoryPost containing Seasons for Sync.AddWatchedHistoryItemsAsync #218
-
|
Hello Henrik! I am still plugging away on my app and have run into a problem understanding PostBuilders and HistoryPosts. Would you be able to provide an example or documentation on how I should be doing this? public static async Task ChangeSeasonWatchedStatusInTraktAsync(bool watched, string watchedShow, int watchedSeason)
{
TraktResponse<ITraktSyncHistoryPostResponse> myHistoryAddResponse;
TraktResponse<ITraktSyncHistoryRemovePostResponse> myHistoryDelResponse;
MyTraktSeasonDB mySeasonFromDB = await SelectSeasonFromDBAsync(watchedShow, watchedSeason); // returns a cached season from my SQLite DB
TraktSeason[] seasonCollection = new TraktSeason[1]; // we only need one because we are only changing one season
seasonCollection[0] = new TraktSeason();
seasonCollection[0].Title = mySeasonFromDB.Title;
seasonCollection[0].Number = watchedSeason;
seasonCollection[0].Ids = new TraktSeasonIds { Trakt = mySeasonFromDB.IdsTrakt };
try
{
if (watched)
{
ITraktSyncHistoryPostBuilder postObject = TraktPost.NewSyncHistoryPost().WithShow(
new TraktShow
{
Ids = new TraktShowIds { Slug = watchedShow },
Seasons = seasonCollection
});
ITraktSyncHistoryPost myTraktSyncHistoryPost = new TraktSyncHistoryPost();
myTraktSyncHistoryPost = postObject.Build();
myHistoryAddResponse = await client.Sync.AddWatchedHistoryItemsAsync(myTraktSyncHistoryPost);
}
else … {remaining code}Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
To mark only specific seasons as watched, you can use For your example, this would look like this: ITraktSyncHistoryPost myTraktSyncHistoryPost = TraktPost.NewSyncHistoryPost().AddShowAndSeasons(
new TraktShow { Ids = new TraktShowIds { Slug = watchedShow } })
.WithSeasons(watchedSeason)
.Build();
myHistoryAddResponse = await client.Sync.AddWatchedHistoryItemsAsync(myTraktSyncHistoryPost); |
Beta Was this translation helpful? Give feedback.
To mark only specific seasons as watched, you can use
TraktPost.NewSyncHistoryPost().AddShowAndSeasons(show).WithSeasons(1, 3, 5).For your example, this would look like this: