Inheritance: TraktPlugin.TraktAPI.DataStructures.TraktResponse
コード例 #1
0
        private void RemoveEpisodeFromLibrary(TraktCalendar.TraktEpisodes episode)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncEpisodeLibrary(CreateEpisodeSyncData(obj as TraktCalendar.TraktEpisodes), TraktSyncModes.unlibrary);
            })
            {
                IsBackground = true,
                Name = "Remove Episode From Library"
            };

            syncThread.Start(episode);
        }
コード例 #2
0
        private void PublishEpisodeSkinProperties(TraktCalendar.TraktEpisodes episode)
        {
            GUICommon.SetProperty("#Trakt.Calendar.Selected.Date", episode.Date);
            GUICommon.SetProperty("#selectedindex", episode.SelectedIndex);

            GUICommon.SetShowProperties(episode.Show);
            GUICommon.SetEpisodeProperties(episode.Episode);
        }
コード例 #3
0
 private void RateEpisode(TraktCalendar.TraktEpisodes episode)
 {
     GUICommon.RateEpisode(episode.Show, episode.Episode);
 }
コード例 #4
0
        private TraktShowSync CreateShowSyncData(TraktCalendar.TraktEpisodes episode)
        {
            List<TraktShowSync.Show> shows = new List<TraktShowSync.Show>();

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

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

            return syncData;
        }
コード例 #5
0
        private void MarkEpisodeAsWatched(TraktCalendar.TraktEpisodes episode)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncEpisodeLibrary(CreateEpisodeSyncData(obj as TraktCalendar.TraktEpisodes), TraktSyncModes.seen);
            })
            {
                IsBackground = true,
                Name = "Mark Episode as Watched"
            };

            syncThread.Start(episode);
        }
コード例 #6
0
        private void AddShowToWatchList(TraktCalendar.TraktEpisodes episode)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncShowWatchList(CreateShowSyncData(obj as TraktCalendar.TraktEpisodes), TraktSyncModes.watchlist);
            })
            {
                IsBackground = true,
                Name = "Adding Show to Watch List"
            };

            syncThread.Start(episode);
        }
コード例 #7
0
        private TraktEpisodeSync CreateEpisodeSyncData(TraktCalendar.TraktEpisodes episode)
        {
            List<TraktEpisodeSync.Episode> episodeList = new List<TraktEpisodeSync.Episode>();
            episodeList.Add(new TraktEpisodeSync.Episode { EpisodeIndex = episode.Episode.Number.ToString(), SeasonIndex = episode.Episode.Season.ToString() });

            TraktEpisodeSync syncData = new TraktEpisodeSync
            {
                EpisodeList = episodeList,
                IMDBID = episode.Show.Imdb,
                SeriesID = episode.Show.Tvdb,
                Title = episode.Show.Title,
                Year = episode.Show.Year.ToString(),
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            return syncData;
        }
コード例 #8
0
        private void RemoveEpisodeFromWatchList(TraktCalendar.TraktEpisodes episode)
        {
            Thread syncThread = new Thread(delegate(object obj)
            {
                TraktAPI.TraktAPI.SyncEpisodeWatchList(CreateEpisodeSyncData(obj as TraktCalendar.TraktEpisodes), TraktSyncModes.unwatchlist);
            })
            {
                IsBackground = true,
                Name = "Removing Episode from Watch List"
            };

            syncThread.Start(episode);
        }
コード例 #9
0
        private void ShowTrailersMenu(TraktCalendar.TraktEpisodes episodeItem)
        {
            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(episodeItem.Show.Imdb))
                            // Exact search
                            searchParam = episodeItem.Show.Imdb;
                        else
                            searchParam = episodeItem.Show.Title;
                        break;

                    case ("YouTube"):
                        siteUtil = "YouTube";
                        searchParam = episodeItem.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);
            }
        }
