Пример #1
0
        private void StartSync()
        {
            SetSyncControlProperties(true);

            var syncThread = new Thread(() =>
            {
                if (TraktSettings.AccountStatus != ConnectionState.Connected)
                {
                    // stop sync
                    SetSyncControlProperties(false);
                    TraktSettings.AccountStatus = ConnectionState.Pending;
                    return;
                }

                TraktLogger.Info("Library and Playback Sync started for all enabled plugins");

                // get data from online and store in cache so its readily available for plugin sync
                // data will also be used in user activity feed on the dashboard
                if (!TraktCache.RefreshData())
                {
                    return;
                }

                foreach (var item in clbPlugins.CheckedItems)
                {
                    try
                    {
                        switch (item.ToString())
                        {
                        case "Moving Pictures":
                            var movingPictures = new MovingPictures(TraktSettings.MovingPictures);
                            movingPictures.SyncLibrary();
                            movingPictures.SyncProgress();
                            break;

                        case "MP-TVSeries":
                            var tvSeries = new TVSeries(TraktSettings.TVSeries);
                            tvSeries.SyncLibrary();
                            tvSeries.SyncProgress();
                            break;

                        case "My Videos":
                            var myVideos = new MyVideos(TraktSettings.MyVideos);
                            myVideos.SyncLibrary();
                            myVideos.SyncProgress();
                            break;

                        case "My Films":
                            var myFilms = new MyFilmsHandler(TraktSettings.MyFilms);
                            myFilms.SyncLibrary();
                            myFilms.SyncProgress();
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        TraktLogger.Error("Error synchronising library, Plugin = '{0}', Error = '{1}'", item.ToString(), ex.Message);
                        continue;
                    }
                }

                // save user activity cache
                TraktCache.Save();

                TraktLogger.Info("Library and Playback Sync completed for all enabled plugins");
                SetSyncControlProperties(false);

                if (SilentMode || AutoCloseAfterSync)
                {
                    CloseConfig();
                }
            })
            {
                Name         = "Sync",
                IsBackground = true
            };

            syncThread.Start();
        }
Пример #2
0
        void GUIWindowManager_Receivers(GUIMessage message)
        {
            // check event was fired from a trailer button
            // buttons allocated are 11899, 11900 and 11901
            if (message.SenderControlId < 11899 || message.SenderControlId > 11901)
            {
                return;
            }

            bool      isDetailsView    = true;
            MediaItem currentMediaItem = null;

            switch (message.Message)
            {
            case GUIMessage.MessageType.GUI_MSG_CLICKED:
                switch (GUIWindowManager.ActiveWindow)
                {
                case (int)ExternalPluginWindows.VideoFile:
                case (int)ExternalPluginWindows.VideoTitle:
                    VideoInfoHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                case (int)ExternalPluginWindows.VideoInfo:
                    VideoInfoHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 2);
                    break;

                case (int)ExternalPluginWindows.MovingPictures:
                    MovingPicturesHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 6 : 50);
                    break;

                case (int)ExternalPluginWindows.MyFilmsDetails:
                    MyFilmsHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 10000);
                    break;

                case (int)ExternalPluginWindows.ShowTimes:
                    ShowTimesHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 42 : 50);
                    break;

                case (int)ExternalPluginWindows.TVSeries:
                    MPTVSeriesHandler.GetCurrentMediaItem(out currentMediaItem);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt movie windows
                case (int)ExternalPluginWindows.TraktRecentAddedMovies:
                case (int)ExternalPluginWindows.TraktRecentWatchedMovies:
                case (int)ExternalPluginWindows.TraktRecommendationsMovies:
                case (int)ExternalPluginWindows.TraktRelatedMovies:
                case (int)ExternalPluginWindows.TraktSearchMovies:
                case (int)ExternalPluginWindows.TraktTrendingMovies:
                case (int)ExternalPluginWindows.TraktWatchedListMovies:
                case (int)ExternalPluginWindows.TraktPopularMovies:
                case (int)ExternalPluginWindows.TraktAnticipatedMovies:
                case (int)ExternalPluginWindows.TraktBoxOffice:
                case (int)ExternalPluginWindows.TraktPersonCreditMovies:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Movie);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt show windows
                case (int)ExternalPluginWindows.TraktRecommendationsShows:
                case (int)ExternalPluginWindows.TraktRelatedShows:
                case (int)ExternalPluginWindows.TraktTrendingShows:
                case (int)ExternalPluginWindows.TraktWatchedListShows:
                case (int)ExternalPluginWindows.TraktSearchShows:
                case (int)ExternalPluginWindows.TraktPopularShows:
                case (int)ExternalPluginWindows.TraktAnticipatedShows:
                case (int)ExternalPluginWindows.TraktPersonCreditShows:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Show);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt season windows
                case (int)ExternalPluginWindows.TraktShowSeasons:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Season);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt episode windows
                case (int)ExternalPluginWindows.TraktCalendar:
                case (int)ExternalPluginWindows.TraktRecentAddedEpisodes:
                case (int)ExternalPluginWindows.TraktRecentWatchedEpisodes:
                case (int)ExternalPluginWindows.TraktSearchEpisodes:
                case (int)ExternalPluginWindows.TraktSeasonEpisodes:
                case (int)ExternalPluginWindows.TraktWatchedListEpisodes:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.Episode);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                // trakt list window
                case (int)ExternalPluginWindows.TraktListItems:
                    TraktHandler.GetCurrentMediaItem(out currentMediaItem, TraktHandler.WindowType.List);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, 50);
                    break;

                case (int)ExternalPluginWindows.NetflixAlpha:
                    NetflixHandler.GetCurrentMediaItem(out currentMediaItem, out isDetailsView);
                    GUIControl.FocusControl(GUIWindowManager.ActiveWindow, isDetailsView ? 6 : 50);
                    break;
                }
                break;
            }

            if (currentMediaItem != null)
            {
                switch (currentMediaItem.MediaType)
                {
                case MediaItemType.Movie:
                    FileLog.Info("Searching for movie trailers on: Title='{0}', Year='{1}', IMDb='{2}', TMDb='{3}', Filename='{4}'", currentMediaItem.Title, currentMediaItem.Year.ToString(), currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>", currentMediaItem.FilenameWOExtension ?? "<empty>");
                    break;

                case MediaItemType.Show:
                    FileLog.Info("Searching for tv show trailers on: Title='{0}', Year='{1}', FirstAired='{2}', IMDb='{3}', TVDb='{4}', TMDb='{5}'", currentMediaItem.Title, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>");
                    break;

                case MediaItemType.Season:
                    FileLog.Info("Searching for tv season trailers on: Title='{0}', Season='{1}', Year='{2}', FirstAired='{3}', IMDb='{4}', TVDb='{5}', TMDb='{6}'", currentMediaItem.Title, currentMediaItem.Season, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>");
                    break;

                case MediaItemType.Episode:
                    FileLog.Info("Searching for tv episode trailers on: Title='{0}', Season='{1}', Episode='{2}', Year='{3}', FirstAired='{4}', IMDb='{5}', TVDb='{6}', TMDb='{7}', Filename='{8}'", currentMediaItem.Title, currentMediaItem.Season, currentMediaItem.Episode, currentMediaItem.Year.ToString(), currentMediaItem.AirDate ?? "<empty>", currentMediaItem.IMDb ?? "<empty>", currentMediaItem.TVDb ?? "<empty>", currentMediaItem.TMDb ?? "<empty>", currentMediaItem.FilenameWOExtension ?? "<empty>");
                    break;
                }

                SearchForTrailers(currentMediaItem);
            }
        }