Esempio n. 1
0
        private static DbMovieInfo GetMovieInformation(Tmdb api, TmdbMovie movieNode, string language)
        {
            LogMyFilms.Debug("GetMovieInformation() - language = '" + (language ?? "") + "'");

              if (movieNode == null) return null;
              DbMovieInfo movie = new DbMovieInfo();

              try
              {
            TmdbMovie m = api.GetMovieInfo(movieNode.id);

            movie.Identifier = m.id.ToString();
            movie.ImdbId = m.imdb_id;
            movie.Name = m.original_title;
            movie.TranslatedTitle = m.title;
            movie.AlternativeTitle = m.original_title;
            DateTime date;
            if (DateTime.TryParse(m.release_date, out date))
              movie.Year = date.Year;
            movie.DetailsUrl = m.homepage;
            movie.Summary = m.overview;
            movie.Score = (float)Math.Round(m.vote_average, 1);
            // movie.Certification = "";
            foreach (SpokenLanguage spokenLanguage in m.spoken_languages)
            {
              movie.Languages.Add(spokenLanguage.name);
            }
            movie.Runtime = m.runtime;

            TmdbMovieCast p = api.GetMovieCast(movieNode.id);

            foreach (Cast cast in p.cast)
            {
              string name = cast.name;
              string character = cast.character;
              DbPersonInfo personToAdd = new DbPersonInfo { Id = cast.id.ToString(), Name = cast.name, DetailsUrl = cast.profile_path };
              movie.Persons.Add(personToAdd);

              if (character.Length > 0) name = name + " (" + character + ")";
              movie.Actors.Add(name);
            }

            foreach (Crew crew in p.crew)
            {
              DbPersonInfo personToAdd = new DbPersonInfo { Id = crew.id.ToString(), Name = crew.name, DetailsUrl = crew.profile_path };
              movie.Persons.Add(personToAdd);
              switch (crew.department)
              {
            case "Production":
              movie.Producers.Add(crew.name);
              break;
            case "Directing":
              movie.Directors.Add(crew.name);
              break;
            case "Writing":
              movie.Writers.Add(crew.name);
              break;
            case "Sound":
            case "Camera":
              break;
              }
            }

            foreach (Cast cast in p.cast)
            {
              string name = cast.name;
              string character = cast.character;
              string thumb = cast.profile_path;
              string job = cast.character;
              string id = cast.id.ToString();
              string url = cast.profile_path;
              var personToAdd = new DbPersonInfo { Id = id, Name = name, DetailsUrl = url, Job = job };
              movie.Persons.Add(personToAdd);
              switch (job)
              {
            case "Producer":
              movie.Producers.Add(name);
              break;
            case "Director":
              movie.Directors.Add(name);
              break;
            case "Actor":
              if (character.Length > 0)
                name = name + " (" + character + ")";
              movie.Actors.Add(name);
              break;
            case "Screenplay":
              movie.Writers.Add(name);
              break;
              }
            }
            foreach (ProductionCountry country in m.production_countries)
            {
              movie.Country.Add(country.name);
            }
            foreach (MovieGenre genre in m.genres)
            {
              movie.Country.Add(genre.name);
            }

            TmdbConfiguration tmdbConf = api.GetConfiguration();

            // load posters
            TmdbMovieImages movieImages = api.GetMovieImages(movieNode.id, language);
            LogMyFilms.Debug("GetMovieInformation() - language = '" + (language ?? "") + "', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");

            foreach (Poster poster in movieImages.posters)
            {
              movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
            }
            foreach (Backdrop backdrop in movieImages.backdrops)
            {
              movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
            }

            // english posters and backdrops
            movieImages = api.GetMovieImages(movieNode.id, "en"); // fallback to en language images
            LogMyFilms.Debug("GetMovieInformation() - language = 'en', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");
            if (movie.Posters.Count < 5)
            {
              foreach (Poster poster in movieImages.posters)
              {
            movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
              }
            }
            foreach (Backdrop backdrop in movieImages.backdrops)
            {
              movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
            }

            // non language posters and backdrops
            movieImages = api.GetMovieImages(movieNode.id, null); // fallback to non language images
            LogMyFilms.Debug("GetMovieInformation() - language = 'null', Posters: '" + movieImages.posters.Count + "', Backdrops: '" + movieImages.backdrops.Count + "'");
            if (movie.Posters.Count < 11)
            {
              foreach (Poster poster in movieImages.posters)
              {
            movie.Posters.Add(tmdbConf.images.base_url + "w500" + poster.file_path);
              }
            }

            if (movie.Backdrops.Count < 11) // only load foreign backdrops, if not anough are availabole
            {
              foreach (Backdrop backdrop in movieImages.backdrops)
              {
            movie.Backdrops.Add(tmdbConf.images.base_url + "original" + backdrop.file_path);
              }
            }
            LogMyFilms.Debug("GetMovieInformation() - Totals added - Posters: '" + movie.Posters.Count + "', Backdrops: '" + movie.Backdrops.Count + "'");
              }
              catch (Exception ex)
              {
            LogMyFilms.Debug(ex.StackTrace);
              }
              return movie;
        }