コード例 #10
0
        private void PublishEpisodeSkinProperties(TraktCalendar.TraktEpisodes episode)
        {
            SetProperty("#Trakt.Calendar.Selected.Date", episode.Date);
            SetProperty("#selectedindex", episode.SelectedIndex);

            SetProperty("#Trakt.Show.Imdb", episode.Show.Imdb);
            SetProperty("#Trakt.Show.Tvdb", episode.Show.Tvdb);
            SetProperty("#Trakt.Show.TvRage", episode.Show.TvRage);
            SetProperty("#Trakt.Show.Title", episode.Show.Title);
            SetProperty("#Trakt.Show.Url", episode.Show.Url);
            SetProperty("#Trakt.Show.AirDay", episode.Show.AirDay);
            SetProperty("#Trakt.Show.AirTime", episode.Show.AirTime);
            SetProperty("#Trakt.Show.Certification", episode.Show.Certification);
            SetProperty("#Trakt.Show.Country", episode.Show.Country);
            SetProperty("#Trakt.Show.FirstAired", episode.Show.FirstAired.FromEpoch().ToShortDateString());
            SetProperty("#Trakt.Show.Network", episode.Show.Network);
            SetProperty("#Trakt.Show.Overview", string.IsNullOrEmpty(episode.Show.Overview) ? Translation.NoShowSummary : episode.Show.Overview);
            SetProperty("#Trakt.Show.Runtime", episode.Show.Runtime.ToString());
            SetProperty("#Trakt.Show.Year", episode.Show.Year.ToString());
            SetProperty("#Trakt.Show.InWatchList", episode.Show.InWatchList.ToString());
            SetProperty("#Trakt.Show.Rating", episode.Show.Rating);
            SetProperty("#Trakt.Show.Ratings.Icon", (episode.Show.Ratings.LovedCount > episode.Show.Ratings.HatedCount) ? "love" : "hate");
            SetProperty("#Trakt.Show.Ratings.HatedCount", episode.Show.Ratings.HatedCount.ToString());
            SetProperty("#Trakt.Show.Ratings.LovedCount", episode.Show.Ratings.LovedCount.ToString());
            SetProperty("#Trakt.Show.Ratings.Percentage", episode.Show.Ratings.Percentage.ToString());
            SetProperty("#Trakt.Show.Ratings.Votes", episode.Show.Ratings.Votes.ToString());
            SetProperty("#Trakt.Show.FanartImageFilename", episode.Show.Images.FanartImageFilename);
            SetProperty("#Trakt.Episode.Number", episode.Episode.Number.ToString());
            SetProperty("#Trakt.Episode.Season", episode.Episode.Season.ToString());
            SetProperty("#Trakt.Episode.FirstAired", episode.Episode.FirstAired.FromEpoch().ToShortDateString());
            SetProperty("#Trakt.Episode.Title", string.IsNullOrEmpty(episode.Episode.Title) ? string.Format("{0} {1}", Translation.Episode, episode.Episode.Number.ToString()) : episode.Episode.Title);
            SetProperty("#Trakt.Episode.Url", episode.Episode.Url);
            SetProperty("#Trakt.Episode.Overview", string.IsNullOrEmpty(episode.Episode.Overview) ? Translation.NoEpisodeSummary : episode.Episode.Overview);
            SetProperty("#Trakt.Episode.Runtime", episode.Episode.Runtime.ToString());
            SetProperty("#Trakt.Episode.InWatchList", episode.Episode.InWatchList.ToString());
            SetProperty("#Trakt.Episode.InCollection", episode.Episode.InCollection.ToString());
            SetProperty("#Trakt.Episode.Plays", episode.Episode.Plays.ToString());
            SetProperty("#Trakt.Episode.Watched", (episode.Episode.Plays > 0).ToString());
            SetProperty("#Trakt.Episode.Rating", episode.Episode.Rating);
            SetProperty("#Trakt.Episode.Ratings.Icon", (episode.Episode.Ratings.LovedCount > episode.Episode.Ratings.HatedCount) ? "love" : "hate");
            SetProperty("#Trakt.Episode.Ratings.HatedCount", episode.Episode.Ratings.HatedCount.ToString());
            SetProperty("#Trakt.Episode.Ratings.LovedCount", episode.Episode.Ratings.LovedCount.ToString());
            SetProperty("#Trakt.Episode.Ratings.Percentage", episode.Episode.Ratings.Percentage.ToString());
            SetProperty("#Trakt.Episode.Ratings.Votes", episode.Episode.Ratings.Votes.ToString());
            SetProperty("#Trakt.Episode.EpisodeImageFilename", episode.Episode.Images.EpisodeImageFilename);
        }
コード例 #11
0
        private void RateEpisode(TraktCalendar.TraktEpisodes episode)
        {
            // default rating to love if not already set
            TraktRateEpisode rateObject = new TraktRateEpisode
            {
                SeriesID = episode.Show.Tvdb,
                Title = episode.Show.Title,
                Year = episode.Show.Year.ToString(),
                Episode = episode.Episode.Number.ToString(),
                Season = episode.Episode.Season.ToString(),
                Rating = episode.Episode.Rating,
                UserName = TraktSettings.Username,
                Password = TraktSettings.Password
            };

            string prevRating = episode.Episode.Rating;
            episode.Episode.Rating = GUIUtils.ShowRateDialog<TraktRateEpisode>(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 != episode.Episode.Rating)
            {
                if (prevRating == "false")
                {
                    episode.Episode.Ratings.Votes++;
                    if (episode.Episode.Rating == "love")
                        episode.Episode.Ratings.LovedCount++;
                    else
                        episode.Episode.Ratings.HatedCount++;
                }

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

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

                episode.Episode.Ratings.Percentage = (int)Math.Round(100 * (episode.Episode.Ratings.LovedCount / (float)episode.Episode.Ratings.Votes));
            }
        }
コード例 #12
0
 private void PublishCalendarSkinProperties(TraktCalendar calendarItem)
 {
     GUICommon.SetShowProperties(calendarItem.Show);
     GUICommon.SetEpisodeProperties(calendarItem.Show, calendarItem.Episode);
 }