Esempio n. 1
0
        public static List <MovieDB_Movie_Result> Search(string criteria)
        {
            List <MovieDB_Movie_Result> results = new List <MovieDB_Movie_Result>();

            try
            {
                TMDbClient client = new TMDbClient(apiKey);
                SearchContainer <SearchMovie> resultsTemp = client.SearchMovie(criteria);

                Console.WriteLine("Got {0} of {1} results", resultsTemp.Results.Count, resultsTemp.TotalResults);
                foreach (SearchMovie result in resultsTemp.Results)
                {
                    MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                    Movie        movie = client.GetMovie(result.Id);
                    ImagesWithId imgs  = client.GetMovieImages(result.Id);
                    searchResult.Populate(movie, imgs);
                    results.Add(searchResult);
                    SaveMovieToDatabase(searchResult, false);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in MovieDB Search: " + ex.Message);
            }

            return(results);
        }
Esempio n. 2
0
        public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages)
        {
            try
            {
                string url = string.Format(InfoURL, apiKey, movieID);
                // Search for a movie
                string xmlSearch = Utils.DownloadWebPage(url);

                XmlDocument docSearchResult = new XmlDocument();
                docSearchResult.LoadXml(xmlSearch);

                bool hasData = docSearchResult["OpenSearchDescription"]["movies"].HasChildNodes;
                if (hasData)
                {
                    XmlNodeList movies = docSearchResult["OpenSearchDescription"]["movies"].GetElementsByTagName("movie");

                    XmlNode movie = movies[0];
                    MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                    if (searchResult.Populate(movie))
                    {
                        // save to the DB
                        SaveMovieToDatabase(session, searchResult, saveImages);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.ErrorException("Error in ParseBanners: " + ex.ToString(), ex);
            }
        }
Esempio n. 3
0
        public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages)
        {
            try
            {
                TMDbClient   client = new TMDbClient(apiKey);
                Movie        movie  = client.GetMovie(movieID);
                ImagesWithId imgs   = client.GetMovieImages(movieID);

                MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                searchResult.Populate(movie, imgs);

                // save to the DB
                SaveMovieToDatabase(session, searchResult, saveImages, false);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error in ParseBanners: " + ex.ToString());
            }
        }
Esempio n. 4
0
        public static List <MovieDB_Movie_Result> Search(string criteria)
        {
            List <MovieDB_Movie_Result> results = new List <MovieDB_Movie_Result>();

            try
            {
                string url = string.Format(SearchURL, apiKey, criteria.Trim());
                // Search for a movie
                string xmlSearch = Utils.DownloadWebPage(url);

                XmlDocument docSearchResult = new XmlDocument();
                docSearchResult.LoadXml(xmlSearch);

                bool hasData = docSearchResult["OpenSearchDescription"]["movies"].HasChildNodes;
                if (hasData)
                {
                    XmlNodeList movies = docSearchResult["OpenSearchDescription"]["movies"].GetElementsByTagName("movie");

                    foreach (XmlNode movieNode in movies)
                    {
                        MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                        if (searchResult.Populate(movieNode))
                        {
                            results.Add(searchResult);
                            SaveMovieToDatabase(searchResult, false);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in MovieDB Search: " + ex.Message);
            }

            return(results);
        }
Esempio n. 5
0
		public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages)
		{

			try
			{
                TMDbClient client = new TMDbClient(apiKey);
                Movie movie = client.GetMovie(movieID);
                ImagesWithId imgs = client.GetMovieImages(movieID);

                MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                searchResult.Populate(movie, imgs);

                // save to the DB
                SaveMovieToDatabase(session, searchResult, saveImages);
			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in ParseBanners: " + ex.ToString(), ex);
			}
		}
Esempio n. 6
0
		public static List<MovieDB_Movie_Result> Search(string criteria)
		{
			List<MovieDB_Movie_Result> results = new List<MovieDB_Movie_Result>();
			
			try
			{
                TMDbClient client = new TMDbClient(apiKey);
                SearchContainer<SearchMovie> resultsTemp = client.SearchMovie(criteria);

                Console.WriteLine("Got {0} of {1} results", resultsTemp.Results.Count, resultsTemp.TotalResults);
                foreach (SearchMovie result in resultsTemp.Results)
                {
                    MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                    Movie movie = client.GetMovie(result.Id);
                    ImagesWithId imgs = client.GetMovieImages(result.Id);
                    searchResult.Populate(movie, imgs);
                    results.Add(searchResult);
                    SaveMovieToDatabase(searchResult, false);
                }	

			}
			catch (Exception ex)
			{
				logger.Error("Error in MovieDB Search: " + ex.Message);
			}

			return results;
		}
Esempio n. 7
0
        public static List<MovieDB_Movie_Result> SearchWithTVShowID(int id, bool isTrakt)
        {
            List<MovieDB_Movie_Result> results = new List<MovieDB_Movie_Result>();

            try
            {
                TMDbClient client = new TMDbClient(apiKey);
                TvShow result = client.GetTvShow(id, TvShowMethods.Images, null);

                if (result != null)
                {

                    logger.Info("Got TMDB results for id: {0} | show name: {1}", id, result.Name);
                    MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
                    Movie movie = client.GetMovie(result.Id);
                    ImagesWithId imgs = client.GetMovieImages(result.Id);
                    searchResult.Populate(movie, imgs);
                    results.Add(searchResult);
                    SaveMovieToDatabase(searchResult, true, isTrakt);
                }
            }
            catch (Exception ex)
            {
                logger.Error("Error in MovieDB Search: " + ex.Message);
            }

            return results;
        }
Esempio n. 8
0
		public static List<MovieDB_Movie_Result> Search(string criteria)
		{
			List<MovieDB_Movie_Result> results = new List<MovieDB_Movie_Result>();
			
			try
			{
				string url = string.Format(SearchURL, apiKey, criteria.Trim());
				// Search for a movie
				string xmlSearch = Utils.DownloadWebPage(url);

				XmlDocument docSearchResult = new XmlDocument();
				docSearchResult.LoadXml(xmlSearch);

				bool hasData = docSearchResult["OpenSearchDescription"]["movies"].HasChildNodes;
				if (hasData)
				{
					XmlNodeList movies = docSearchResult["OpenSearchDescription"]["movies"].GetElementsByTagName("movie");

					foreach (XmlNode movieNode in movies)
					{
						MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
						if (searchResult.Populate(movieNode))
						{
							results.Add(searchResult);
							SaveMovieToDatabase(searchResult, false);
						}
					}

					
				}

			}
			catch (Exception ex)
			{
				logger.Error("Error in MovieDB Search: " + ex.Message);
			}

			return results;
		}
Esempio n. 9
0
		public static void UpdateMovieInfo(ISession session, int movieID, bool saveImages)
		{

			try
			{
				string url = string.Format(InfoURL, apiKey, movieID);
				// Search for a movie
				string xmlSearch = Utils.DownloadWebPage(url);

				XmlDocument docSearchResult = new XmlDocument();
				docSearchResult.LoadXml(xmlSearch);

				bool hasData = docSearchResult["OpenSearchDescription"]["movies"].HasChildNodes;
				if (hasData)
				{
					XmlNodeList movies = docSearchResult["OpenSearchDescription"]["movies"].GetElementsByTagName("movie");

					XmlNode movie = movies[0];
					MovieDB_Movie_Result searchResult = new MovieDB_Movie_Result();
					if (searchResult.Populate(movie))
					{
						// save to the DB
						SaveMovieToDatabase(session, searchResult, saveImages);
					}

				}

			}
			catch (Exception ex)
			{
				logger.ErrorException("Error in ParseBanners: " + ex.ToString(), ex);
			}
		}