Ejemplo n.º 1
0
        private static WatchedAuth createWatchedAuth(String imdbID, String title, Int16 year)
        {
            WatchedAuth auth = new WatchedAuth();

            auth.Movies            = new TraktMovieRequest[1];
            auth.Movies[0]         = new TraktMovieRequest();
            auth.Movies[0].imdb_id = imdbID;
            auth.Movies[0].Title   = title;
            auth.Movies[0].year    = year;
            auth.Movies[0].Plays   = 1;
            DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            auth.Movies[0].LastPlayed = (long)(DateTime.UtcNow - UnixEpoch).TotalSeconds;

            return(auth);
        }
Ejemplo n.º 2
0
        private void SeenMovie_Click(object sender, RoutedEventArgs e)
        {
            lastModel = (ListItemViewModel)((MenuItem)sender).DataContext;
            var seenClient = new WebClient();

            seenClient.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadMovieSeenStringCompleted);
            WatchedAuth auth = new WatchedAuth();

            auth.Movies            = new TraktMovieRequest[1];
            auth.Movies[0]         = new TraktMovieRequest();
            auth.Movies[0].imdb_id = lastModel.Imdb;
            auth.Movies[0].Title   = lastModel.Name;
            auth.Movies[0].year    = Int16.Parse(lastModel.SubItemText);
            auth.Movies[0].Plays   = 1;

            DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            auth.Movies[0].LastPlayed = (long)(DateTime.UtcNow - UnixEpoch).TotalSeconds;

            seenClient.UploadStringAsync(new Uri("https://api.trakt.tv/movie/seen/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(WatchedAuth), auth));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Unmarks a movie as seen through URL https://api.trakt.tv/movie/unseen/[KEY]
        /// </summary>
        /// <param name="IMDBID">The IMDBID of the movie.</param>
        /// <param name="title">The name of the movie. (Attribute is title on trakt.tv).</param>
        /// <param name="year">The year the movie premiered.</param>
        /// <returns>
        /// If the movie was successfully unmarked as seen on trakt.tv, it will return TRUE. If it
        /// fails FALSE will be returned.
        /// </returns>
        internal async Task <Boolean> unMarkMovieAsSeen(String IMDBID, String title, Int16 year)
        {
            try
            {
                WebClient   watchlistClient = new WebClient();
                WatchedAuth auth            = createWatchedAuth(IMDBID, title, year);
                String      jsonString      = await watchlistClient.UploadStringTaskAsync(new Uri("https://api.trakt.tv/movie/unseen/9294cac7c27a4b97d3819690800aa2fedf0959fa"), AppUser.createJsonStringForAuthentication(typeof(WatchedAuth), auth));

                TraktMovie movie = await getMovieByIMDB(IMDBID);

                movie.Watched = false;

                return(saveMovie(movie));
            }
            catch (WebException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("WebException in unMarkMovieAsSeen(" + IMDBID + ", " + title + ").", false); }
            catch (TargetInvocationException)
            { GoogleAnalytics.EasyTracker.GetTracker().SendException("TargetInvocationException in unMarkMovieAsSeen(" + IMDBID + ", " + title + ").", false); }

            return(false);
        }