Exemple #1
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                var url = string.Format(
                    "http://www.filmdelta.se/search.php?string={0}&type=movie", query.Title.Replace(' ', '+'));

                var searchHtml =
                    Downloader.ProcessDownload(url, DownloadType.Html, Section.Movies).RemoveCharacterReturn();

                var matches = Regex.Matches(
                    searchHtml,
                    @"filmer/(?<id>.*?)/.*?"">(?<title>.*?)</a>.*?(?<year>\d{4})");

                foreach (Match m in matches)
                {
                    var queryResult = new QueryResult
                                          {
                                              Title = m.Groups["title"].Value,
                                              URL = string.Format("http://www.filmdelta.se/titles.php?movieId={0}", m.Groups["id"].Value),
                                              Year = m.Groups["title"].Value.ToInt()
                                          };

                    query.Results.Add(queryResult);
                }

                return true;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #2
0
 public void SearchYANFOETest()
 {
     var target = new TheMovieDb();
     var query = new Query { Results = new BindingList<QueryResult>(), Title = "Transformers", Year = "2007" };
     const int ThreadID = 0;
     var actual = target.SearchYANFOE(query, ThreadID, string.Empty);
     Assert.IsTrue(actual);
 }
        public void QuickSearchTmdbTest()
        {
            Query query = new Query();

            query.Title = "Sin City";

            var actual = MovieScrapeFactory.QuickSearchTmdb(query);

            Assert.IsTrue(actual);
        }
        /// <summary>
        /// Do a quick lookup on TmDB
        /// </summary>
        /// <param name="query">The query.</param>
        /// <returns>
        /// The quick search tmdb.
        /// </returns>
        public static bool QuickSearchTmdb(Query query)
        {
            if (query == null)
            {
                query = new Query();
            }

            var tmdb = new TheMovieDb();
            tmdb.SearchSite(query, 0, "Tmdb");

            return query.Results.Count > 0;
        }
Exemple #5
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0} {1} site:filmup.leonardo.it/", query.Title, query.Year),
                    "http://filmup.leonardo.it/sc_",
                    threadID);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #6
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0} site:http://www.filmaffinity.com/es", query.Title), 
                    string.Empty, 
                    threadID);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #7
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0}%20{1}%20site:www.impawards.com%20poster", query.Title, query.Year),
                    string.Empty,
                    threadID);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #8
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0} {1} site:http://www.filmaffinity.com/es", query.Title, query.Year),
                    "http://www.filmaffinity.com/es/film",
                    threadID,
                    @"(?<title>.*?)\s\((?<year>\d{4})\)\s-\sFilmAffinity",
                    @"(?<title>.*?)\s\((?<year>\d{4})\)\s-\sFilmAffinity",
                    @"http://www\.filmaffinity\.com/es/film(?<id>\d{6,9})\.html",
                    ScraperList.FilmAffinity);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #9
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0} site:www.kinopoisk.ru/level/1/", query.Title),
                    string.Empty,
                    threadID,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    ScraperList.Kinopoisk);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #10
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                var url =
                    string.Format(
                        "http://www.filmweb.pl/szukaj?q={0}&type=&startYear={1}&endYear={1}&startRate=&endRate=&startCount=&endCount=&sort=TEXT_SCORE&sortAscending=false",
                        query.Title.Replace(' ', '+'),
                        query.Year);

                var downloadHtml = Downloader.ProcessDownload(url, DownloadType.Html, Section.Movies).RemoveCharacterReturn();

                query.Results.Add(
                    new QueryResult
                        {
                            URL = YRegex.Match(@"searchResultTitle""\shref=""(?<url>.*?)"">.*?</a>", downloadHtml, "url")
                        });

                return true;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
        /// <summary>
        /// Handles the DoWork event of the bgw control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.ComponentModel.DoWorkEventArgs"/> instance containing the event data.</param>
        private void bgw_DoWork(object sender, DoWorkEventArgs e)
        {
            var results = new BindingList<QueryResult>();
            var query = new Query
            {
                Results = results,
                Title = MovieDBFactory.GetCurrentMovie().Title,
                Year = MovieDBFactory.GetCurrentMovie().Year.ToString()
            };

            Factories.Scraper.MovieScrapeFactory.QuickSearchTmdb(query);

            e.Result = query;
        }
Exemple #12
0
        /// <summary>
        /// Starts the search process.
        /// </summary>
        /// <param name="yanfoeid">The yanfoe id.</param>
        /// <param name="title">The title value.</param>
        /// <param name="year">The year value.</param>
        /// <returns>A query object.</returns>
        private Query DoSearch(string yanfoeid, string title, string year)
        {
            var results = new BindingList<QueryResult>();
            var query = new Query
                {
                    Results = results, 
                    Title = title, 
                    Year = year
                };

            Factories.Scraper.MovieScrapeFactory.QuickSearchTmdb(query);
            return query;
        }
