Ejemplo n.º 1
0
        private MovieInfo GetMovieInfo(TmdbMovie source)
        {
            var result = new MovieInfo();

            if (source == null)
            {
                return(result);
            }
            result.Name          = source.title;
            result.OriginalTitle = source.original_title;
            if (string.IsNullOrEmpty(result.OriginalTitle))
            {
                result.OriginalTitle = result.Name;
            }
            result.Year     = string.IsNullOrEmpty(source.release_date) ? string.Empty : source.release_date.Substring(0, 4);
            result.Homepage = source.homepage;
            result.IMDBID   = source.imdb_id;
            result.Rating   = source.vote_average.ToString("N0");
            if (!string.IsNullOrEmpty(source.release_date))
            {
                try
                {
                    result.SetReleaseDate(GetFormattedDate(source.release_date));
                }
                catch
                {
                }
            }
            result.Overview = source.overview;
            result.Tagline  = source.tagline;
            var trailers = api.GetMovieTrailers(source.id);

            if (trailers.youtube != null && trailers.youtube.Any())
            {
                result.Trailer = string.Format("http://www.youtube.com/watch?v={0}", trailers.youtube.First().source);
            }
            var cast = api.GetMovieCast(source.id);

            if (cast != null && cast.cast != null && cast.cast.Any())
            {
                result.Cast.AddRange(cast.cast.Select(x => x.name));
            }
            if (cast != null && cast.crew != null && cast.crew.Any(x => x.job == "Director"))
            {
                result.Director.Add(cast.crew.Where(x => x.job == "Director").Select(x => x.name).First());
            }

            result.Genre.AddRange(source.genres.Select(x => x.name));
            result.Runtime = source.runtime.ToString(CultureInfo.InvariantCulture);
            result.Studios.AddRange(source.production_companies.Select(x => x.name));
            result.Countries.AddRange(source.production_countries.Select(x => x.name));

            return(result);
        }
Ejemplo n.º 2
0
        private MovieInfo GetMovieInfo(XmlNode movie, string id)
        {
            MovieInfo _result = new MovieInfo();

            _result.HasRightToLeftDirection = GetFlowDirection() == FlowDirection.RightToLeft;
            _result.TVDBID = id;
            _result.Name   = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movie, "SeriesName"));
            _result.Year   = GetSeriesYear(movie);
            _result.IMDBID = Helpers.GetValueFromXmlNode(movie, "IMDB_ID");
            _result.SetReleaseDate(this.GetFormattedDate(Helpers.GetValueFromXmlNode(movie, "FirstAired")));
            _result.Overview = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movie, "Overview"));

            // check if no rating already
            if (string.IsNullOrEmpty(_result.Rating))
            {
                _result.Rating = Helpers.GetValueFromXmlNode(movie, "Rating");
            }

            string _actorsList = Helpers.GetValueFromXmlNode(movie, "Actors");

            if (!string.IsNullOrEmpty(_actorsList))
            {
                _result.Cast = _actorsList.Split('|').ToTrimmedList();
            }

            string _directorList = Helpers.GetValueFromXmlNode(movie, "Director");

            if (!string.IsNullOrEmpty(_directorList))
            {
                _result.Director = _directorList.Split('|').ToTrimmedList();
            }

            string _genresList = Helpers.GetValueFromXmlNode(movie, "Genre");

            if (!string.IsNullOrEmpty(_genresList))
            {
                _result.Genre = _genresList.Split('|').ToTrimmedList();
            }
            string _studios = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movie, "Network"));

            if (!string.IsNullOrEmpty(_studios))
            {
                _result.Studios.Add(_studios);
            }
            _result.Runtime = Helpers.GetValueFromXmlNode(movie, "Runtime");

            return(_result);
        }
