Exemplo n.º 1
0
        internal virtual void FillFrom(IMDbTitle dto)
        {
            ID     = dto.TConst;
            Title  = dto.Title;
            Year   = dto.Year;
            Rating = dto.Rating;
            Votes  = dto.Votes;

            if (dto.Image != null)
            {
                Image = dto.Image.Url;
            }

            switch (dto.Type)
            {
            case "feature":
                Type = TitleType.Movie;
                break;

            case "tv_series":
                Type = TitleType.TVSeries;
                break;

            case "video_game":
                Type = TitleType.Game;
                break;

            case "short":
                Type = TitleType.Short;
                break;

            // todo: add more types
            default:
                Type = TitleType.Unknown;
                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Here we do whatever we want with the info.
        /// </summary>
        /// <param name="type">Type of result to process (list of results or a title).</param>
        /// <param name="result">The result object to be processed.</param>
        public void processResult(int type, object result)
        {
            if (!error)        // if no errors occured
            {
                if (type == 0) // if we get a title
                {
                    IMDbTitle title = (IMDbTitle)result;
                    Console.WriteLine(title.Title);
                    richTextBox1.SelectionFont = new Font("arial", 12, FontStyle.Bold);
                    richTextBox1.AppendText("Title: ");
                    richTextBox1.SelectionFont = new Font("arial", 12, FontStyle.Regular);
                    richTextBox1.AppendText(title.Title + Environment.NewLine);

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  IMDbLink: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.URL + Environment.NewLine);

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  Year: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.Year + Environment.NewLine);

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  Cover URL: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.CoverURL + Environment.NewLine);

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  User Rating: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.Rating + Environment.NewLine);

                    if (title.Directors != null)
                    {
                        richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                        if (title.Media == 0)
                        {
                            richTextBox1.AppendText("  Directors:" + Environment.NewLine);
                        }
                        else
                        {
                            richTextBox1.AppendText("  Creators:" + Environment.NewLine);
                        }

                        richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);


                        foreach (IMDbDirCrea person in title.Directors)
                        {
                            richTextBox1.AppendText("   " + person.Name + Environment.NewLine);
                            richTextBox1.AppendText("   " + person.URL + Environment.NewLine);
                        }
                    }

                    if (title.Media == 1 && title.Seasons != null)
                    {
                        richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                        richTextBox1.AppendText("  Seasons:" + Environment.NewLine);
                        for (int i = 0; i < title.Seasons.Count; i++)
                        {
                            IMDbSerieSeason season = title.Seasons[i];
                            richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                            richTextBox1.AppendText("   Season " + season.Number + Environment.NewLine);
                            if (season.Episodes != null)
                            {
                                foreach (IMDbSerieEpisode ep in season.Episodes)
                                {
                                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Bold);
                                    richTextBox1.AppendText("    Episode " + ep.Number + ": " + ep.Title + Environment.NewLine);
                                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                                    richTextBox1.AppendText("      Aired on: " + ep.AirDate + Environment.NewLine);
                                    richTextBox1.AppendText("      " + ep.Plot + Environment.NewLine);
                                }
                            }
                            else
                            {
                                richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Bold);
                                richTextBox1.AppendText("    No episodes!" + Environment.NewLine);
                            }
                            richTextBox1.AppendText(Environment.NewLine);
                        }
                    }

                    if (title.Genres != null)
                    {
                        richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                        richTextBox1.AppendText("  Genres: " + Environment.NewLine);
                        richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                        foreach (string genre in title.Genres)
                        {
                            richTextBox1.AppendText("   " + genre + Environment.NewLine);
                        }
                    }

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  Tagline: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.Tagline + Environment.NewLine);

                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  Plot: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.Plot + Environment.NewLine);

                    if (title.Actors != null)
                    {
                        richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                        richTextBox1.AppendText("  Cast: " + Environment.NewLine);
                        foreach (IMDbActor actor in title.Actors)
                        {
                            richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                            richTextBox1.AppendText("   " + actor.Name + " as " + actor.Character + Environment.NewLine);
                            richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                            if (actor.PhotoURL != null)
                            {
                                richTextBox1.AppendText("   Photo URL: " + actor.PhotoURL + Environment.NewLine);
                            }
                            else
                            {
                                richTextBox1.AppendText("   Photo URL: N/A" + Environment.NewLine);
                            }
                            richTextBox1.AppendText("   Page URL: " + actor.URL + Environment.NewLine);
                        }
                    }
                    richTextBox1.SelectionFont = new Font("arial", 9, FontStyle.Bold);
                    richTextBox1.AppendText("  Runtime: ");
                    richTextBox1.SelectionFont = new Font("arial", 8, FontStyle.Regular);
                    richTextBox1.AppendText(title.Runtime + Environment.NewLine + Environment.NewLine);
                }
                else if (type == 1) // if we get a result list
                {
                    List <IMDbLink> results = (List <IMDbLink>)result;
                    Results         res     = new Results();
                    res.setResults(results);
                    if (res.ShowDialog() == DialogResult.OK)
                    {
                        manag.IMDbParse(res.Selected);
                    }
                }
            }
            Cursor = Cursors.Default;
        }