private void ClearGUIProperties()
 {
     TVSeriesPlugin.clearGUIProperty(guiProperty.Title.ToString());
     TVSeriesPlugin.clearGUIProperty(guiProperty.Subtitle.ToString());
     TVSeriesPlugin.clearGUIProperty(guiProperty.Description.ToString());
     TVSeriesPlugin.clearGUIProperty(guiProperty.Logos.ToString());
     TVSeriesPlugin.clearGUIProperty(guiProperty.EpisodeImage.ToString());
     TVSeriesPlugin.clearFieldsForskin("Episode");
 }
Exemple #2
0
        static public bool SubmitRating(RatingType type, string itemId, int rating)
        {
            string account = DBOption.GetOptions(DBOption.cOnlineUserID);

            if (String.IsNullOrEmpty(account))
            {
                string[] lines = new string[] { Translation.TVDB_INFO_ACCOUNTID_1, Translation.TVDB_INFO_ACCOUNTID_2 };
                //TVSeriesPlugin.ShowDialogOk(Translation.TVDB_INFO_TITLE, lines); //trakt.tv also listens to this, also can store ratings locally.
                MPTVSeriesLog.Write("Cannot submit rating to thetvdb.com, this requires your Account Identifier to be set.");
                return(false);
            }

            if (itemId == "0" || rating < 0 || rating > 10)
            {
                MPTVSeriesLog.Write("Cannot submit rating, invalid values...this is most likely a programming error");
                return(false);
            }

            if (!DBOnlineMirror.IsMirrorsAvailable)
            {
                // Server maybe available now.
                DBOnlineMirror.Init();
                if (!DBOnlineMirror.IsMirrorsAvailable)
                {
                    GUIDialogOK dlgOK = ( GUIDialogOK )GUIWindowManager.GetWindow(( int )GUIWindow.Window.WINDOW_DIALOG_OK);
                    dlgOK.SetHeading(Translation.TVDB_ERROR_TITLE);
                    if (!TVSeriesPlugin.IsNetworkAvailable)
                    {
                        string[] lines = new string[] { Translation.NETWORK_ERROR_UNAVAILABLE_1, Translation.NETWORK_ERROR_UNAVAILABLE_2 };
                        TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                    }
                    else
                    {
                        string[] lines = new string[] { Translation.TVDB_ERROR_UNAVAILABLE_1, Translation.TVDB_ERROR_UNAVAILABLE_2 };
                        TVSeriesPlugin.ShowDialogOk(Translation.TVDB_ERROR_TITLE, lines);
                    }

                    MPTVSeriesLog.Write("Cannot submit rating, the online database is unavailable");
                    return(false);
                }
            }
            // ok we're good
            MPTVSeriesLog.Write(string.Format("Submitting Rating of {2} for {0} {1}", type.ToString(), itemId, rating), MPTVSeriesLog.LogLevel.Debug);
            Generic(string.Format(apiURIs.SubmitRating, account, type.ToString(), itemId, rating), true, false, Format.NoExtension);
            return(true);
        }
        private void onFacadeItemSelected(GUIListItem item, GUIControl parent)
        {
            // if this is not a message from the facade, exit
            if (parent != m_Facade && parent != m_Facade.FilmstripLayout &&
                parent != m_Facade.ThumbnailLayout && parent != m_Facade.ListLayout &&
                parent != m_Facade.PlayListLayout)
            {
                return;
            }

            if (item == null || item.TVTag == null)
            {
                return;
            }

            DBEpisode episode = item.TVTag as DBEpisode;

            if (episode == null || prevSelectedEpisode == episode)
            {
                return;
            }

            if (item.IsPlayed)
            {
                episode[DBOnlineEpisode.cWatched] = true;
            }

            // Push properties to skin
            TVSeriesPlugin.setGUIProperty(guiProperty.Title.ToString(), FieldGetter.resolveDynString(m_sFormatEpisodeTitle, episode));
            TVSeriesPlugin.setGUIProperty(guiProperty.Subtitle.ToString(), FieldGetter.resolveDynString(m_sFormatEpisodeSubtitle, episode));
            TVSeriesPlugin.setGUIProperty(guiProperty.Description.ToString(), FieldGetter.resolveDynString(m_sFormatEpisodeMain, episode));
            TVSeriesPlugin.setGUIProperty(guiProperty.Logos.ToString(), localLogos.getLogos(ref episode, TVSeriesPlugin.logosHeight, TVSeriesPlugin.logosWidth));
            TVSeriesPlugin.setGUIProperty(guiProperty.EpisodeImage.ToString(), ImageAllocator.GetEpisodeImage(episode));
            GUIPropertyManager.SetProperty("#selectedthumb", ImageAllocator.GetEpisodeImage(episode));

            TVSeriesPlugin.pushFieldsToSkin(episode, "Episode");

            // Some strange issues with logos when using mouse and hovering over current item
            // Dont push properties next time if the same episode is selected
            prevSelectedEpisode = episode;
        }
