Ejemplo n.º 1
0
        static void ConvertToBase64Image()
        {
            MovieEntities db = new MovieEntities();

            foreach (PosterInfo poster in db.PosterInfoes)
            {
                if (poster.Imdb != null && !string.IsNullOrWhiteSpace(poster.Imdb))
                {
                    string base64 = ImageToByteArray(poster.Imdb);
                    poster.LocalPath = base64;
                    db.SaveChanges();
                }
            }
        }
Ejemplo n.º 2
0
        static void LoadDataIntoDb()
        {
            string        inputpath   = "C:\\Users\\PrashMaya\\Desktop\\IMDBMovieTitleIds-0-2500.txt";
            string        inputfolder = "C:\\Users\\PrashMaya\\My Documents\\First2500MoviesIMDB\\Movie{0}.txt";
            MovieEntities db          = new MovieEntities();

            for (int i = 0; i < 2450; i++)
            {
                string  currentFile = string.Format(inputfolder, i);
                string  text        = System.IO.File.ReadAllText(@inputpath);
                dynamic obj         = ConvertToObj(text);
                Movie   movie       = new Movie();
                movie.PlotDetailed = obj[0]["plot"];
            }
        }
Ejemplo n.º 3
0
        static void DeleteDups()
        {
            MovieEntities    db     = new MovieEntities();
            HashSet <string> movies = new HashSet <string>();
            var dups = db.Movies.GroupBy(i => i.ImdbID).Where(x => x.Count() > 1).Distinct();

            foreach (var movie in db.Movies)
            {
                var test = db.Movies.Where(p => p.Title == "Peter Pan");
                var q    = test.ToList();
                if (q.Count > 1)
                {
                    //var delete =
                    for (int k = 1; k < q.Count(); k++)
                    {
                        try
                        {
                            var  movies1 = q.ToList();
                            long tempid  = movies1.ElementAt(k).ID;
                            //// TODO: This query is to find the valid record which should not be deleted inside the posterinfo class
                            var validPosterInfo = (from h in db.PosterInfoes
                                                   where h.MovieId == tempid
                                                   select h).ToList();
                            if (validPosterInfo.Count() == 0)
                            {
                                db.Movies.Remove(q.ElementAt(k));
                                db.SaveChanges();
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.Message);
                        }
                    }
                }
            }

            foreach (var item in movies)
            {
                var m = db.Movies.Where(s => s.ImdbID == item);
                db.Movies.Remove(m.First());
                db.SaveChanges();
            }
            Console.WriteLine(movies.Count());
        }
        public static void Download()
        {
            string serverPath         = @"C:\Users\PrashMaya\Pictures\MovieRecommendation\";
            string localFilenameImdb  = @"C:\Users\PrashMaya\Pictures\MovieRecommendation\{0}.jpg";
            string localFilenameCover = @"C:\Users\PrashMaya\Pictures\MovieRecommendation\Cover-{0}.jpg";
            var    db = new MovieEntities();
            int    i  = 0;

            foreach (var poster in db.PosterInfoes)
            {
                using (MyWebClient client = new MyWebClient())
                {
                    try
                    {
                        if (poster.Imdb != null)
                        {
                            var imdbId = db.Movies.Where(m => m.ID == poster.MovieId).ToList();
                            //imdbId = db.Movies.Where(s => s.ID == poster.MovieId).ToList();
                            int count = imdbId.Count();
                            serverPath         = string.Format(serverPath, imdbId.First().ImdbID);
                            localFilenameImdb  = string.Format(localFilenameImdb, imdbId.First().ImdbID);
                            localFilenameCover = string.Format(localFilenameCover, imdbId.First().ImdbID);

                            //if (!Directory.Exists(serverPath))
                            //    Directory.CreateDirectory(serverPath);

                            client.DownloadFile(poster.Imdb, localFilenameImdb);
                            i++;
                            localFilenameImdb = @"C:\Users\PrashMaya\Pictures\MovieRecommendation\{0}.jpg";
                            //serverPath = @"C:\Users\PrashMaya\Pictures\{0}\";
                        }
                        //client.DownloadFile(poster.Cover, localFilenameCover);
                    }
                    catch (Exception ex)
                    {
                        i++;
                        continue;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public static void run()
 {
     var db = new MovieEntities();
 }