예제 #1
0
        public void QuickSearchTmdbTest()
        {
            Query query = new Query();

            query.Title = "Sin City";

            var actual = MovieScrapeFactory.QuickSearchTmdb(query);

            Assert.IsTrue(actual);
        }
예제 #2
0
        /// <summary>
        /// The get scraper id.
        /// </summary>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// The scraper id
        /// </returns>
        private static string GetScraperID(string scraperName, MovieModel movie)
        {
            if (string.IsNullOrEmpty(movie.ImdbId) || string.IsNullOrEmpty(movie.TmdbId))
            {
                var results = new BindingList <QueryResult>();
                var query   = new Query
                {
                    Results = results,
                    Title   = movie.Title,
                    Year    = movie.Year.ToString(),
                    ImdbId  = movie.ImdbId
                };

                MovieScrapeFactory.QuickSearchTmdb(query);

                if (query.Results.Count > 0)
                {
                    if (string.IsNullOrEmpty(movie.ImdbId))
                    {
                        movie.ImdbId = query.Results[0].ImdbID;
                    }

                    if (string.IsNullOrEmpty(movie.TmdbId))
                    {
                        movie.TmdbId = query.Results[0].TmdbID;
                    }
                }
            }

            switch (scraperName)
            {
            case "Imdb":
                return("tt" + movie.ImdbId);

            case "TheMovieDB":
                return(movie.TmdbId);

            case "Apple":
                return(movie.Title);
            }

            return(null);
        }
예제 #3
0
        /// <summary>
        /// The get scraper id.
        /// </summary>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// The scraper id
        /// </returns>
        private static string GetScraperID(string scraperNameString, MovieModel movie)
        {
            var results = new BindingList <QueryResult>();
            var query   = new Query
            {
                Results = results, Title = movie.Title, Year = movie.Year.ToString(), ImdbId = movie.ImdbId
            };

            var scraperName = (ScraperList)Enum.Parse(typeof(ScraperList), scraperNameString);

            if (scraperName == ScraperList.Imdb || scraperName == ScraperList.TheMovieDB)
            {
                if (string.IsNullOrEmpty(movie.ImdbId) || string.IsNullOrEmpty(movie.TmdbId))
                {
                    MovieScrapeFactory.QuickSearchTmdb(query);

                    if (query.Results.Count > 0)
                    {
                        if (string.IsNullOrEmpty(movie.ImdbId))
                        {
                            movie.ImdbId = query.Results[0].ImdbID;
                        }

                        if (string.IsNullOrEmpty(movie.TmdbId))
                        {
                            movie.TmdbId = query.Results[0].TmdbID;
                        }
                    }
                }
            }

            switch (scraperName)
            {
            case ScraperList.Imdb:
                return("tt" + movie.ImdbId);

            case ScraperList.TheMovieDB:
                return(movie.TmdbId);

            case ScraperList.Apple:
                return(movie.Title);

            case ScraperList.Allocine:

                if (string.IsNullOrEmpty(movie.AllocineId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.Allocine select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.AllocineId = query.Results[0].AllocineId;
                    }
                }

                return(movie.AllocineId);

            case ScraperList.FilmAffinity:

                if (string.IsNullOrEmpty(movie.FilmAffinityId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.FilmAffinity select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.FilmAffinityId = query.Results[0].FilmAffinityId;
                    }
                }

                return(movie.FilmAffinityId);

            case ScraperList.FilmDelta:

                if (string.IsNullOrEmpty(movie.FilmDeltaId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.FilmDelta select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.FilmDeltaId = query.Results[0].FilmDeltaId;
                    }
                }

                return(movie.FilmDeltaId);

            case ScraperList.FilmUp:

                if (string.IsNullOrEmpty(movie.FilmUpId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.FilmUp select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.FilmUpId = query.Results[0].FilmUpId;
                    }
                }

                return(movie.FilmUpId);

            case ScraperList.FilmWeb:

                if (string.IsNullOrEmpty(movie.FilmWebId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.FilmWeb select s).SingleOrDefault();

                    scraper.SearchSite(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.FilmWebId = query.Results[0].FilmWebId;
                    }
                }

                return(movie.FilmWebId);

            case ScraperList.Impawards:
                return(movie.ImpawardsId);

            case ScraperList.MovieMeter:

                if (string.IsNullOrEmpty(movie.MovieMeterId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.MovieMeter select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.MovieMeterId = query.Results[0].MovieMeterId;
                    }
                }

                return(movie.MovieMeterId);

            case ScraperList.OFDB:

                if (string.IsNullOrEmpty(movie.OfdbId))
                {
                    var scraper =
                        (from s in scrapers where s.ScraperName == ScraperList.OFDB select s).SingleOrDefault();

                    scraper.SearchViaBing(query, 0, string.Empty);

                    if (query.Results.Count > 0)
                    {
                        movie.OfdbId = query.Results[0].OfdbId;
                    }
                }

                return(movie.OfdbId);

            case ScraperList.Kinopoisk:
                return(movie.KinopoiskId);

            case ScraperList.Sratim:
                return(movie.SratimId);

            case ScraperList.RottenTomato:
                return(movie.RottenTomatoId);
            }

            return(null);
        }