Exemple #4
0
        private void LoadFacade(List <DBActor> actors)
        {
            // clear facade
            GUIControl.ClearControl(GetID, FacadeActors.GetID);

            // set number of actors property
            GUIPropertyManager.SetProperty("#itemcount", actors.Count().ToString());

            // notify user if no actors to display and backout of window
            if (actors.Count == 0)
            {
                SetProperty("NoActors", Translation.NoActors);
                TVSeriesPlugin.ShowNotifyDialog(Translation.Actors, Translation.NoActors);
                GUIWindowManager.ShowPreviousWindow();
            }

            // Add each actor to the list
            foreach (var actor in actors)
            {
                GUIActorListItem actorItem = new GUIActorListItem(actor.ToString());

                actorItem.Item            = actor;
                actorItem.IconImage       = "defaultActor.png";
                actorItem.IconImageBig    = "defaultActor.png";
                actorItem.ThumbnailImage  = "defaultActor.png";
                actorItem.OnItemSelected += OnActorSelected;
                Utils.SetDefaultIcons(actorItem);
                FacadeActors.Add(actorItem);
            }

            FacadeActors.SelectedListItemIndex = 0;

            // Download actor images async and set to facade
            GetImages(actors);

            // Set Facade Layout
            FacadeActors.CurrentLayout = (GUIFacadeControl.Layout)CurrentLayout;
            GUIControl.FocusControl(GetID, FacadeActors.GetID);
        }
        /// <summary>
        /// Notify user in GUI if an error state was returned from Trakt API
        /// </summary>
        public static void CheckTraktErrorAndNotify <T>(T response, bool notify)
        {
            var r = response as TraktResponse;

            if (r == null || r.Status == null)
            {
                return;
            }

            // check response error status
            if (r.Status != "success")
            {
                MPTVSeriesLog.Write("Trakt Error: {0}", r.Error);
                if (notify)
                {
                    TVSeriesPlugin.ShowNotifyDialog(Translation.TraktError, r.Error);
                }
            }
            else
            {
                // success
                MPTVSeriesLog.Write("Trakt Response: {0}", r.Message);
            }
        }
        protected void LoadPlayList(string strPlayList)
        {
            IPlayListIO loader = PlayListFactory.CreateIO(strPlayList);

            if (loader == null)
            {
                return;
            }
            PlayList playlist = new PlayList();

            if (!loader.Load(playlist, strPlayList))
            {
                TVSeriesPlugin.ShowDialogOk(Translation.Playlist, new string[] { GUILocalizeStrings.Get(477) });
                return;
            }

            playlistPlayer.CurrentPlaylistName = System.IO.Path.GetFileNameWithoutExtension(strPlayList);
            if (playlist.Count == 1 && playlistPlayer.PlaylistAutoPlay)
            {
                MPTVSeriesLog.Write(string.Format("GUITVSeriesPlaylist: play single playlist item - {0}", playlist[0].FileName));

                // If the file is an image file, it should be mounted before playing
                string filename = playlist[0].FileName;
                if (Helper.IsImageFile(filename))
                {
                    if (!GUIVideoFiles.MountImageFile(GUIWindowManager.ActiveWindow, filename, false))
                    {
                        return;
                    }
                }

                if (g_Player.Play(filename))
                {
                    if (MediaPortal.Util.Utils.IsVideo(filename))
                    {
                        g_Player.ShowFullScreenWindow();
                    }
                }
                return;
            }

            // clear current playlist
            playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Clear();

            // add each item of the playlist to the playlistplayer
            for (int i = 0; i < playlist.Count; ++i)
            {
                PlayListItem playListItem = playlist[i];
                playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Add(playListItem);
            }

            // if we got a playlist
            if (playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES).Count > 0)
            {
                playlist = playlistPlayer.GetPlaylist(PlayListType.PLAYLIST_TVSERIES);

                // autoshuffle on load
                if (playlistPlayer.PlaylistAutoShuffle)
                {
                    playlist.Shuffle();
                }

                // then get 1st item
                PlayListItem item = playlist[0];

                // and start playing it
                if (playlistPlayer.PlaylistAutoPlay)
                {
                    playlistPlayer.CurrentPlaylistType = PlayListType.PLAYLIST_TVSERIES;
                    playlistPlayer.Reset();
                    playlistPlayer.Play(0);
                }

                // and activate the playlist window if its not activated yet
                if (GetID == GUIWindowManager.ActiveWindow)
                {
                    GUIWindowManager.ActivateWindow(GetID);
                }
            }
        }