Exemple #13
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                var searchQuery =
                    string.Format("http://www.filmaffinity.com/es/search.php?stype=title&stext={0}&from=0", query.Title);

                var html = Downloader.ProcessDownload(searchQuery, DownloadType.Html, Section.Movies).RemoveCharacterReturn();

                var matches = Regex.Matches(
                    html,
                    @"src=""(?<imageurl>http://pics.*?jpg).*?/es/film(?<id>\d*?)\.html"">(?<title>.*?)</a></b>\t\((?<year>\d{4})\)",
                    RegexOptions.IgnoreCase);

                foreach (Match match in matches)
                {
                    query.Results.Add(new QueryResult
                                          {
                                              URL = match.Groups["id"].Value,
                                              Title = match.Groups["title"].Value,
                                              Year = match.Groups["year"].Value.ToInt()
                                          });
                }

                return true;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #14
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                var url = string.Format("http://www.imdb.com/find?s=tt&q={0} ({1})", query.Title, query.Year);

                var webPage = Downloader.ProcessDownload(url, DownloadType.Html, Section.Movies).RemoveCharacterReturn();

                webPage = webPage
                    .ReplaceWithStringEmpty(new[] { "<b>", "</b>" })
                    .RemoveExtraWhiteSpace()
                    .RemoveCharacterReturn();

                var matches = Regex.Matches(
                    webPage,
                    @"(rc=""(?<imageurl>http://ia.media-imdb.com/images/M/.{46}@@._V1._SY30_SX23_.jpg)?"" width=""23"" height=""32"".*?)?onclick="".{1,100}"">(?<title>.{1,100})</a> \((?<year>\d{4})\) </td></tr>");

                foreach (Match m in matches)
                {
                    var queryResult = new QueryResult
                                          {
                                              URL = string.Format("http://www.imdb.com/title/{0}/combined", m.Groups["id"].Value),
                                              PosterUrl = m.Groups["imageurl"].Value.Replace("SY30_SX23", "SY500_SX500"),
                                              ImdbID = m.Groups["id"].Value,
                                              Title = m.Groups["title"].Value,
                                              Year = m.Groups["year"].Value.ToInt()
                                          };

                    query.Results.Add(queryResult);
                }

                Log.WriteToLog(LogSeverity.Info, 0, string.Format("IMDB site search complete ({0} results)", query.Results.Count), query.Title);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #15
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>
        /// [true/false] if an error occurred.
        /// </returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            query.Results = new BindingList<QueryResult>();

            try
            {
                query.Results = Bing.SearchBing(
                    string.Format(CultureInfo.CurrentCulture, "{0} {1} site:www.imdb.com", query.Title, query.Year),
                    string.Empty,
                    threadID);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #16
0
 /// <summary>
 /// Searches the YANFOE database for MovieUniqueId's
 /// </summary>
 /// <param name="query">The query.</param>
 /// <param name="threadID">The thread MovieUniqueId.</param>
 /// <param name="logCatagory">The log catagory.</param>
 /// <returns>[true/false] if an error occurred.</returns>
 public bool SearchYANFOE(Query query, int threadID, string logCatagory)
 {
     throw new NotImplementedException();
 }
Exemple #17
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>
        /// [true/false] if an error occurred.
        /// </returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format("{0} site:www.filmdelta.se/filmer/", query.Title),
                    "http://www.filmdelta.se/filmer/",
                    threadID,
                    @"(?<title>.*?)\s-\sFilmdelta\s-\sFilmdatabas\spå\ssvenska",
                    @"(?<title>.*?)\s\((?<year>\d{4})\)\s-\sFilmAffinity",
                    @"http://www.filmdelta.se/filmer/(?<id>\d{2,9}/.*?)/",
                    ScraperList.FilmAffinity);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #18
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                var url = string.Format("http://filmup.leonardo.it/cgi-bin/search.cgi?q={0}", query.Title);

                var html = Downloader.ProcessDownload(url, DownloadType.Html, Section.Movies).RemoveCharacterReturn();

                var matches = Regex.Matches(
                    html, 
                    @"href=""(?<url>http://filmup.leonardo.it/sc_.{1,20}.htm)?"" TARGET=""_blank"">\s(?<title>.*?)\(.*?(?<year>\d{4})", 
                    RegexOptions.IgnoreCase);

                foreach (Match m in matches)
                {
                    query.Results.Add(new QueryResult
                                          {
                                              Title = m.Groups["title"].Value,
                                              Year = m.Groups["year"].Value.ToInt(),
                                              URL = m.Groups["url"].Value
                                          });
                }

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #19
0
        /// <summary>
        /// Searches Bing for Applicable MovieUniqueId's
        /// </summary>
        /// <param name="query">A BingQuery object.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results = Bing.SearchBing(
                    string.Format(CultureInfo.CurrentCulture, "site:http://www.allocine.fr {0}%20{1}", query.Title, query.Year),
                    "http://www.allocine.fr/film/fichefilm_gen_cfilm=",
                    threadID,
                    BingRegexMatchTitle,
                    BingRegexMatchYear,
                    BingRegexMatchID,
                    this.ScraperName);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
        /// <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;
        }
        /// <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;
        }
