Ejemplo n.º 1
0
        public List<Movie> GetMovies()
        {
            var movies = new List<Movie>();

            string[] folders = Directory.GetDirectories(_fullpath, "*", SearchOption.TopDirectoryOnly);

            foreach (string folder in folders)
            {
                Movie m;

                // check if exactly one .nfo file is found. if so, read it. no subfolders
                string[] nfofile = Directory.GetFiles(folder, "*.nfo", SearchOption.TopDirectoryOnly);
                if (nfofile.Length == 1)
                {
                    // exactly 1 found, so read the file and create a movie object
                    m = NFOFile.ReadNFO(nfofile[0]);
                    m.OriginalFolder = folder;
                }
                else
                {
                    // no, or multiple NFO files. Ignore them and create an empty movie object
                    m = new Movie();
                    m.OriginalFolder = folder;
                    m.Title = NameExtractor.ExtractMovieName(folder.Substring(folder.LastIndexOf('\\') + 1));
                }

                movies.Add(m);
            }

            return movies;
        }
Ejemplo n.º 2
0
        public Movie GuessMovieandAskUser(string guessName)
        {
            // ask tmdb client to search for possible movies
            var possibleMovies = _client.SearchMovie(guessName).Results;

            // if no movies found, return null
            if (possibleMovies.Count == 0)
            {
                return null;
            }

            // 1 or more movies found. loop over all the found movies, and put the titles in a list
            var listitems = new List<ListItemObject>();
            foreach (SearchMovie mov in possibleMovies)
            {
                listitems.Add(new ListItemObject(mov.Title, mov));
            }

            // create dialog and pass list of movies
            SelectMovie dialog = new SelectMovie(listitems);
            DialogResult res = dialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                // get selected item in the listbox, and the dataitem that belongs to it
                SearchMovie searchmov = (SearchMovie)dialog.GetSelectedItem().DataObject;

                // get additional info (used for imdb id)
                TMDbLib.Objects.Movies.Movie tmdbmovie = _client.GetMovie(searchmov.Id);

                // fill a new movie object with the data from the website
                Movie m = new Movie();
                m.Title = searchmov.Title;
                m.ReleaseDate = searchmov.ReleaseDate;
                m.IMDBMovieId = tmdbmovie.ImdbId;

                return m;
            }

            // user closed the selection form.
            return null;
        }