Esempio n. 2
0
        private static DbPersonInfo GetPersonInformation(XmlNode personNode)
        {
            if (personNode == null)
            return null;

              if (personNode.ChildNodes.Count < 2 || personNode.Name != "person")
            return null;

              List<string> images = new List<string>();
              DbPersonInfo person = new DbPersonInfo();
              foreach (XmlNode node in personNode.ChildNodes)
              {
            string value = node.InnerText;
            switch (node.Name)
            {
              case "id":
            person.Id = value;
            break;
              case "name":
            person.Name = value;
            break;
              case "birthday":
            person.Birthday = value;
            break;
              case "birthplace":
            person.Birthplace = value;
            break;
              case "url":
            person.DetailsUrl = value;
            break;
              case "biography":
            person.Biography = value;
            break;
              case "image":
            if (node.OuterXml.Contains("\"original\""))
              images.Add(value);
            break;
              case "version":
              case "last_modified_at":
            break;
              case "images":
            if (node.OuterXml.Contains("\"original\"") && node.OuterXml.Contains("\"profile\"") && node.OuterXml.Contains("url="))
            {
              images.AddRange(from XmlNode image in node.SelectNodes("image") where image.OuterXml.Contains("\"original\"") && image.OuterXml.Contains("\"profile\"") && image.OuterXml.Contains("url=") let start = image.OuterXml.IndexOf("url=") + 5 select image.OuterXml.Substring(start) into zvalue select zvalue.Substring(0, zvalue.IndexOf("\"")));
            }
            break;
            }
              }
              person.Images = images;
              return person;
        }
Esempio n. 3
0
        private static DbPersonInfo GetPersonInformation(Tmdb api, TmdbPerson personNode, string language)
        {
            LogMyFilms.Debug("GetPersonInformation()");

              if (personNode == null) return null;

              List<string> images = new List<string>();
              DbPersonInfo person = new DbPersonInfo();

              try
              {
            TmdbPerson m = api.GetPersonInfo(personNode.id);

            person.Id = m.id.ToString();
            person.Name = m.name;
            person.Biography = m.biography;
            person.Birthday = m.birthday;
            person.Birthplace = m.place_of_birth;
            person.DetailsUrl = m.homepage;

            TmdbPersonCredits p = api.GetPersonCredits(personNode.id);

            foreach (CastCredit cast in p.cast)
            {
            }

            foreach (CrewCredit crew in p.crew)
            {
            }

            TmdbConfiguration tmdbConf = api.GetConfiguration();

            TmdbPersonImages personImages = api.GetPersonImages(personNode.id);
            foreach (PersonImageProfile imageProfile in personImages.profiles)
            {
              person.Images.Add(tmdbConf.images.base_url + "w500" + imageProfile.file_path);
            }
              }
              catch (Exception ex)
              {
            LogMyFilms.Debug(ex.StackTrace);
              }
              return person;
        }
