Example #1
0
        private static void SearchFileName()
        {
            foreach (var movie in Movies)
            {
                string userConfirmation = "no";
                string searchTerm = "";
                OmdbResponseModel searchResult = new OmdbResponseModel();
                while (userConfirmation != "yes" && searchTerm != "skip")
                {
                    Console.WriteLine("Title: " + movie.OldFileName);
                    Console.WriteLine("What should I search for? You may also skip this title by typing 'skip'");
                    SearchModel SM = new SearchModel();
                     searchTerm = Console.ReadLine();
                    if (searchTerm != "skip")
                    {
                        SM.Name = searchTerm;
                        searchResult = omdbRequest.Search(SM);
                        Console.WriteLine(searchResult.ToString());
                        Console.WriteLine("Are you happy with this result?  yes, no, or skip?");
                        userConfirmation = Console.ReadLine();
                    }

                }

                if (userConfirmation == "yes")
                {
                    movie.Title = searchResult.Title;
                    movie.Year = searchResult.Year;
                    movie.Rated = searchResult.Rated;
                    movie.Released = searchResult.Released;
                    movie.Runtime = searchResult.Runtime;
                    movie.Genre = searchResult.Genre;
                    movie.Director = searchResult.Director;
                    movie.Writer = searchResult.Writer;
                    movie.Actors = searchResult.Actors;
                    movie.Plot = searchResult.Plot;
                    movie.Language = searchResult.Language;
                    movie.Country = searchResult.Country;
                    movie.Awards = searchResult.Awards;
                    movie.Poster = searchResult.Poster;
                    movie.Metascore = searchResult.Metascore;
                    movie.ImdbRating = searchResult.ImdbRating;
                    movie.ImdbVotes = searchResult.ImdbVotes;
                    movie.Type = searchResult.Type;

                    var responseCode= FileManipulation.Rename(movie);
                    if (responseCode)
                    {
                        Console.WriteLine("Rename was a success");
                    }
                    else
                    {
                        Console.WriteLine("Rename failed");
                    }

                }

            }
        }
Example #2
0
        static OmdbResponseModel Converter(string response)
        {
            OmdbResponseModel RM = new OmdbResponseModel();

            var json = (IDictionary<string, string>)JsonConvert.DeserializeObject(response, typeof(IDictionary<string, string>));
            try
            {
                RM.Title = json["Title"];
            }
            catch { }
            try
            {
                RM.Year = json["Year"];
            }
            catch { }
            try
            {
                RM.Rated = json["Rated"];
            }
            catch { }
            try
            {
                RM.Released = json["Released"];
            }
            catch { }
            try
            {
                RM.Runtime = json["Runtime"];
            }
            catch { }
            try
            {
                RM.Genre = json["Genre"];
            }
            catch { }
            try
            {
                RM.Director = json["Director"];
            }
            catch { }
            try
            {
                RM.Writer = json["Writer"];
            }
            catch { }
            try
            {
                RM.Actors = json["Actors"];
            }
            catch { }
            try
            {
                RM.Plot = json["Plot"];
            }
            catch { }
            try
            {
                RM.Language = json["Language"];
            }
            catch { }
            try
            {
                RM.Country = json["Country"];
            }
            catch { }
            try
            {
                RM.Awards = json["Awards"];
            }
            catch { }
            try
            {
                RM.Poster = json["Poster"];
            }
            catch { }
            try
            {
                RM.Metascore = json["Metascore"];
            }
            catch { }
            try
            {
                RM.ImdbRating = json["imdbRating"];
            }
            catch { }
            try
            {
                RM.ImdbVotes = json["imdbVotes"];
            }
            catch { }
            try
            {
                RM.Type = json["Type"];
            }
            catch { }
            try
            {
                RM.Response = json["Response"];
            }
            catch { }

            return RM;
        }