Exemple #22
0
        /// <summary>
        /// Searches the sites search engine for movies.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchSite(Query query, int threadID, string logCatagory)
        {
            try
            {
                string xml;

                if (!string.IsNullOrEmpty(query.ImdbId))
                {
                    xml =
                        Downloader.ProcessDownload(
                            string.Format(
                                "http://api.themoviedb.org/2.1/Movie.imdbLookup/en/xml/{0}/{1}",
                                Settings.ConstSettings.Application.TheMovieDBApi,
                                query.ImdbId),
                            DownloadType.Html,
                            Section.Movies);
                }
                else
                {
                    xml =
                        Downloader.ProcessDownload(
                            string.Format(
                                "http://api.themoviedb.org/2.1/Movie.search/en/xml/{0}/{1}",
                                Settings.ConstSettings.Application.TheMovieDBApi,
                                query.Title),
                            DownloadType.Html,
                            Section.Movies);
                }

                if (string.IsNullOrEmpty(xml))
                {
                    return false;
                }

                XDocument xmlDoc = XDocument.Parse(xml);

                var movies = from m in xmlDoc.Descendants("movie") select m;

                foreach (var movie in movies)
                {
                    var title = movie.Element("name").Value;
                    var releaseDate = movie.Element("released").Value;
                    var imdbID = movie.Element("imdb_id").Value;
                    var tmdbId = movie.Element("id").Value;
                    var additionalDetails = movie.Element("overview").Value;

                    XDocument xmlDocImages = XDocument.Parse(movie.ToString());

                    var images = (from i in xmlDocImages.Descendants("image")
                                  where 
                                    i.Attribute("type").Value == "poster" && 
                                    i.Attribute("size").Value == "cover"
                                  select i.Attribute("url").Value).ToList();

                    var queryResult = new QueryResult();
                    DateTime releaseParse;
                    var reseaseParseSuccess = DateTime.TryParse(releaseDate, out releaseParse);

                    queryResult.Title = title;

                    if (reseaseParseSuccess)
                    {
                        queryResult.Year = releaseParse.Year;
                        queryResult.ReleaseDate = releaseParse;
                    }

                    queryResult.AdditionalInfo = additionalDetails;
                    queryResult.ImdbID = imdbID.ToLower().Replace("tt", string.Empty);
                    queryResult.TmdbID = tmdbId;

                    if (images.Count > 0)
                    {
                        queryResult.PosterUrl = images[0];
                    }

                    query.Results.Add(queryResult);
                }

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #23
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public new bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            try
            {
                query.Results =
                    Bing.SearchBing(
                        string.Format("{0} {1} site:filmup.leonardo.it/", query.Title, query.Year),
                        "http://filmup.leonardo.it/sc_",
                        threadID,
                        @"FilmUP\s-\sScheda:\s(?<title>.*?)$",
                        @"FilmUP\s-\sScheda:\s(?<title>.*?)$",
                        @"http://filmup\.leonardo\.it/sc_(?<id>.*?)\.htm",
                        ScraperList.FilmUp);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }
Exemple #24
0
        /// <summary>
        /// Searches bing for the scraper MovieUniqueId.
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="logCatagory">The log catagory.</param>
        /// <returns>[true/false] if an error occurred.</returns>
        public bool SearchViaBing(Query query, int threadID, string logCatagory)
        {
            query.Results = new BindingList<QueryResult>();

            try
            {
                if (query.Year == "0")
                {
                    query.Year = string.Empty;
                }

                query.Results = Bing.SearchBing(
                    string.Format(CultureInfo.CurrentCulture, BingSearchQuery, query.Title, query.Year),
                    BingMatchString,
                    threadID,
                    BingRegexMatchTitle,
                    BingRegexMatchYear,
                    BingRegexMatchID,
                    ScraperName);

                return query.Results.Count > 0;
            }
            catch (Exception ex)
            {
                Log.WriteToLog(LogSeverity.Error, threadID, logCatagory, ex.Message);
                return false;
            }
        }