Esempio n. 4
0
        private static DbMovieInfo GetMovieInformation(XmlNode movieNode)
        {
            if (movieNode == null)
            return null;

              if (movieNode.ChildNodes.Count < 2 || movieNode.Name != "movie")
            return null;

              var producers = new List<string>();
              var directors = new List<string>();
              var writers = new List<string>();
              var actors = new List<string>();
              var backdrops = new List<string>();
              var posters = new List<string>();
              var persons = new List<DbPersonInfo>();
              var movie = new DbMovieInfo();
              foreach (XmlNode node in movieNode.ChildNodes)
              {
            string value = node.InnerText;
            switch (node.Name)
            {
              case "id":
            movie.Identifier = value;
            break;
              case "name":
              case "title":
            movie.Name = value;
            break;
              case "alternative_name":
            if (value.Trim() != "None found." && value.Trim().Length > 0)
              movie.AlternativeTitle = value;
            break;
              case "original_name":
            if (value.Trim() != "None found." && value.Trim().Length > 0)
              movie.TranslatedTitle = value;
            break;
              case "released":
              case "release":
            DateTime date;
            if (DateTime.TryParse(value, out date))
              movie.Year = date.Year;
            break;
              case "imdb":
              case "imdb_id":
            movie.ImdbId = value;
            break;
              case "url":
            movie.DetailsUrl = value;
            break;
              case "overview":
              case "short_overview":
            movie.Summary = value;
            break;
              case "rating":
              case "score":
            float rating = 0;
            if (float.TryParse(value, out rating))
              movie.Score = rating;
            break;
              case "certification":
            movie.Certification = value;
            break;
              case "languages_spoken":
            foreach (XmlNode language in node.SelectNodes("language_spoken/name"))
            {
              movie.Languages.Add(language.InnerText.Trim());
            }
            break;
              case "runtime":
            int runtime = 0;
            if (int.TryParse(value, out runtime))
              movie.Runtime = runtime;
            break;
              case "people":
              case "cast":
            foreach (XmlNode person in node.ChildNodes)
            {
              string name = person.Attributes["name"].Value;
              string character = person.Attributes["character"].Value;
              string thumb = person.Attributes["thumb"].Value;
              string job = person.Attributes["job"].Value;
              string id = person.Attributes["id"].Value;
              string url = person.Attributes["url"].Value;
              var personToAdd = new DbPersonInfo { Id = id, Name = name, DetailsUrl = url, Job = job };
              persons.Add(personToAdd);
              switch (job)
              {
                case "Producer":
                  producers.Add(name);
                  break;
                case "Director":
                  directors.Add(name);
                  break;
                case "Actor":
                  if (character.Length > 0)
                    name = name + " (" + character + ")";
                  actors.Add(name);
                  break;
                case "Screenplay":
                  writers.Add(name);
                  break;
              }
            }
            break;
              case "countries":
            foreach (XmlNode country in node.SelectNodes("country/name"))
            {
              movie.Country.Add(country.InnerText.Trim());
            }
            break;
              case "categories":
            foreach (XmlNode category in node.SelectNodes("category/name"))
            {
              movie.Genres.Add(category.InnerText.Trim());
            }
            break;
              case "poster":
            if (node.OuterXml.Contains("\"original\""))
              posters.Add(value);
            break;
              case "backdrop":
            if (node.OuterXml.Contains("\"original\""))
              backdrops.Add(value);
            break;
              case "images":
            if (node.OuterXml.Contains("\"original\"") && node.OuterXml.Contains("\"backdrop\"") && node.OuterXml.Contains("url="))
            {
              backdrops.AddRange(from XmlNode image in node.SelectNodes("image") where image.OuterXml.Contains("\"original\"") && image.OuterXml.Contains("\"backdrop\"") && image.OuterXml.Contains("url=") let start = image.OuterXml.IndexOf("url=") + 5 select image.OuterXml.Substring(start) into zvalue select zvalue.Substring(0, zvalue.IndexOf("\"")));
            }
            if (node.OuterXml.Contains("\"original\"") && node.OuterXml.Contains("\"poster\"") && node.OuterXml.Contains("url="))
            {
              posters.AddRange(from XmlNode image in node.SelectNodes("image") where image.OuterXml.Contains("\"original\"") && image.OuterXml.Contains("\"poster\"") && image.OuterXml.Contains("url=") let start = image.OuterXml.IndexOf("url=") + 5 select image.OuterXml.Substring(start) into zvalue select zvalue.Substring(0, zvalue.IndexOf("\"")));
            }
            break;
            }
              }
              movie.Producers = producers;
              movie.Directors = directors;
              movie.Writers = writers;
              movie.Actors = actors;
              movie.Backdrops = backdrops;
              movie.Posters = posters;
              movie.Persons = persons;
              return movie;
        }
