public bool Populate(Movie movie, ImagesWithId imgs)
        {
            try
            {
                Images = new List<MovieDB_Image_Result>();

                MovieID = movie.Id;
                MovieName = movie.Title;
                OriginalName = movie.Title;
                Overview = movie.Overview;

                if (imgs != null && imgs.Backdrops != null)
                {
                    foreach (ImageData img in imgs.Backdrops)
                    {
                        MovieDB_Image_Result imageResult = new MovieDB_Image_Result();
                        if (imageResult.Populate(img, "backdrop"))
                            Images.Add(imageResult);
                    }
                }

                if (imgs != null && imgs.Posters != null)
                {
                    foreach (ImageData img in imgs.Posters)
                    {
                        MovieDB_Image_Result imageResult = new MovieDB_Image_Result();
                        if (imageResult.Populate(img, "poster"))
                            Images.Add(imageResult);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error( ex,ex.ToString());
                return false;
            }

            return true;
        }
Example #2
0
        public void cacheVideo(Movie movie)
        {
            try
            {
                
                /*
                //check if exists
                bool exists = false;
               // var movieJson = Newtonsoft.Json.JsonConvert.SerializeObject(movie);
                string line;
               // StreamReader file = new StreamReader(videosCache);
               // while ((line = file.ReadLine()) != null)
                {
                    var myLine = Newtonsoft.Json.JsonConvert.SerializeObject(line);
                    if (myLine == movieJson)
                        exists = true;
                }
                file.Dispose();
                if (!exists) {
                    using (System.IO.StreamWriter file2 = new System.IO.StreamWriter(videosCache))
                    {
                        file2.WriteLine(movieJson);
                    }
                }
                */
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }

        }
Example #3
0
        private void addToMyVideos(string Name, string Year, string Season, string Episode)
        {

            this.labelTotalMyVideos.Invoke(new UIUpdaterDelegate(() =>
            {
                this.labelTotalMyVideos.Text = "My Videos: " + MoviesManager.MyMoviesCount.ToString();
            }));

            TMDbLib.Objects.Movies.Movie aMovie = new TMDbLib.Objects.Movies.Movie();
            Name = MovieCleaner.justMovieName(Name, Year);
            aMovie = MyMovie.loadTMDbLib(Name);
            if (MyMovie.lastImage != null)
            {
                //MyMoviesCollection.Add(aMovie);
                if (aMovie != null)
                {
                    if (!File.Exists(MySettings + "//cache//"))
                        AddOneEntryToMyVideos(aMovie, MyMovie.lastImage);
                }
                else
                    return;
            }
            /*


            Season = Season.Replace("S", "");
            Episode = Episode.Replace("E", "");
            if (Season == "")
                Season = "01";
            string RunTime = "";
            string Rating = "";
            string Title = "";
            string Description = "";
            string SmallImage = "";
            string RegularImage =  "http://blogs.ncs-nj.org/k4stemlab/files/2013/04/image-unavailable.jpg";
            string URL = "";
            string number = "";
            string IMDBRating = "";
            string ComingSoon = "";
            string TheaterStatus = "";
            string Trailers = "";
            string TheAirDate = "";
            string TheEpisodeTitle = "";
            string SeasonCover = "";
            Int32 theYear = 0;
            string Genres = "";
            if (Episode == "")
                Episode = "0";

            Name = MovieCleaner.justMovieName(Name, Year);
            //locate the movie in the database 
            string postInfo = "Title=" + Name + "&Submit=QueryMovie";
            HTTP http = new HTTP();
            string response = http.DoPOST("https://secure2025.hostgator.com/~czzplnm/moviemanager.php", postInfo);

            string[] Data = response.Split('|');

            if (Data.Length >= 13)
            {
                createMyMovie(Data[5], Data[8], Data[2], Data[4], Convert.ToInt32(Data[3]), Convert.ToInt16(Data[0]), Data[7], Data[6], Data[1], Data[12], Data[11], Data[10], Data[9], Data[13], TheEpisodeTitle, TheAirDate, 0, 0, SeasonCover);
                this.labelTotalMyVideos.Invoke(new UIUpdaterDelegate(() =>
                    {
                        this.labelTotalMyVideos.Text = "My Videos: " + MoviesManager.MyMoviesCount.ToString();
                    }));
            }*/
            //aMovie.loadConfig();//search moviedb
            //  if (!aMovie.loadMyMovieFromFile(Name, Year, Season, Episode))
            //  {
            //  aMovie.loadTMDbLib(Name, this);
            //aMovie.loadMovieDB(Name);
            /*
            if (!aMovie.loadOMDB(Name))
            {

                if(!aMovie.loadTvShowID(Name))       
                    aMovie.loadMovieID(Name);




            }
            */


            //}
            /*
            if (checkBoxIgnoreMovies.Checked)
                if (aMovie.movieType == MyMovie.mType.themoviedbMovie)
                    return;

            if (checkBoxIgnoreTVShows.Checked)
                if (aMovie.movieType == MyMovie.mType.themoviedbTV)
                    return;
                        

            if (aMovie.Image != null)
            {
                MyMoviesCollection.Add(aMovie);
                AddOneEntryToMyVideos(aMovie);
            }
                  */

            /*
             
                JToken titleToken = token.SelectToken("Title");
                if (titleToken != null)
                {
                    Title = titleToken.ToString();
                    int itemYear = (int)token.SelectToken("Year");
                }
                Int16 IntSeason = Convert.ToInt16(Season);
                Int16 IntEpisode = Convert.ToInt16(Episode);
            */
            //   createMyMovie(SmallImage, number, Title, Description, MoviesManager.CleanYear(theYear.ToString()), MoviesManager.CleanRuntime(RunTime), URL, RegularImage, Rating, TheaterStatus, ComingSoon, IMDBRating, Genres, Trailers, TheEpisodeTitle, TheAirDate, IntSeason, IntEpisode, SeasonCover);

        }
        public WriteMovieInfoToXML(Movie movie, string folder)
        {
            TMDbClient client = new TMDbClient("a8fab4f9461636422a8df05bf17065a8");
            var actors = movie.Credits.Cast;
            var crews = movie.Credits.Crew;
            string _year;

            string[] files = Directory.GetFiles(folder, "*", SearchOption.TopDirectoryOnly);
            List<string> videoFiles = new List<string>();
            foreach (var file in files)
            {
                if (file.EndsWith(".mp4"))
                {
                    videoFiles.Add(file);
                }
                if (file.EndsWith(".mkv"))
                {
                    videoFiles.Add(file);
                }
                if (file.EndsWith(".avi"))
                {
                    videoFiles.Add(file);
                }
            }
            string nfile = null;
            if (videoFiles.Count == 1)
            {
                int index = videoFiles[0].LastIndexOf("\\");
                nfile = videoFiles[0].Substring(index + 1);
                Console.WriteLine(nfile);
            }

            if (movie.ReleaseDate != null)
            {
                _year = ((DateTime)movie.ReleaseDate).Year.ToString();
            }
            else
            {
                _year = "Unkown year";
            }
            var settings = new XmlWriterSettings
            {
                Indent = true,
                OmitXmlDeclaration = true,
                NewLineOnAttributes = true
            };
            using (XmlWriter writer = XmlWriter.Create(folder + "\\"+ nfile.Substring(0,nfile.Length-4) + ".nfo", settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("movie");
                writer.WriteElementString("title", movie.Title);
                writer.WriteElementString("originaltitle", movie.OriginalTitle);
                writer.WriteElementString("rating", movie.VoteAverage.ToString());
                writer.WriteElementString("votes", movie.VoteCount.ToString());
                writer.WriteElementString("year", _year);
                writer.WriteElementString("plot", movie.Overview);
                writer.WriteElementString("tagline", movie.Tagline);
                writer.WriteElementString("runtime", movie.Runtime.ToString());
                writer.WriteElementString("thumb", "https://image.tmdb.org/t/p/original" + movie.PosterPath);
                writer.WriteElementString("filenameandpath", folder + "\\" + nfile);
                foreach (var genre in movie.Genres)
                {
                    writer.WriteElementString("genre", genre.Name);
                }
                foreach (var actor in actors)
                {
                    writer.WriteStartElement("actor");
                    writer.WriteElementString("name", actor.Name);
                    writer.WriteElementString("role", actor.Character);
                    writer.WriteEndElement();
                }
                foreach (var crew in crews)
                {
                    writer.WriteStartElement("crew");
                    writer.WriteElementString("name", crew.Name);
                    writer.WriteElementString("job", crew.Job);
                    writer.WriteEndElement();
                }
                writer.WriteElementString("dateadded", DateTime.Now.ToString());
                writer.WriteEndElement();
                writer.WriteEndDocument();
            }
        }