private void RemoveShowFromWatchList(TraktWatchListShow show)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncShowWatchList(CreateSyncData(obj as TraktWatchListShow), TraktSyncModes.unwatchlist);
            })
            {
                IsBackground = true,
                Name = "Removing Show from Watch List"
            };

            syncThread.Start(show);
        }
        private void ShowTrailersMenu(TraktWatchListShow show)
        {
            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
            dlg.Reset();
            dlg.SetHeading(Translation.Trailer);

            foreach (TrailerSite site in Enum.GetValues(typeof(TrailerSite)))
            {
                string menuItem = Enum.GetName(typeof(TrailerSite), site);
                GUIListItem pItem = new GUIListItem(menuItem);
                dlg.Add(pItem);
            }

            dlg.DoModal(GUIWindowManager.ActiveWindow);

            if (dlg.SelectedLabel >= 0)
            {
                string siteUtil = string.Empty;
                string searchParam = string.Empty;

                switch (dlg.SelectedLabelText)
                {
                    case ("IMDb"):
                        siteUtil = "IMDb Movie Trailers";
                        if (!string.IsNullOrEmpty(show.Imdb))
                            // Exact search
                            searchParam = show.Imdb;
                        else
                            searchParam = show.Title;
                        break;

                    case ("YouTube"):
                        siteUtil = "YouTube";
                        searchParam = show.Title;
                        break;
                }

                string loadingParam = string.Format("site:{0}|search:{1}|return:Locked", siteUtil, searchParam);
                // Launch OnlineVideos Trailer search
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.OnlineVideos, loadingParam);
            }
        }
 private void PublishShowSkinProperties(TraktWatchListShow show)
 {
     GUICommon.SetProperty("#Trakt.Show.WatchList.Inserted", show.Inserted.FromEpoch().ToShortDateString());
     GUICommon.SetShowProperties(show);
 }
        private TraktShowSync CreateSyncData(TraktWatchListShow show)
        {
            if (show == null) return null;

            List<TraktShowSync.Show> shows = new List<TraktShowSync.Show>();

            TraktShowSync.Show syncShow = new TraktShowSync.Show
            {
                TVDBID = show.Tvdb,
                Title = show.Title,
                Year = show.Year
            };
            shows.Add(syncShow);

            TraktShowSync syncData = new TraktShowSync
            {
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password,
                Shows = shows
            };

            return syncData;
        }
        private void AddShowToWatchList(TraktWatchListShow show)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncShowWatchList(CreateSyncData(obj as TraktWatchListShow), TraktSyncModes.watchlist);
            })
            {
                IsBackground = true,
                Name = "Adding Show to Watch List"
            };

            syncThread.Start(show);
        }
        private void RateShow(TraktWatchListShow show)
        {
            TraktRateSeries rateObject = new TraktRateSeries
            {
                SeriesID = show.Tvdb,
                Title = show.Title,
                Year = show.Year.ToString(),
                Rating = show.Rating,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            string prevRating = show.Rating;
            show.Rating = GUIUtils.ShowRateDialog<TraktRateSeries>(rateObject);

            // if previous rating not equal to current rating then
            // update skin properties to reflect changes so we dont
            // need to re-request from server
            if (prevRating != show.Rating)
            {
                if (prevRating == "false")
                {
                    show.Ratings.Votes++;
                    if (show.Rating == "love")
                        show.Ratings.LovedCount++;
                    else
                        show.Ratings.HatedCount++;
                }

                if (prevRating == "love")
                {
                    show.Ratings.LovedCount--;
                    show.Ratings.HatedCount++;
                }

                if (prevRating == "hate")
                {
                    show.Ratings.LovedCount++;
                    show.Ratings.HatedCount--;
                }

                show.Ratings.Percentage = (int)Math.Round(100 * (show.Ratings.LovedCount / (float)show.Ratings.Votes));
            }
        }
 private void PublishShowSkinProperties(TraktWatchListShow show)
 {
     SetProperty("#Trakt.Show.AirDay", show.AirDay);
     SetProperty("#Trakt.Show.AirTime", show.AirTime);
     SetProperty("#Trakt.Show.Country", show.Country);
     SetProperty("#Trakt.Show.Network", show.Network);
     SetProperty("#Trakt.Show.TvRage", show.TvRage);
     SetProperty("#Trakt.Show.Imdb", show.Imdb);
     SetProperty("#Trakt.Show.Certification", show.Certification);
     SetProperty("#Trakt.Show.Overview", string.IsNullOrEmpty(show.Overview) ? Translation.NoShowSummary : show.Overview);
     SetProperty("#Trakt.Show.FirstAired", show.FirstAired.FromEpoch().ToShortDateString());
     SetProperty("#Trakt.Show.WatchList.Inserted", show.Inserted.FromEpoch().ToShortDateString());
     SetProperty("#Trakt.Show.InWatchList", show.InWatchList.ToString());
     SetProperty("#Trakt.Show.Runtime", show.Runtime.ToString());
     SetProperty("#Trakt.Show.Title", show.Title);
     SetProperty("#Trakt.Show.Url", show.Url);
     SetProperty("#Trakt.Show.Year", show.Year.ToString());
     SetProperty("#Trakt.Show.PosterImageFilename", show.Images.PosterImageFilename);
     SetProperty("#Trakt.Show.FanartImageFilename", show.Images.FanartImageFilename);
     SetProperty("#Trakt.Show.Rating", show.Rating);
     SetProperty("#Trakt.Show.Ratings.Icon", (show.Ratings.LovedCount > show.Ratings.HatedCount) ? "love" : "hate");
     SetProperty("#Trakt.Show.Ratings.HatedCount", show.Ratings.HatedCount.ToString());
     SetProperty("#Trakt.Show.Ratings.LovedCount", show.Ratings.LovedCount.ToString());
     SetProperty("#Trakt.Show.Ratings.Percentage", show.Ratings.Percentage.ToString());
     SetProperty("#Trakt.Show.Ratings.Votes", show.Ratings.Votes.ToString());
 }