Esempio n. 5
0
    //-------------------------------------------------------------------------------------------
    //  Dowload backdrops on theMovieDB.org
    //-------------------------------------------------------------------------------------------        
    public static void Download_Backdrops_Fanart(string wtitle, string wttitle, string wftitle, string director, string imdbid, string year, bool choose, int wGetID, string savetitle, string personartworkpath, bool loadFanart, bool loadPersonImages, GUIAnimation searchanimation)
    {
      new Thread(delegate()
      {
        var grab = new Grabber_URLClass();
        int wyear = 0;
        try { wyear = Convert.ToInt32(year); }
        catch { }
        try
        {
          SetProcessAnimationStatus(true, searchanimation);  // GUIWaitCursor.Init(); GUIWaitCursor.Show();
          List<DbMovieInfo> listemovies = grab.GetFanart(
            wtitle,
            savetitle,
            wyear,
            director,
            imdbid,
            MyFilms.conf.StrPathFanart,
            true,
            choose,
            MyFilms.conf.StrTitle1,
            personartworkpath);
          SetProcessAnimationStatus(false, searchanimation);  //GUIWaitCursor.Hide();
          //System.Collections.Generic.List<grabber.DBMovieInfo> listemovies = Grab.GetFanart(wtitle, wttitle, wyear, director, MyFilms.conf.StrPathFanart, true, choose);
          LogMyFilms.Debug("(DownloadBackdrops) - listemovies: '" + wtitle + "', '" + wttitle + "', '" + wyear + "', '" + director + "', '" + MyFilms.conf.StrPathFanart + "', 'true', '" + choose.ToString() + "', '" + MyFilms.conf.StrTitle1 + "'");
          int listCount = listemovies.Count;
          LogMyFilms.Debug("(DownloadBackdrops) - listemovies: Result Listcount: '" + listCount.ToString() + "'");

          if (choose) listCount = 2;
          switch (listCount)
          {
            case 0:
              break;
            case 1:
              LogMyFilms.Debug("Fanart " + listemovies[0].Name.Substring(listemovies[0].Name.LastIndexOf("\\") + 1) + " downloaded for " + wttitle);
              if (listemovies[0].Persons.Count > 0)
              {
                LogMyFilms.Debug("PersonArtwork: " + listemovies[0].Persons.Count.ToString() + " Persons checked for " + wttitle);
                foreach (DbPersonInfo person in listemovies[0].Persons)
                {
                  LogMyFilms.Debug("PersonArtwork: " + person.Images.Count.ToString() + " images found for " + person.Name);
                }
              }
              break;
            default:

              var wotitle_tableau = new ArrayList();
              var wttitle_tableau = new ArrayList();
              var wotitle_sub_tableau = new ArrayList();
              var wttitle_sub_tableau = new ArrayList();
              const int MinChars = 2;
              bool Filter = true;

              var dlg = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
              if (dlg == null) return;
              dlg.Reset();
              dlg.SetHeading(loadFanart ? GUILocalizeStrings.Get(1079862) : GUILocalizeStrings.Get(1079900));  // Load fanart (online)  // Download person images (selected film)
              dlg.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
              foreach (DbMovieInfo t in listemovies)
              {
                string dialoginfoline = t.Name + "  (" + t.Year + ")";
                if (loadFanart) dialoginfoline += " - Fanarts: " + t.Backdrops.Count;
                if (loadPersonImages) dialoginfoline += " - Persons: " + t.Persons.Count.ToString();
                dlg.Add(dialoginfoline);
                LogMyFilms.Debug("TMDB listemovies: " + t.Name + "  (" + t.Year + ") - Fanarts: " + t.Backdrops.Count + " - TMDB-Id: " + t.Identifier + " - Persons: " + t.Persons.Count.ToString());
              }
              if (!(dlg.SelectedLabel > -1))
              {
                dlg.SelectedLabel = -1;
                dlg.DoModal(wGetID);
              }
              if (dlg.SelectedLabel == 0)
              {
                #region Get SubTitles and Subwords from otitle and ttitle

                wotitle_tableau = MyFilms.SubTitleGrabbing(wtitle);
                wttitle_tableau = MyFilms.SubTitleGrabbing(wttitle);
                wotitle_sub_tableau = MyFilms.SubWordGrabbing(wtitle, MinChars, Filter);
                // Min 3 Chars, Filter true (no der die das)
                wttitle_sub_tableau = MyFilms.SubWordGrabbing(wttitle, MinChars, Filter);
                // Min 3 Chars, Filter true (no der die das)
                //First Show Dialog to choose Otitle, Ttitle or substrings - or Keyboard to manually enter searchstring!!!
                var dlgSearchFilm = (GUIDialogMenu)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                if (dlgSearchFilm == null) return;
                dlgSearchFilm.Reset();
                dlgSearchFilm.SetHeading(GUILocalizeStrings.Get(1079859)); // choose search expression
                dlgSearchFilm.Add("  *****  " + GUILocalizeStrings.Get(1079858) + "  *****  ");
                //manual selection with keyboard
                //dlgs.Add(wtitle); //Otitle
                dlgSearchFilm.Add(savetitle); //Otitle = savetitle
                dlgSearchFilm.Add(wttitle); //Ttitle
                foreach (object t in from object t in wotitle_tableau where t.ToString().Length > 1 select t)
                {
                  dlgSearchFilm.Add(t.ToString());
                }
                foreach (object t in from object t in wttitle_tableau where t.ToString().Length > 1 select t)
                {
                  dlgSearchFilm.Add(t.ToString());
                }
                foreach (object t in from object t in wotitle_sub_tableau where t.ToString().Length > 1 select t)
                {
                  dlgSearchFilm.Add(t.ToString());
                }
                foreach (object t in from object t in wttitle_sub_tableau where t.ToString().Length > 1 select t)
                {
                  dlgSearchFilm.Add(t.ToString());
                }
                //Now all titles and Substrings listed in dialog !
                //dlgs.Add("  *****  " + GUILocalizeStrings.Get(1079860) + "  *****  "); //manual selection
                if (!(dlgSearchFilm.SelectedLabel > -1))
                {
                  dlgSearchFilm.SelectedLabel = -1;
                  dlgSearchFilm.DoModal(wGetID);
                }
                if (dlgSearchFilm.SelectedLabel == 0) // enter manual searchstring via VK
                {
                  var keyboard = (VirtualKeyboard)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_VIRTUAL_KEYBOARD);
                  if (null == keyboard) return;
                  keyboard.Reset();
                  keyboard.SetLabelAsInitialText(false); // set to false, otherwise our intial text is cleared
                  keyboard.Text = wtitle;
                  keyboard.DoModal(wGetID);
                  if ((keyboard.IsConfirmed) && (keyboard.Text.Length > 0))
                  {
                    //Remove_Backdrops_Fanart(wtitle, true);
                    //Remove_Backdrops_Fanart(wttitle, true);
                    //Remove_Backdrops_Fanart(wftitle, true);
                    Download_Backdrops_Fanart(
                      keyboard.Text,
                      string.Empty,
                      string.Empty,
                      string.Empty,
                      string.Empty,
                      string.Empty,
                      true,
                      wGetID,
                      savetitle,
                      personartworkpath,
                      loadFanart,
                      loadPersonImages,
                      searchanimation);
                  }
                  break;
                }
                if (dlgSearchFilm.SelectedLabel > 0 && dlgSearchFilm.SelectedLabel < 3) // if one of otitle or ttitle selected, keep year and director
                {
                  Download_Backdrops_Fanart(
                    dlgSearchFilm.SelectedLabelText,
                    wttitle,
                    wftitle,
                    year,
                    director,
                    string.Empty,
                    true,
                    wGetID,
                    savetitle,
                    personartworkpath,
                    loadFanart,
                    loadPersonImages,
                    searchanimation);
                  //Download_Backdrops_Fanart(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                  break;
                }
                if (dlgSearchFilm.SelectedLabel > 2) // For subitems, search without year and director !
                {
                  Download_Backdrops_Fanart(
                    dlgSearchFilm.SelectedLabelText,
                    wttitle,
                    wftitle,
                    string.Empty,
                    string.Empty,
                    string.Empty,
                    true,
                    wGetID,
                    savetitle,
                    personartworkpath,
                    loadFanart,
                    loadPersonImages,
                    searchanimation);
                  //Download_Backdrops_Fanart(string wtitle, string wttitle, string director, string year, bool choose,int wGetID, string savetitle)
                  break;
                }

                #endregion
              }
              if (dlg.SelectedLabel > 0)
              {
                // Load Fanart  -> show progress dialog !

                var dlgPrgrs = (GUIDialogProgress)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_PROGRESS);
                if (dlgPrgrs != null)
                {
                  dlgPrgrs.Reset();
                  dlgPrgrs.DisplayProgressBar = true;
                  dlgPrgrs.ShowWaitCursor = false;
                  dlgPrgrs.DisableCancel(true);
                  dlgPrgrs.SetHeading("MyFilms Artwork Download");
                  dlgPrgrs.StartModal(GUIWindowManager.ActiveWindow);
                  dlgPrgrs.SetLine(1, "Loading Artwork ...");
                  dlgPrgrs.Percentage = 0;

                  #region load fanarts ...
                  bool first = true;
                  string filename = string.Empty;
                  string filename1 = string.Empty;
                  //if (MyFilms.conf.StrTitle1 == "OriginalTitle")
                  //  wttitle = savetitle; // Was wttitle = wtitle;
                  int i = 0;
                  if (loadFanart) // Download Fanart
                  {
                    if (dlgPrgrs != null) dlgPrgrs.SetLine(1, "Loading Fanart for '" + savetitle + "'");

                    foreach (string backdrop in listemovies[dlg.SelectedLabel - 1].Backdrops)
                    {
                      filename1 = Grabber.GrabUtil.DownloadBacdropArt(MyFilms.conf.StrPathFanart, backdrop, savetitle, true, first, out filename);
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + System.IO.Path.GetFileName(filename) + "'");
                      if (dlgPrgrs != null) dlgPrgrs.Percentage = i * 100 / listemovies[dlg.SelectedLabel - 1].Backdrops.Count;
                      LogMyFilms.Debug("Fanart " + filename1.Substring(filename1.LastIndexOf("\\") + 1) + " downloaded for " + savetitle);

                      if (filename == string.Empty) filename = filename1;
                      if (!(filename == "already" && filename1 == "already")) filename = "added";
                      first = false;
                      i++;
                    }
                  }
                  #endregion

                  listemovies[0].Name = filename;

                  if (loadPersonImages) // Download PersonArtwork
                  {
                    string filenameperson = string.Empty;
                    string filename1person = string.Empty;
                    string filename2person = string.Empty;
                    LogMyFilms.Debug(
                      "Person Artwork - " + listemovies[0].Persons.Count + " persons found - now loading artwork");
                    if (!string.IsNullOrEmpty(personartworkpath) && listemovies[0].Persons != null &&
                        listemovies[0].Persons.Count > 0)
                    {
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(1, "Loading person images for '" + wttitle + "'");
                      if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "");

                      foreach (Grabber.DbPersonInfo person in listemovies[0].Persons)
                      {
                        bool firstpersonimage = true;
                        bool onlysinglepersonimage = true;
                        var persondetails = new DbPersonInfo();
                        var theMoviedb = new TheMoviedb();
                        persondetails = theMoviedb.GetPersonsById(person.Id, string.Empty);
                        LogMyFilms.Debug("Person Artwork: found '" + persondetails.Images.Count + "' TMDB images for '" + persondetails.Name + "' in movie '" + savetitle + "'");
                        if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + persondetails.Name + "'");
                        if (dlgPrgrs != null) dlgPrgrs.Percentage = 0;

                        if (persondetails.Images.Count > 0)
                        {
                          i = 0;
                          foreach (var image in persondetails.Images)
                          {
                            filename1person = Grabber.GrabUtil.DownloadPersonArtwork(personartworkpath, image, persondetails.Name, true, firstpersonimage, out filenameperson);
                            if (dlgPrgrs != null) dlgPrgrs.SetLine(2, "loading '" + persondetails.Name + "' (TMDB - #" + i + ")");
                            if (dlgPrgrs != null) dlgPrgrs.Percentage = i * 100 / persondetails.Images.Count;

                            LogMyFilms.Debug("Person Artwork " + filename1person.Substring(filename1person.LastIndexOf("\\") + 1) + " downloaded for '" + persondetails.Name + "' in movie '" + savetitle + "', path='" + filename1person + "'");
                            if (filenameperson == string.Empty) filenameperson = filename1person;
                            if (!(filenameperson == "already" && filename1person == "already")) filenameperson = "added";
                            firstpersonimage = false;
                            i++;
                            if (onlysinglepersonimage) break;
                          }
                        }
                      }
                    }
                    else if (string.IsNullOrEmpty(personartworkpath)) LogMyFilms.Debug("No Personartwork loaded - Personartworkpath is not set in setup!");
                  }
                  if (dlgPrgrs != null) dlgPrgrs.Percentage = 100;
                  dlgPrgrs.ShowWaitCursor = false;
                  dlgPrgrs.SetLine(1, GUILocalizeStrings.Get(1079846));
                  dlgPrgrs.SetLine(2, "");
                  Thread.Sleep(50);
                  dlgPrgrs.Close(); // Done...
                  return;
                }
              }
              break;
          }
        }
        catch (Exception ex)
        {
          LogMyFilms.DebugException("Thread 'MyFilmsTMDBLoader' - exception! - ", ex);
        }
        GUIWindowManager.SendThreadCallbackAndWait((p1, p2, data) =>
        {
          //dlgPrgrs.ShowWaitCursor = false;
          // enter here what to load after background thread has finished !
          if (DetailsUpdated != null) DetailsUpdated(true);
          return 0;
        }, 0, 0, null);
      }) { Name = "MyFilmsTMDBLoader", IsBackground = true }.Start();
    }
Esempio n. 6
0
 private static bool DownloadPersonImage(string personname) //void downloadPersonImage(DBPersonInfo person)
 {
   bool added = false;
   // we need to get it, let's queue them up and download in the background
   var person = new DbPersonInfo { Name = personname };
   lock (PersonstoDownloadQueue)
   {
     if (PersonstoDownloadQueue.Any(personInfo => personInfo.Name == personname))
     {
       return false;
     }
     if (!PersonstoDownloadQueue.Contains(person))
     {
       PersonstoDownloadQueue.Enqueue(person);
       added = true;
     }
   }
   setDownloadStatus();
   if (!downloadingWorker.IsBusy) downloadingWorker.RunWorkerAsync(); // finally lets check if the downloader is already running, and if not start it
   return added;
 }