コード例 #1
0
        public void FilmPageConstructorTest()
        {
            const uint filmId = 526;
            var target = new FilmPage(filmId);
            Assert.AreEqual(target.LocalTitle, "Большой куш");
            Assert.AreEqual(target.Title, "Snatch.");
            Assert.AreEqual(target.Year, 2000);
            Assert.AreEqual(target.MPAA, "R");
            Assert.AreEqual(target.Runtime, "102 мин. / 01:42");
            Assert.IsTrue(target.Summary.Length > 10);

            // Added with plugin system version 2.1
            CollectionAssert.AreEqual(target.GetContries(), new string[] { "США", "Великобритания" });

            // Added with plugin system version 2.2
            Assert.AreEqual(target.TagLine, "«Stealing stones is hazardous.»");
            Assert.AreEqual(target.FullMPAA, "лицам до 17 лет обязательно присутствие взрослого");
            Assert.AreEqual(target.GetOnlyPoster(), "http://st.kinopoisk.ru/im/poster/1/4/1/kinopoisk.ru-Snatch-14167.jpg");
            Assert.AreEqual(target.GetOnlyBackdrop(), "http://st.kinopoisk.ru/im/wallpaper/1/9/7/kinopoisk.ru-Snatch-1971--w--1024.jpg");
            var director = string.Join(", ", target.GetCrew().Where(p => p.Type == "director").Select(p => p.LocalName).ToArray());
            Assert.AreEqual(director, "Гай Ричи");
            var writers = target.GetCrew().Where(p => p.Type == "writer").Select(p => p.LocalName).ToArray();
            CollectionAssert.AreEqual(writers, new string[] {"Гай Ричи"});
            Assert.IsTrue(target.Rating.ImdbRating.Votes > 0);
            //Assert.AreEqual(target.IMDBScore, "8,3");
        }
コード例 #2
0
        protected static MovieInfo FetchFilm(uint filmId, FetchOptions options = FetchOptions.None)
        {
            var movie = new MovieInfo();
            var filmInfo = new Kinopoisk.FilmPage(filmId);

            movie.AllGenres = filmInfo.GetGenreList().ToArray();
            movie.Budget = filmInfo.Budget;
            movie.MPAArating = filmInfo.MPAA;
            movie.Revenue = filmInfo.Revenue;
            movie.Runtime = filmInfo.Runtime;
            movie.Summary = Utils.UnHTML(filmInfo.Summary);
            movie.IMDBscore = filmInfo.IMDBScore;
            movie.Year = Utils.SafeYear(filmInfo.Year);
            movie.Local_Title = filmInfo.LocalTitle;
            movie.Original_Title = filmInfo.Title;

            // Added with plugin system version 2.1
            var countries = filmInfo.GetContries();
            if (countries.Count() > 0)
                movie.Country = string.Join(", ", countries);

            //public string Language = string.Empty;
            //public string ParentalRatingSummary = string.Empty;

            // Added with plugin system version 2.2
            movie.TagLine = filmInfo.TagLine;
            movie.FullMPAA = filmInfo.FullMPAA;
            movie.PosterURL = filmInfo.GetOnlyPoster();
            movie.BackdropURL = filmInfo.GetOnlyBackdrop();

            movie.Director = string.Join(", ", filmInfo.GetCrew().Where(p => p.Type == "director").Select(p=>p.LocalName).ToArray());
            movie.Writers = filmInfo.GetCrew().Where(p => p.Type == "writer").Select(p => p.LocalName).ToArray();
            movie.NumberOfVotes = filmInfo.Rating.ImdbRating.Votes.ToString();

            //public string FullCertifications = string.Empty;
            //public string Outline = string.Empty;
            //public string Plot = string.Empty;
            //public string Top250 = string.Empty;
            //public string Awards = string.Empty;
            //public string Website = string.Empty;
            //public string Trailer = string.Empty;

            if ((options & FetchOptions.FetchImages)==FetchOptions.FetchImages)
            {
                var link = filmInfo.GetOnlyBackdrop();
                if (link != null) movie.Backdrop = Utils.SerializeBitmap(Utils.LoadPictureFromURI(link));
                link = filmInfo.GetOnlyPoster();
                if (link != null) movie.Poster = Utils.SerializeBitmap(Utils.LoadPictureFromURI(link));
            }

            movie.AllCastAndCrew = ProcessCastAndCrew(filmInfo);

            //movie.IMDB_ID = Utils.ChopperBlank(sMoviePageContents, "<imdb>", "</imdb>");
            //movie.Studios  // not supported by tMDB API 2.0

            return movie;
        }
コード例 #3
0
        /// <summary>
        /// Retrieves a list of all available posters in a string array.
        /// 
        /// This is an optional interface and can be removed if it is not applicable to your fetcher.
        /// 
        /// Optional for:
        ///     meta data fetches (all)
        /// </summary>
        /// <returns>An array of string's (can be empty, but not null)</returns>
        public static string[] GetAllPosters(string localId, string externalId)
        {
            Utils.Logger(Tag + string.Format("<b>GetAllPosters</b> called with localId = \"{0}\", externalId=\"{1}\"", localId, externalId));
            try
            {
                var filmInfo = new Kinopoisk.FilmPage(localId);
                List<string> posters = filmInfo.GetPosters();
                Utils.Logger(Tag + string.Format("<b>GetAllPosters</b> returned \"{0}\" results.", localId, posters.Count));
                return posters.ToArray();
            }
            catch (Exception ex)
            {
                Utils.Logger(Utils.GetAllErrorDetails(ex));
            }

            return new string[]{};
        }