Ejemplo n.º 3
0
        public MovieInfo GetMovieInfo(string imdbId, string countryCode)
        {
            MovieInfo _result = new MovieInfo();

            if (!string.IsNullOrEmpty(imdbId))
            {
                MovieInfo _originalInfo = new MovieInfo();
                if (this.Language != "com")
                {
                    _originalInfo = new IMDBMovieInfo("com").GetMovieInfo(imdbId, countryCode);
                }

                string _moviePage = Helpers.GetPage(string.Format("{0}/title/{1}/", m_CountryFactory.TargetHost, imdbId), null, m_CountryFactory.GetEncoding, "", true, false, m_CountryFactory.Language);
                if (!string.IsNullOrEmpty(_moviePage))
                {
                    _result.IMDBID        = imdbId;
                    _result.Name          = GetTitle(_moviePage);
                    _result.Name          = string.IsNullOrEmpty(_result.Name) ? _originalInfo.Name : _result.Name;
                    _result.OriginalTitle = GetOriginalTitle(_moviePage);
                    _result.OriginalTitle = string.IsNullOrEmpty(_result.OriginalTitle) ? (string.IsNullOrEmpty(_originalInfo.OriginalTitle) ? _result.Name : _originalInfo.OriginalTitle) : _result.OriginalTitle;
                    _result.Year          = GetYear(_moviePage);
                    _result.Year          = string.IsNullOrEmpty(_result.Year) ? _originalInfo.Year : _result.Year;
                    _result.Runtime       = GetRunTime(_moviePage);
                    _result.Runtime       = string.IsNullOrEmpty(_result.Runtime) ? _originalInfo.Runtime : _result.Runtime;

                    DateTimeFormatInfo _dtfi = new DateTimeFormatInfo()
                    {
                        DateSeparator = " ", ShortDatePattern = "dd MMMM yyyy"
                    };
                    if (string.IsNullOrEmpty(_originalInfo.ReleaseDate))
                    {
                        _result.SetReleaseDate(Helpers.GetFormattedDate(GetReleaseDate(imdbId), _dtfi));
                    }
                    else
                    {
                        _result.ReleaseDate = _originalInfo.ReleaseDate;
                    }
                    DateTime _out = DateTime.MinValue;
                    if (DateTime.TryParse(_result.ReleaseDate, out _out) && _out != DateTime.MinValue)
                    {
                        _result.ReleaseDate = Helpers.GetFormattedDate(_out);
                    }
                    _result.Rating    = GetRating(_moviePage);
                    _result.Rating    = string.IsNullOrEmpty(_result.Rating) ? _originalInfo.Rating : _result.Rating;
                    _result.MPAA      = GetMPAA(_moviePage);
                    _result.MPAA      = string.IsNullOrEmpty(_result.MPAA) ? _originalInfo.MPAA : _result.MPAA;
                    _result.Tagline   = GetTagline(_moviePage);
                    _result.Tagline   = string.IsNullOrEmpty(_result.Tagline) ? _originalInfo.Tagline : _result.Tagline;
                    _result.Metascore = GetMetascore(_moviePage);
                    _result.Metascore = string.IsNullOrEmpty(_result.Metascore) ? _originalInfo.Metascore : _result.Metascore;
                    _result.Trailer   = GetTrailerLink(_moviePage);
                    _result.Trailer   = string.IsNullOrEmpty(_result.Trailer) ? _originalInfo.Trailer : _result.Trailer;
                    if (!string.IsNullOrEmpty(_result.Trailer) && !_result.Trailer.StartsWith("http"))
                    {
                        _result.Trailer = "http://www.imdb.com" + _result.Trailer;
                    }
                    _result.Overview = GetOverview(imdbId);
                    if (string.IsNullOrEmpty(_result.Overview))
                    {
                        _result.Overview = GetPlot(_moviePage);
                    }
                    _result.Overview      = string.IsNullOrEmpty(_result.Overview) ? _originalInfo.Overview : _result.Overview;
                    _result.Genre         = GetGenres(_moviePage);
                    _result.Genre         = _result.Genre.Count == 0 ? _originalInfo.Genre : _result.Genre;
                    _result.Cast          = GetActors(_moviePage).ToTrimmedList();
                    _result.Cast          = _result.Cast.Count == 0 ? _originalInfo.Cast : _result.Cast;
                    _result.Director      = GetDirectors(_moviePage);
                    _result.Director      = _result.Director.Count == 0 ? _originalInfo.Director : _result.Director;
                    _result.Countries     = GetCountries(_moviePage);
                    _result.Countries     = _result.Countries.Count == 0 ? _originalInfo.Countries : _result.Countries;
                    _result.Certification = GetCertification(countryCode, _moviePage, imdbId);
                    _result.Certification = string.IsNullOrEmpty(_result.Certification) ? _originalInfo.Certification : _result.Certification;
                    _result.Studios       = GetCompanies(_moviePage);
                    _result.Studios       = _result.Studios.Count == 0 ? _originalInfo.Studios : _result.Studios;
                }
            }

            return(_result);
        }