Beispiel #1
0
        private void StartImport()
        {
            if (ImportRunning) return;

            if (string.IsNullOrEmpty(AppSettings.TraktUsername) || string.IsNullOrEmpty(AppSettings.TraktPassword))
            {
                UIUtils.UpdateStatus("You must enter in your trakt username and password!", true);
                return;
            }

            sites.Clear();

            // add import sites for processing
            sites.Add(new TMDb(AppSettings.TMDbRequestToken, AppSettings.TMDbSessionId));
            sites.Add(new TVDb(AppSettings.TVDbAccountIdentifier));
            sites.Add(new IMDb(AppSettings.IMDbFilename));

            if (sites.Where(s => s.Enabled).Count() == 0)
            {
                UIUtils.UpdateStatus("Incorrect site information supplied!", true);
                return;
            }

            #region Import
            Thread importThread = new Thread((o) =>
            {
                ImportRunning = true;

                // only one import at a time
                SetControlState(false);

                // Clear Progress
                ClearProgress();

                #region Login to trakt
                UIUtils.UpdateStatus("Logging in to trakt.tv...");
                var accountDetails = new TraktAuthentication { Username = AppSettings.TraktUsername, Password = AppSettings.TraktPassword };
                var response = TraktAPI.TraktAPI.TestAccount(accountDetails);
                //bool asdfx= Sites.Listal.ListalTest("e:\\test1.xml");
                if (response == null || response.Status != "success")
                {
                    UIUtils.UpdateStatus("Unable to login to trakt, check username and password!", true);
                    SetControlState(true);
                    ImportRunning = false;
                    ImportCancelled = false;
                    return;
                }
                #endregion

                // import ratings
                foreach (var site in sites.Where(s => s.Enabled))
                {
                    try
                    {
                        if (!ImportCancelled)
                            site.ImportRatings();
                    }
                    catch (Exception e)
                    {
                        UIUtils.UpdateStatus(string.Format("{0}:{1}", site.Name, e.Message), true);
                        Thread.Sleep(5000);
                    }
                }

                // finished
                SetControlState(true);
                UIUtils.UpdateStatus("Import Complete!");
                ImportRunning = false;
                ImportCancelled = false;
            });

            importThread.Start();
            #endregion
        }
Beispiel #2
0
 /// <summary>
 /// Tests account details can login to trakt.tv
 /// </summary>
 /// <param name="data">Object containing username/password</param>
 /// <returns>The response from trakt</returns>
 public static TraktResponse TestAccount(TraktAuthentication data)
 {
     string response = TraktWeb.Transmit(TraktURIs.TestAccount, data.ToJSON());
     return response.FromJSON<TraktResponse>();
 }
Beispiel #3
0
        private void StartImport()
        {
            // update file log with new name
            FileLog.LogFileName = DateTime.Now.ToString("yyyyMMdd_hhmmss") + ".log";

            if (ImportRunning) return;

            if (string.IsNullOrEmpty(AppSettings.TraktUsername) || string.IsNullOrEmpty(AppSettings.TraktPassword))
            {
                UIUtils.UpdateStatus("You must enter in your trakt username and password!", true);
                return;
            }

            sites.Clear();

            // add import sites for processing
            if (AppSettings.EnableTMDb)     sites.Add(new TMDb(AppSettings.TMDbRequestToken, AppSettings.TMDbSessionId));
            if (AppSettings.EnableTVDb)     sites.Add(new TVDb(AppSettings.TVDbAccountIdentifier));
            if (AppSettings.EnableIMDb)     sites.Add(new IMDb(AppSettings.IMDbRatingsFilename, AppSettings.IMDbWatchlistFilename, rdnImdbCSV.Checked));
            if (AppSettings.EnableIMDb)     sites.Add(new IMDbWeb(AppSettings.IMDbUsername, rdnImdbUsername.Checked));
            if (AppSettings.EnableListal)   sites.Add(new Listal(AppSettings.ListalMovieFilename, AppSettings.ListalShowFilename, AppSettings.ListalSyncWatchlist));
            if (AppSettings.EnableCriticker) sites.Add(new Criticker(AppSettings.CritickerMovieFilename));

            if (sites.Where(s => s.Enabled).Count() == 0)
            {
                UIUtils.UpdateStatus("No sites enabled or incorrect site information supplied!", true);
                return;
            }

            #region Import
            Thread importThread = new Thread((o) =>
            {
                ImportRunning = true;

                // only one import at a time
                SetControlState(false);

                // Clear Progress
                ClearProgress();

                #region Login to trakt
                UIUtils.UpdateStatus("Logging in to trakt.tv...");
                var accountDetails = new TraktAuthentication { Username = AppSettings.TraktUsername, Password = AppSettings.TraktPassword };
                var response = TraktAPI.TraktAPI.TestAccount(accountDetails);
                if (response == null || response.Status != "success")
                {
                    UIUtils.UpdateStatus("Unable to login to trakt, check username and password!", true);
                    SetControlState(true);
                    ImportRunning = false;
                    ImportCancelled = false;
                    return;
                }
                #endregion

                // import ratings
                foreach (var site in sites.Where(s => s.Enabled))
                {
                    UIUtils.UpdateStatus(string.Format("Starting import from {0}", site.Name));
                    try
                    {
                        if (!ImportCancelled)
                            site.ImportRatings();
                    }
                    catch (Exception e)
                    {
                        UIUtils.UpdateStatus(string.Format("{0}:{1}", site.Name, e.Message), true);
                        Thread.Sleep(5000);
                    }
                    UIUtils.UpdateStatus(string.Format("Finished import from {0}", site.Name));
                }

                // finished
                SetControlState(true);
                UIUtils.UpdateStatus("Import Complete!");
                ImportRunning = false;
                ImportCancelled = false;
            });

            importThread.Start();
            #endregion
        }