Example #1
0
        private void lnkTMDbStart_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (!string.IsNullOrEmpty(AppSettings.TMDbRequestToken) || !string.IsNullOrEmpty(AppSettings.TMDbSessionId))
            {
                AppSettings.TMDbRequestToken = string.Empty;
                AppSettings.TMDbSessionId    = string.Empty;
                SetTMDbControlState();
                return;
            }

            Thread tokenThread = new Thread(o =>
            {
                // store token and parse into tmdb object later
                // for request session id
                string requestToken = TMDb.RequestToken();

                if (!string.IsNullOrEmpty(requestToken))
                {
                    TMDb.RequestAuthorization(requestToken);
                    AppSettings.TMDbRequestToken = requestToken;
                    SetTMDbControlState();
                }
            });

            tokenThread.Start();
        }
Example #2
0
 static void Main(string[] args)
 {
     try
     {
         SqlConnection connection = new SqlConnection(Properties.Settings.Default.connectionString);
         TMDb db = new TMDb();
         var moviesTask = db.GetPopularMovies(CancellationToken.None, 10);
         //var moviesTask = db.GetComingSoonMovies(CancellationToken.None);
         //var moviesTask = db.GetMovies(CancellationToken.None);
         //var moviesTask = db.GetMoviesSimilarTo(CancellationToken.None, "Saw");
         Task.WaitAll(moviesTask);
         List<Movie> movies = moviesTask.Result;
         DbEntity.ProcessMovieResponse(movies, connection);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
     Console.WriteLine("Press <Enter> to continue...");
     Console.Read();
 }
        /// <summary>
        /// Handles the Click event of the searchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void SearchButtonOnClick(object sender, RoutedEventArgs e)
        {
            if (!_loaded || _sidx == database.SelectedIndex)
            {
                return;
            }

            database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = false;

            Guide guide;

            switch (database.SelectedIndex)
            {
            case 1:
                guide = new TVRage();
                break;

            case 2:
                guide = new TVDB();
                break;

            case 3:
                guide = new TMDb();
                break;

            case 4:
                guide = new Freebase();
                break;

            case 5:
                guide = new TVcom();
                break;

            case 6:
                guide = new EPisodeWorld();
                break;

            case 7:
                guide = new IMDb();
                break;

            case 8:
                guide = new AniDB();
                break;

            case 9:
                guide = new AnimeNewsNetwork();
                break;

            case 11:
                guide = new EPGuides();
                break;

            case 12:
                guide = new EPGuides();
                break;

            default:
                database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                return;
            }

            new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) =>
            {
                if (id == null)
                {
                    Dispatcher.Invoke((Action)(() =>
                    {
                        switch (Database.TVShows[_id].Source)
                        {
                        case "TVRage":
                            database.SelectedIndex = 1;
                            break;

                        case "TVDB":
                            database.SelectedIndex = 2;
                            break;

                        case "TMDb":
                            database.SelectedIndex = 3;
                            break;

                        case "Freebase":
                            database.SelectedIndex = 4;
                            break;

                        case "TVcom":
                            database.SelectedIndex = 5;
                            break;

                        case "EPisodeWorld":
                            database.SelectedIndex = 6;
                            break;

                        case "IMDb":
                            database.SelectedIndex = 7;
                            break;

                        case "AniDB":
                            database.SelectedIndex = 8;
                            break;

                        case "AnimeNewsNetwork":
                            database.SelectedIndex = 9;
                            break;

                        case "EPGuides":
                            database.SelectedIndex = 12;
                            break;
                        }

                        database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                    }));

                    TaskDialog.Show(new TaskDialogOptions
                    {
                        MainIcon        = VistaTaskDialogIcon.Error,
                        Title           = "Not found",
                        MainInstruction = _show,
                        Content         = "The currently set show title was not found on the selected guide.\r\nYour selection will be reverted. Try editing the official title.",
                        CustomButtons   = new[] { "OK" }
                    });
                }
                else
                {
                    _newSource = guide.GetType().Name;
                    _newSID    = id;
                    _newLang   = lang;

                    _change = _upReq = true;

                    Dispatcher.Invoke((Action)(() =>
                    {
                        nameTextBox.Text = title;
                        _sidx = database.SelectedIndex;

                        database.IsEnabled = language.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                    }));

                    TaskDialog.Show(new TaskDialogOptions
                    {
                        MainIcon        = VistaTaskDialogIcon.Information,
                        Title           = "Modified",
                        MainInstruction = _show,
                        Content         = "The guide was successfully changed!\r\nAn update will be initiated to this TV show after you click Save.",
                        CustomButtons   = new[] { "OK" }
                    });
                }
            });
        }
        /// <summary>
        /// Handles the Click event of the searchButton control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        private void SearchButtonOnClick(object sender, RoutedEventArgs e)
        {
            if (!_loaded || _sidx == database.SelectedIndex)
            {
                return;
            }

            database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = false;

            Guide guide;
            switch (database.SelectedIndex)
            {
                case 1:
                    guide = new TVDB();
                    break;

                case 2:
                    guide = new TVmaze();
                    break;

                case 3:
                    guide = new TMDb();
                    break;

                case 4:
                    guide = new TVRage();
                    break;

                case 5:
                    guide = new Freebase();
                    break;

                case 6:
                    guide = new TVcom();
                    break;

                case 7:
                    guide = new EPisodeWorld();
                    break;

                case 8:
                    guide = new IMDb();
                    break;

                case 9:
                    guide = new AniDB();
                    break;

                case 10:
                    guide = new AnimeNewsNetwork();
                    break;

                case 12:
                    guide = new EPGuides();
                    break;

                case 13:
                    guide = new EPGuides();
                    break;

                default:
                    database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                    return;
            }

            new ShowGuideTaskDialog().Search(guide, nameTextBox.Text, (language.SelectedItem as StackPanel).Tag as string, (id, title, lang) =>
                {
                    if (id == null)
                    {
                        Dispatcher.Invoke((Action)(() =>
                            {
                                switch (Database.TVShows[_id].Source)
                                {
                                    case "TVDB":
                                        database.SelectedIndex = 1;
                                        break;

                                    case "TVmaze":
                                        database.SelectedIndex = 2;
                                        break;

                                    case "TMDb":
                                        database.SelectedIndex = 3;
                                        break;

                                    case "TVRage":
                                        database.SelectedIndex = 4;
                                        break;

                                    case "Freebase":
                                        database.SelectedIndex = 5;
                                        break;

                                    case "TVcom":
                                        database.SelectedIndex = 6;
                                        break;

                                    case "EPisodeWorld":
                                        database.SelectedIndex = 7;
                                        break;

                                    case "IMDb":
                                        database.SelectedIndex = 8;
                                        break;

                                    case "AniDB":
                                        database.SelectedIndex = 9;
                                        break;

                                    case "AnimeNewsNetwork":
                                        database.SelectedIndex = 10;
                                        break;

                                    case "EPGuides":
                                        database.SelectedIndex = 13;
                                        break;
                                }

                                database.IsEnabled = language.IsEnabled = searchButton.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                            }));

                        TaskDialog.Show(new TaskDialogOptions
                            {
                                MainIcon        = VistaTaskDialogIcon.Error,
                                Title           = "Not found",
                                MainInstruction = _show,
                                Content         = "The currently set show title was not found on the selected guide.\r\nYour selection will be reverted. Try editing the official title.",
                                CustomButtons   = new[] { "OK" }
                            });
                    }
                    else
                    {
                        _newSource = guide.GetType().Name;
                        _newSID    = id;
                        _newLang   = lang;
                        
                        _change = _upReq = true;

                        Dispatcher.Invoke((Action)(() =>
                            {
                                nameTextBox.Text = title;
                                _sidx = database.SelectedIndex;

                                database.IsEnabled = language.IsEnabled = saveButton.IsEnabled = cancelButton.IsEnabled = nameTextBox.IsEnabled = true;
                            }));

                        TaskDialog.Show(new TaskDialogOptions
                            {
                                MainIcon        = VistaTaskDialogIcon.Information,
                                Title           = "Modified",
                                MainInstruction = _show,
                                Content         = "The guide was successfully changed!\r\nAn update will be initiated to this TV show after you click Save.",
                                CustomButtons   = new[] { "OK" }
                            });
                    }
                });
        }
 public HomeController(ILogger <HomeController> logger, MyDBContext context)
 {
     _logger = logger;
     db      = new TMDb(context);
 }