public void TestTraktShowsTrendingDefaultConstructor()
        {
            var trendingShow = new TraktTrendingShow();

            trendingShow.Watchers.Should().NotHaveValue();
            trendingShow.Show.Should().BeNull();
        }
        private TraktShowSync CreateSyncData(TraktTrendingShow 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);
        }
Example #3
0
        private void OnShowSelected(GUIListItem item, GUIControl parent)
        {
            TraktTrendingShow show = item.TVTag as TraktTrendingShow;

            PublishShowSkinProperties(show);
            GUIImageHandler.LoadFanart(backdrop, show.Images.FanartImageFilename);
        }
        public void Test_TraktTrendingShow_Default_Constructor()
        {
            var trendingShow = new TraktTrendingShow();

            trendingShow.Watchers.Should().NotHaveValue();

            trendingShow.Show.Should().BeNull();
            trendingShow.Title.Should().BeNullOrEmpty();
            trendingShow.Year.Should().NotHaveValue();
            trendingShow.Airs.Should().BeNull();
            trendingShow.AvailableTranslationLanguageCodes.Should().BeNull();
            trendingShow.Ids.Should().BeNull();
            trendingShow.Genres.Should().BeNull();
            trendingShow.Seasons.Should().BeNull();
            trendingShow.Overview.Should().BeNullOrEmpty();
            trendingShow.FirstAired.Should().NotHaveValue();
            trendingShow.Runtime.Should().NotHaveValue();
            trendingShow.Certification.Should().BeNullOrEmpty();
            trendingShow.Network.Should().BeNullOrEmpty();
            trendingShow.CountryCode.Should().BeNullOrEmpty();
            trendingShow.UpdatedAt.Should().NotHaveValue();
            trendingShow.Trailer.Should().BeNullOrEmpty();
            trendingShow.Homepage.Should().BeNullOrEmpty();
            trendingShow.Status.Should().BeNull();
            trendingShow.Rating.Should().NotHaveValue();
            trendingShow.Votes.Should().NotHaveValue();
            trendingShow.LanguageCode.Should().BeNullOrEmpty();
            trendingShow.AiredEpisodes.Should().NotHaveValue();
        }
Example #5
0
        /// <summary>
        /// Loads an Image from memory into a facade item
        /// </summary>
        /// <param name="imageFilePath">Filename of image</param>
        protected void SetImageToGui(string imageFilePath)
        {
            if (string.IsNullOrEmpty(imageFilePath))
            {
                return;
            }

            // determine the overlays to add to poster
            TraktTrendingShow show        = TVTag as TraktTrendingShow;
            MainOverlayImage  mainOverlay = MainOverlayImage.None;

            if (show.InWatchList)
            {
                mainOverlay = MainOverlayImage.Watchlist;
            }
            //else if (show.Watched)
            //    mainOverlay = MainOverlayImage.Seenit;

            RatingOverlayImage ratingOverlay = GUIImageHandler.GetRatingOverlay(show.RatingAdvanced);

            // get a reference to a MediaPortal Texture Identifier
            string suffix  = Enum.GetName(typeof(MainOverlayImage), mainOverlay) + Enum.GetName(typeof(RatingOverlayImage), ratingOverlay);
            string texture = GUIImageHandler.GetTextureIdentFromFile(imageFilePath, suffix);

            // build memory image
            Image memoryImage = null;

            if (mainOverlay != MainOverlayImage.None || ratingOverlay != RatingOverlayImage.None)
            {
                memoryImage = GUIImageHandler.DrawOverlayOnPoster(imageFilePath, mainOverlay, ratingOverlay);
                if (memoryImage == null)
                {
                    return;
                }

                // load texture into facade item
                if (GUITextureManager.LoadFromMemory(memoryImage, texture, 0, 0, 0) > 0)
                {
                    ThumbnailImage = texture;
                    IconImage      = texture;
                    IconImageBig   = texture;
                }
            }
            else
            {
                ThumbnailImage = imageFilePath;
                IconImage      = imageFilePath;
                IconImageBig   = imageFilePath;
            }

            // if selected and is current window force an update of thumbnail
            this.UpdateItemIfSelected((int)TraktGUIWindows.TrendingShows, ItemId);
        }
Example #6
0
        private void CheckAndPlayEpisode(bool jumpTo)
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktTrendingShow selectedShow = (TraktTrendingShow)selectedItem.TVTag;

            GUICommon.CheckAndPlayFirstUnwatched(selectedShow, jumpTo);
        }
Example #7
0
        public override async Task <ITraktTrendingShow> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktTrendingShow)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var showObjectReader = new ShowObjectJsonReader();
                ITraktTrendingShow traktTrendingShow = new TraktTrendingShow();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.TRENDING_SHOW_PROPERTY_NAME_WATCHERS:
                        traktTrendingShow.Watchers = await jsonReader.ReadAsInt32Async(cancellationToken);

                        break;

                    case JsonProperties.TRENDING_SHOW_PROPERTY_NAME_SHOW:
                        traktTrendingShow.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktTrendingShow);
            }

            return(await Task.FromResult(default(ITraktTrendingShow)));
        }
Example #8
0
 private void PublishShowSkinProperties(TraktTrendingShow show)
 {
     GUICommon.SetProperty("#Trakt.Show.Watchers", show.Watchers.ToString());
     GUICommon.SetProperty("#Trakt.Show.Watchers.Extra", show.Watchers > 1 ? string.Format(Translation.PeopleWatching, show.Watchers) : Translation.PersonWatching);
     GUICommon.SetShowProperties(show);
 }
