예제 #1
0
        public List<Youtube> getYoutubeTrailerURL(Movie currentMovie)
        {
            bool noExist = false;
            int TmdbID = 0;
            List<Youtube> youtube = new List<Youtube>();
            Tmdb api = new Tmdb(mApiKey, "en");

            if (currentMovie.TmdbID == null)
            {
                // Search TMDB by title + year for correct movie ID
                TmdbMovieSearch movie = api.SearchMovie(currentMovie.Title, 1);
                List<MovieResult> movieResults = movie.results;
                if (movieResults.Count != 0)
                {
                    TmdbID = movieResults[0].id;
                }
                else
                {
                    noExist = true;
                }
            }
            else
            {
                // Parse String TMDBID to Int
                int.TryParse(currentMovie.TmdbID, out TmdbID);
            }

            if (noExist == false)
            {
                TmdbMovieTrailers trailers = api.GetMovieTrailers(TmdbID);
                if (trailers != null)
                {
                    if (trailers.youtube != null)
                    {
                        youtube = trailers.youtube;
                    }
                    else
                    {
                        youtube = null;
                    }
                }
                else
                {
                    youtube = null;
                }
            }
            else
            {
                youtube = null;
            }
            return youtube;
        }
예제 #2
0
        public List<Movie> ScanCollection(System.IO.DirectoryInfo collectionPath)
        {
            List<Movie> Movies = new List<Movie>();
            System.IO.DirectoryInfo[] movieDirs = null;
            System.IO.FileInfo[] metaFile = null;
            System.IO.DirectoryInfo[] trailerDir = null;
            System.IO.FileInfo[] trailerFile = null;

            if (collectionPath.Exists)
            {
                movieDirs = collectionPath.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in movieDirs)
                {
                    Movie tempMovie = new Movie();

                    tempMovie.MoviePath = dirInfo.FullName;

                    if (!dirInfo.Name.Contains("System Volume Information"))
                    {

                        metaFile = dirInfo.GetFiles("mymovies.xml");
                        if (metaFile.Count() != 0)
                        {
                            tempMovie.MetaFile = metaFile[0].FullName;

                            // Create new MetaXML Object
                            MetaXML MetaXML = new MetaXML();

                            // Extract MetaInfo from XML File and store in MetaXML object
                            MetaXML.ExtractMeta(metaFile[0].FullName);

                            // Set TempMovie Attributes with Meta Data from MetaXML Object
                            if (MetaXML.MetaTitle != null)
                            {
                                MetaXML.MetaTitle = MetaXML.MetaTitle.Trim();
                                if (MetaXML.MetaTitle.Length != 0)
                                {
                                    tempMovie.Title = MetaXML.MetaTitle;
                                }
                                else
                                {
                                    tempMovie.Title = dirInfo.Name;
                                }
                            }
                            else
                            {
                                tempMovie.Title = dirInfo.Name;
                            }
                            tempMovie.Year = MetaXML.MetaYear;
                            tempMovie.TmdbID = MetaXML.MetaTmdbID;
                            tempMovie.ImdbID = MetaXML.MetaImdbID;

                            trailerDir = dirInfo.GetDirectories("trailers");
                            if (trailerDir.Count() != 0)
                            {
                                tempMovie.TrailerPath = trailerDir[0].FullName;
                                trailerFile = trailerDir[0].GetFiles("*.*");
                                if (trailerFile.Count() != 0)
                                {
                                    tempMovie.TrailerFile = trailerFile[0].FullName;
                                    tempMovie.TrailerExists = true;
                                }
                            }

                            Movies.Add(tempMovie);
                            tempMovie = null;
                        }
                        else
                        {
                            tempMovie.Title = dirInfo.Name;
                        }
                    }
                }
            }
            return Movies;
        }