/// <summary>
        /// Gets the scrapers as string list.
        /// </summary>
        /// <param name="scrapeField">
        /// The scrape field.
        /// </param>
        /// <param name="addNoneFirst">
        /// if set to <c>true</c> [add none first].
        /// </param>
        /// <param name="addMediaInfo">
        /// if set to <c>true</c> [add media info].
        /// </param>
        /// <returns>
        /// Scrapers collection
        /// </returns>
        public static BindingList<string> GetScrapersAsStringList(
            ScrapeFields scrapeField, bool addNoneFirst = false, bool addMediaInfo = false)
        {
            var output = new BindingList<string>();

            List<IMovieScraper> scrapers = GetScrapersSupporting(scrapeField);

            var tempSortedList = new SortedList<string, string>();

            foreach (IMovieScraper scraper in scrapers)
            {
                tempSortedList.Add(scraper.ScraperName.ToString(), null);
            }

            if (addNoneFirst)
            {
                output.Add("<None>");
            }

            foreach (var s in tempSortedList)
            {
                output.Add(s.Key);
            }

            if (addMediaInfo)
            {
                output.Add("Use MediaInfo Data");
            }

            return output;
        }
Example #2
0
        /// <summary>
        /// Gets the scrapers as string list.
        /// </summary>
        /// <param name="scrapeField">
        /// The scrape field.
        /// </param>
        /// <param name="addNoneFirst">
        /// if set to <c>true</c> [add none first].
        /// </param>
        /// <param name="addMediaInfo">
        /// if set to <c>true</c> [add media info].
        /// </param>
        /// <returns>
        /// Scrapers collection
        /// </returns>
        public static BindingList <string> GetScrapersAsStringList(
            ScrapeFields scrapeField, bool addNoneFirst = false, bool addMediaInfo = false)
        {
            var output = new BindingList <string>();

            List <IMovieScraper> scrapers = GetScrapersSupporting(scrapeField);

            var tempSortedList = new SortedList <string, string>();

            foreach (IMovieScraper scraper in scrapers)
            {
                tempSortedList.Add(scraper.ScraperName.ToString(), null);
            }

            if (addNoneFirst)
            {
                output.Add("<None>");
            }

            foreach (var s in tempSortedList)
            {
                output.Add(s.Key);
            }

            if (addMediaInfo)
            {
                output.Add("Use MediaInfo Data");
            }

            return(output);
        }
Example #3
0
        public void GetScrapersSupportingScrapeTest()
        {
            const ScrapeFields ScrapeFields = new ScrapeFields();
            var actual = MovieScraperHandler.GetScrapersSupporting(ScrapeFields);

            Assert.IsTrue(actual.Count > 0);
        }
Example #4
0
        /// <summary>
        /// Get scrapers supporting.
        /// </summary>
        /// <param name="scrapeFields">
        /// The scrape fields.
        /// </param>
        /// <returns>
        /// Scraper collection
        /// </returns>
        public static List <IMovieScraper> GetScrapersSupporting(ScrapeFields scrapeFields)
        {
            List <IMovieScraper> scrapers = ReturnAllScrapers();

            return
                ((from s in scrapers where s.AvailableScrapeMethods.Contains(scrapeFields) orderby s.ScraperName select s)
                 .ToList());
        }
Example #5
0
        private static bool GetOutResult(ScrapeFields scrapeFields, string scrapeGroup, MovieModel movie, string noneValue, MovieScraperGroupModel scraperGroup, bool outResult)
        {
            if (!string.IsNullOrEmpty(scrapeGroup) && scrapeGroup != noneValue)
            {
                bool result;
                ScrapeValues(movie, scrapeGroup, scrapeFields, out result);

                if (!result)
                {
                    outResult = false;
                }
            }
            return(outResult);
        }
Example #6
0
        /// <summary>
        /// The scrape rating.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeRating(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool   result = true;
            double output;

            bool scrapeSuccess = scraper.ScrapeRating(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Rating = output;
            }
            else
            {
                result = false;
            }

            return(result);
        }
