protected static Movie BuildMovieObject(MoviesOnIMDBInfo info) { var movie = new Movie { Id = Convert.ToInt64(info.id), Title = info.title }; return movie; }
public void mappenOphalen() { String[] standaardVid = Directory.GetDirectories(myvideo); foreach (string dir in standaardVid) { String filmItem = dir.ToString(); Movie m = new Movie(); m.OriginalFolder = dir; filmItem = filmItem.Substring(filmItem.LastIndexOf("\\") + 1); filmItem = filmItem.Replace("_", " "); filmItem = filmItem.Replace(".", " "); if (filmItem.Contains("(")) { filmItem = filmItem.Remove(filmItem.LastIndexOf("(")); } if (filmItem.Contains("20")) { filmItem = filmItem.Remove(filmItem.LastIndexOf("20")); } if (filmItem.Contains("19")) { filmItem = filmItem.Remove(filmItem.LastIndexOf("19")); } listBox1.Items.Add(filmItem); filmLijst.Add(filmItem); } }
public Movie NFOLezer() { Movie m = new Movie(); string orgineleMap = filmbestand()[listBox1.SelectedIndex]; string NFOPad = orgineleMap + "\\movie.nfo"; if (File.Exists(NFOPad)) { //uitlezen van nfo bestand XmlDataDocument xmlDoc = new XmlDataDocument(); XmlNode xmlnodefilm; FileStream fs = new FileStream(NFOPad, FileMode.Open, FileAccess.Read); xmlDoc.Load(fs); xmlnodefilm = xmlDoc.ChildNodes[0]; XmlNode xmlnodeTitle = xmlnodefilm.SelectSingleNode("title"); m.MovieTitle = xmlnodeTitle.InnerText; XmlNode xmlnodeIMDBScore = xmlnodefilm.SelectSingleNode("IMDBScore"); m.movieRating = xmlnodeIMDBScore.InnerText; XmlNode xmlnodeRelease = xmlnodefilm.SelectSingleNode("release"); m.movieReleaseDate = xmlnodeRelease.InnerText; XmlNode xmlnodePlot = xmlnodefilm.SelectSingleNode("plot"); m.moviePlot = xmlnodePlot.InnerText; XmlNode xmlnodeBoxcover = xmlnodefilm.SelectSingleNode("boxcover"); m.movieBoxCover = xmlnodeBoxcover.InnerText; XmlNode xmlnodeBackDrop = xmlnodefilm.SelectSingleNode("backdrop"); m.movieBackDrop = xmlnodeBackDrop.InnerText; } //string filmInformatie = m.movieRating + Environment.NewLine + m.movieReleaseDate + Environment.NewLine + Environment.NewLine + m.moviePlot; return m; }
public void identificeerfilm() { //mylist wordt leeggemaakt voor gebruik myList.Clear(); var filmMap = Directory.GetDirectories(myvideo); if (filmPadVanGekozenMap == null) { filmMap = Directory.GetDirectories(myvideo); } else { filmMap = Directory.GetDirectories(filmPadVanGekozenMap); } //geselecteerd item uit de filmlijst wordt geselecteerd string selectedItem = listBox1.SelectedItem.ToString(); if (!File.Exists(filmMap[listBox1.SelectedIndex] + ("\\movie.nfo"))) { //foreach loop die alle resulaten in de listbox zet var resultaat = client.SearchMovie(selectedItem).Results; foreach (SearchMovie mov in resultaat) { Movie m = new Movie(); m.MovieObject = mov; m.DisplayName = mov.Title; m.MovieId = mov.Id.ToString(); m.moviePlot = mov.Overview; m.movieBoxCover = mov.PosterPath; m.OriginalFolder = filmMap[listBox1.SelectedIndex]; m.movieBackDrop = mov.BackdropPath; m.movieRating = mov.VoteAverage.ToString(); m.movieReleaseDate = mov.ReleaseDate.ToString(); myList.Add(m); } //alle gevonden films worden in een lijst gezet en vervolgens wordt nr.1 gekozen als film if (myList.Count != 0) { Movie selectedMovieObject = myList[0]; string orgineleNaam = listBox1.GetItemText(listBox1.SelectedItem); if (selectedMovieObject.movieRating != "0") { selectedMovieObject.movieRating = "IMDB Score " + selectedMovieObject.DisplayName + ": " + selectedMovieObject.movieRating; } else { selectedMovieObject.movieRating = "Er is geen filmscore gevonden voor deze film."; } if (selectedMovieObject.movieReleaseDate != "") { selectedMovieObject.movieReleaseDate = selectedMovieObject.movieReleaseDate.Remove(selectedMovieObject.movieReleaseDate.Length - 9); selectedMovieObject.movieReleaseDate = "Release: " + selectedMovieObject.movieReleaseDate; } else { selectedMovieObject.movieReleaseDate = "Helaas is de releasedatum niet gevonden voor deze film"; } //downloaden van boxcover if (selectedMovieObject.movieBoxCover != null && !File.Exists(filmMap[listBox1.SelectedIndex].ToString() + "\\")) { webClient.DownloadFile("https://image.tmdb.org/t/p/original" + selectedMovieObject.movieBoxCover, filmMap[listBox1.SelectedIndex].ToString() + selectedMovieObject.movieBoxCover); BoxCoverPicBox.Load(filmMap[listBox1.SelectedIndex].ToString() + "\\" + selectedMovieObject.movieBoxCover); } else { BoxCoverPicBox.Load(filmMap[listBox1.SelectedIndex].ToString() + "\\" + selectedMovieObject.movieBoxCover); } if (selectedMovieObject.movieBackDrop != null && !File.Exists(filmMap[listBox1.SelectedIndex].ToString() + "\\")) { webClient.DownloadFile("https://image.tmdb.org/t/p/original" + selectedMovieObject.movieBackDrop, filmMap[listBox1.SelectedIndex].ToString() + selectedMovieObject.movieBackDrop); pictureBox2.Load(filmMap[listBox1.SelectedIndex].ToString() + "\\" + selectedMovieObject.movieBackDrop); } // osdb api haalt ondertitels op try { string imdbID = client.GetMovie(selectedMovieObject.MovieId).ImdbId.Substring(2); var osdbClient = Osdb.Login("nl", "OSTestUserAgent"); var ophalenOndertitels = osdbClient.SearchSubtitlesFromImdb("dut", imdbID); var engelseOndertitles = osdbClient.SearchSubtitlesFromImdb("eng", imdbID); if (ophalenOndertitels.Count != 0) { string ondertitelLink = ophalenOndertitels[0].SubTitleDownloadLink.ToString().Replace(".gz", ".srt"); string orgineleMap = filmMap[listBox1.SelectedIndex].ToString() + "\\"; if (!File.Exists(orgineleMap + ophalenOndertitels[0].SubtitleFileName)) { webClient.DownloadFile(ondertitelLink, orgineleMap + ophalenOndertitels[0].SubtitleFileName); } } else if(engelseOndertitles.Count != 0) { string engelseOndertitelLink = engelseOndertitles[0].SubTitleDownloadLink.ToString().Replace(".gz", ".srt"); string orgineleMap = filmMap[listBox1.SelectedIndex].ToString() + "\\"; if (!File.Exists(orgineleMap + engelseOndertitles[0].SubtitleFileName)) { webClient.DownloadFile(engelseOndertitelLink, orgineleMap + engelseOndertitles[0].SubtitleFileName); } } else { MessageBox.Show("Helaas waren er geen ondertitels gevonden!"); } } catch (Exception ex) { MessageBox.Show("Ondertitles konden niet worden opgehaald, " + ex.Message); } } else { MessageBox.Show("Geen films gevonden met de titel " + selectedItem); } NFOMaker(); Movie nfoData = NFOLezer(); FilmPlot.Text = nfoData.movieRating + Environment.NewLine + nfoData.movieReleaseDate + Environment.NewLine + Environment.NewLine + nfoData.moviePlot; } else { //nfo bestand laden Movie nfoData = NFOLezer(); var gekozenMap = filmbestand(); FilmPlot.Text = nfoData.movieRating + Environment.NewLine + nfoData.movieReleaseDate + Environment.NewLine + Environment.NewLine + nfoData.moviePlot; BoxCoverPicBox.Load(gekozenMap[listBox1.SelectedIndex] + "\\" + nfoData.movieBoxCover); if (nfoData.movieBackDrop != null) { pictureBox2.Load(filmMap[listBox1.SelectedIndex].ToString() + "\\" + nfoData.movieBackDrop); } } }