Example #9
0
        protected override void OnShowContextMenu()
        {
            GUIListItem selectedItem = this.Facade.SelectedListItem;

            if (selectedItem == null)
            {
                return;
            }

            TraktTrendingShow selectedShow = (TraktTrendingShow)selectedItem.TVTag;

            IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);

            if (dlg == null)
            {
                return;
            }

            dlg.Reset();
            dlg.SetHeading(GUIUtils.PluginName());

            GUICommon.CreateTrendingShowsContextMenu(ref dlg, selectedShow, false);

            // Show Context Menu
            dlg.DoModal(GUIWindowManager.ActiveWindow);
            if (dlg.SelectedId < 0)
            {
                return;
            }

            switch (dlg.SelectedId)
            {
            case ((int)TrendingContextMenuItem.AddToWatchList):
                TraktHelper.AddShowToWatchList(selectedShow);
                selectedShow.InWatchList = true;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingShowsHideWatchlisted)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.ShowSeasonInfo):
                GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                break;

            case ((int)TrendingContextMenuItem.MarkAsWatched):
                GUICommon.MarkShowAsSeen(selectedShow);
                if (TraktSettings.TrendingShowsHideWatched)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.AddToLibrary):
                GUICommon.AddShowToLibrary(selectedShow);
                if (TraktSettings.TrendingShowsHideCollected)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.RemoveFromWatchList):
                TraktHelper.RemoveShowFromWatchList(selectedShow);
                selectedShow.InWatchList = false;
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                break;

            case ((int)TrendingContextMenuItem.AddToList):
                TraktHelper.AddRemoveShowInUserList(selectedShow.Title, selectedShow.Year.ToString(), selectedShow.Tvdb, false);
                break;

            case ((int)TrendingContextMenuItem.Filters):
                if (GUICommon.ShowTVShowFiltersMenu())
                {
                    UpdateButtonState();
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.Related):
                TraktHelper.ShowRelatedShows(selectedShow);
                break;

            case ((int)TrendingContextMenuItem.Trailers):
                GUICommon.ShowTVShowTrailersMenu(selectedShow);
                break;

            case ((int)TrendingContextMenuItem.Shouts):
                TraktHelper.ShowTVShowShouts(selectedShow);
                break;

            case ((int)TrendingContextMenuItem.Rate):
                GUICommon.RateShow(selectedShow);
                OnShowSelected(selectedItem, Facade);
                selectedShow.Images.NotifyPropertyChanged("PosterImageFilename");
                if (TraktSettings.TrendingShowsHideRated)
                {
                    LoadTrendingShows();
                }
                break;

            case ((int)TrendingContextMenuItem.ChangeLayout):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            case ((int)TrendingContextMenuItem.SearchWithMpNZB):
                string loadingParam = string.Format("search:{0}", selectedShow.Title);
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MpNZB, loadingParam);
                break;

            case ((int)TrendingContextMenuItem.SearchTorrent):
                string loadPar = selectedShow.Title;
                GUIWindowManager.ActivateWindow((int)ExternalPluginWindows.MyTorrents, loadPar);
                break;

            default:
                break;
            }

            base.OnShowContextMenu();
        }
Example #10
0
        protected override void OnClicked(int controlId, GUIControl control, Action.ActionType actionType)
        {
            // wait for any background action to finish
            if (GUIBackgroundTask.Instance.IsBusy)
            {
                return;
            }

            switch (controlId)
            {
            // Facade
            case (50):
                if (actionType == Action.ActionType.ACTION_SELECT_ITEM)
                {
                    if (TraktSettings.EnableJumpToForTVShows)
                    {
                        CheckAndPlayEpisode(true);
                    }
                    else
                    {
                        GUIListItem selectedItem = this.Facade.SelectedListItem;
                        if (selectedItem == null)
                        {
                            return;
                        }
                        TraktTrendingShow selectedShow = (TraktTrendingShow)selectedItem.TVTag;
                        GUIWindowManager.ActivateWindow((int)TraktGUIWindows.ShowSeasons, selectedShow.ToJSON());
                    }
                }
                break;

            // Layout Button
            case (2):
                CurrentLayout = GUICommon.ShowLayoutMenu(CurrentLayout);
                break;

            // Sort Button
            case (8):
                var newSortBy = GUICommon.ShowSortMenu(TraktSettings.SortByTrendingShows);
                if (newSortBy != null)
                {
                    if (newSortBy.Field != TraktSettings.SortByTrendingShows.Field)
                    {
                        TraktSettings.SortByTrendingShows = newSortBy;
                        PreviousSelectedIndex             = 0;
                        UpdateButtonState();
                        LoadTrendingShows();
                    }
                }
                break;

            // Hide Watched
            case (9):
                TraktSettings.TrendingShowsHideWatched = !TraktSettings.TrendingShowsHideWatched;
                UpdateButtonState();
                LoadTrendingShows();
                break;

            // Hide Watchlisted
            case (10):
                TraktSettings.TrendingShowsHideWatchlisted = !TraktSettings.TrendingShowsHideWatchlisted;
                UpdateButtonState();
                LoadTrendingShows();
                break;

            // Hide Collected
            case (11):
                TraktSettings.TrendingShowsHideCollected = !TraktSettings.TrendingShowsHideCollected;
                UpdateButtonState();
                LoadTrendingShows();
                break;

            // Hide Rated
            case (12):
                TraktSettings.TrendingShowsHideRated = !TraktSettings.TrendingShowsHideRated;
                UpdateButtonState();
                LoadTrendingShows();
                break;

            default:
                break;
            }
            base.OnClicked(controlId, control, actionType);
        }