Example #7
0
        /// <summary>
        /// Scrape cast.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeCast(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList <PersonModel> output;

            bool scrapeSuccess = scraper.ScrapeCast(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Cast = output;
            }
            else
            {
                result = false;
            }

            return(result);
        }
Example #8
0
        /// <summary>
        /// The scrape poster.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapePoster(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList <ImageDetailsModel> output;

            bool scrapeSuccess = scraper.ScrapePoster(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                if (output.Count > 0)
                {
                    movie.CurrentPosterImageUrl = output[0].UriFull.ToString();
                }

                movie.AlternativePosters = output;
            }
            else
            {
                result = false;
            }

            return(result);
        }
        /// <summary>
        /// The scrape rating.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeRating(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            double output;

            bool scrapeSuccess = scraper.ScrapeRating(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Rating = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
        /// <summary>
        /// The scrape trailer.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeTrailer(
            IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList<TrailerDetailsModel> output;

            bool scrapeSuccess = scraper.ScrapeTrailer(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.AlternativeTrailers = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
Example #11
0
 /// <summary>
 /// The create log catagory.
 /// </summary>
 /// <param name="title">
 /// The log title.
 /// </param>
 /// <param name="type">
 /// The ScrapeFields type.
 /// </param>
 /// <returns>
 /// Log catagory
 /// </returns>
 private static string CreateLogCatagory(string title, ScrapeFields type)
 {
     return("Scrape > " + type + " > " + title);
 }
Example #12
0
        /// <summary>
        /// The scrape values.
        /// </summary>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="result">
        /// The result.
        /// </param>
        private static void ScrapeValues(MovieModel movie, string scraperName, ScrapeFields type, out bool result)
        {
            result = true;

            for (int index = 0; index < scrapers.Count; index++)
            {
                IMovieScraper scraper = scrapers[index];
                if (scraper.ScraperName.ToString() == scraperName)
                {
                    if (type == ScrapeFields.Title)
                    {
                        result = ScrapeTitle(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.OriginalTitle)
                    {
                        result = ScrapeOriginalTitle(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Year)
                    {
                        result = ScrapeYear(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Top250)
                    {
                        result = Scrape250(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Cast)
                    {
                        result = ScrapeCast(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Certification)
                    {
                        result = ScrapeCertification(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Country)
                    {
                        result = ScrapeCountry(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Director)
                    {
                        result = ScrapeDirector(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Genre)
                    {
                        result = ScrapeGenre(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Language)
                    {
                        result = ScrapeLanguage(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Outline)
                    {
                        result = ScrapeOutline(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Plot)
                    {
                        result = ScrapePlot(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Rating)
                    {
                        result = ScrapeRating(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.ReleaseDate)
                    {
                        result = ScrapeReleaseDate(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Runtime)
                    {
                        result = ScrapeRuntime(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Studio)
                    {
                        result = ScrapeStudio(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Tagline)
                    {
                        result = ScrapeTagline(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Votes)
                    {
                        result = ScrapeVotes(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Writers)
                    {
                        result = ScrapeWriters(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Mpaa)
                    {
                        result = ScrapeMpaa(scraper, scraperName, type, movie);
                    }

                    if (type == ScrapeFields.Poster)
                    {
                        result = ScrapePoster(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Fanart)
                    {
                        result = ScrapeFanart(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Trailer)
                    {
                        result = ScrapeTrailer(scraper, scraperName, type, movie);
                        break;
                    }
                }
            }
        }
        /// <summary>
        /// The scrape values.
        /// </summary>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="result">
        /// The result.
        /// </param>
        private static void ScrapeValues(MovieModel movie, string scraperName, ScrapeFields type, out bool result)
        {
            result = true;

            foreach (IMovieScraper scraper in scrapers)
            {
                if (scraper.ScraperName.ToString() == scraperName)
                {
                    if (type == ScrapeFields.Title)
                    {
                        result = ScrapeTitle(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.OriginalTitle)
                    {
                        result = ScrapeOriginalTitle(scraper, scraperName, type, movie);
                        break;
                    }
                    
                    if (type == ScrapeFields.Year)
                    {
                        result = ScrapeYear(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Top250)
                    {
                        result = Scrape250(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Cast)
                    {
                        result = ScrapeCast(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Certification)
                    {
                        result = ScrapeCertification(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Country)
                    {
                        result = ScrapeCountry(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Director)
                    {
                        result = ScrapeDirector(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Genre)
                    {
                        result = ScrapeGenre(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Language)
                    {
                        result = ScrapeLanguage(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Outline)
                    {
                        result = ScrapeOutline(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Plot)
                    {
                        result = ScrapePlot(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Rating)
                    {
                        result = ScrapeRating(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.ReleaseDate)
                    {
                        result = ScrapeReleaseDate(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Runtime)
                    {
                        result = ScrapeRuntime(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Studio)
                    {
                        result = ScrapeStudio(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Tagline)
                    {
                        result = ScrapeTagline(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Votes)
                    {
                        result = ScrapeVotes(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Writers)
                    {
                        result = ScrapeWriters(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Mpaa)
                    {
                        result = ScrapeMpaa(scraper, scraperName, type, movie);
                    }

                    if (type == ScrapeFields.Poster)
                    {
                        result = ScrapePoster(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Fanart)
                    {
                        result = ScrapeFanart(scraper, scraperName, type, movie);
                        break;
                    }

                    if (type == ScrapeFields.Trailer)
                    {
                        result = ScrapeTrailer(scraper, scraperName, type, movie);
                        break;
                    }
                }
            }
        }
        private static bool GetOutResult(ScrapeFields scrapeFields, string scrapeGroup, MovieModel movie, string noneValue, MovieScraperGroupModel scraperGroup, bool outResult)
        {
            if (!string.IsNullOrEmpty(scrapeGroup) && scrapeGroup != noneValue)
            {
                bool result;
                ScrapeValues(movie, scrapeGroup, scrapeFields, out result);

                if (!result)
                {
                    outResult = false;
                }
            }
            return outResult;
        }
        /// <summary>
        /// Get scrapers supporting.
        /// </summary>
        /// <param name="scrapeFields">
        /// The scrape fields.
        /// </param>
        /// <returns>
        /// Scraper collection
        /// </returns>
        public static List<IMovieScraper> GetScrapersSupporting(ScrapeFields scrapeFields)
        {
            List<IMovieScraper> scrapers = ReturnAllScrapers();

            return
                (from s in scrapers where s.AvailableScrapeMethods.Contains(scrapeFields) orderby s.ScraperName select s)
                    .ToList();
        }
        /// <summary>
        /// The scrape poster.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapePoster(IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList<ImageDetailsModel> output;

            bool scrapeSuccess = scraper.ScrapePoster(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                if (output.Count > 0)
                {
                    movie.CurrentPosterImageUrl = output[0].UriFull.ToString();
                }

                movie.AlternativePosters = output;
            }
            else
            {
                result = false;
            }

            return result;
        }
 /// <summary>
 /// The create log catagory.
 /// </summary>
 /// <param name="title">
 /// The log title.
 /// </param>
 /// <param name="type">
 /// The ScrapeFields type.
 /// </param>
 /// <returns>
 /// Log catagory
 /// </returns>
 private static string CreateLogCatagory(string title, ScrapeFields type)
 {
     return "Scrape > " + type + " > " + title;
 }
        /// <summary>
        /// The scrape language.
        /// </summary>
        /// <param name="scraper">
        /// The scraper.
        /// </param>
        /// <param name="scraperName">
        /// The scraper name.
        /// </param>
        /// <param name="type">
        /// The ScrapeFields type.
        /// </param>
        /// <param name="movie">
        /// The movie.
        /// </param>
        /// <returns>
        /// Scrape successful
        /// </returns>
        private static bool ScrapeLanguage(
            IMovieScraper scraper, string scraperName, ScrapeFields type, MovieModel movie)
        {
            bool result = true;
            BindingList<string> output;

            bool scrapeSuccess = scraper.ScrapeLanguage(
                GetScraperID(scraperName, movie), 0, out output, CreateLogCatagory(scraper.ScraperName.ToString(), type));

            if (scrapeSuccess)
            {
                movie.Language = output;
            }
            else
            {
                result = false;
            }

            return result;
        }