示例#1
0
        public DbPersonInfo GetPersonsById(string id, string language)
        {
            Tmdb api = new Tmdb(TmdbApiKey, language); // language is optional, default is "en"

              if (language.Length != 2) language = CultureInfo.CurrentCulture.Name.Substring(0, 2); // use local language instead

              TmdbPerson singleperson = api.GetPersonInfo(int.Parse(id));

              DbPersonInfo result = GetPersonInformation(api, singleperson, language);
              return result;
        }
示例#2
0
        public DbPersonInfo GetPersonsById(string id, string language)
        {
            Tmdb api = new Tmdb(TmdbApiKey, language); // language is optional, default is "en"

              if (language.Length != 2)
            language = CultureInfo.CurrentCulture.Name.Substring(0, 2); // use local language instead

              TmdbPerson singleperson = api.GetPersonInfo(int.Parse(id));

              DbPersonInfo result = GetPersonInformation(api, singleperson, language);
              return result;

              //string apiGetPersonInfoLanguage = language.Length == 2 ? ApiGetPersonInfo.Replace("/en/", "/" + language + "/") : ApiGetPersonInfo;

              //XmlNodeList xml = GetXml(apiGetPersonInfoLanguage + id);
              //if (xml == null) return result;

              //XmlNodeList personNodes = xml.Item(0).SelectNodes("//person");
              //foreach (DbPersonInfo person in personNodes.Cast<XmlNode>().Select(node => GetPersonInformation(node)).Where(person => person != null))
              //{
              //  result = person;
              //}
              //return result;
        }
示例#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;
        }
示例#4
0
    internal static bool UpdatePersonDetails(string personname, GUIListItem item, bool forceupdate, bool stopLoadingViewDetails)
    {
      if (!forceupdate && !Helper.PersonUpdateAllowed(MyFilms.conf.StrPathArtist, personname)) return false;

      string item1LabelOrg = (item != null) ? item.Label : "";
      string item3LabelOrg = (item != null) ? item.Label3 : "";
      string filename = MyFilms.conf.StrPathArtist + "\\" + personname + ".jpg";  // string filename = Path.Combine(MyFilms.conf.StrPathArtist, personname); //File.Exists(MyFilms.conf.StrPathArtist + "\\" + personsname + ".jpg")))

      IMDBActor person = null;
      bool vdBexists = false;

      if (item != null) item.Label = item1LabelOrg + " " + GUILocalizeStrings.Get(10799205); // (updating...)

      #region get person info from VDB
      if (item != null) item.Label3 = "Loading details from VDB ...";
      var actorList = new ArrayList();
      VideoDatabase.GetActorByName(personname, actorList);
      LogMyFilms.Debug("VDB - found '" + actorList.Count + "' local results for '" + personname + "'");
      if (actorList.Count > 0 && actorList.Count < 5)
      {
        LogMyFilms.Debug("VDB first search result: '" + actorList[0] + "'");
        string[] strActor = actorList[0].ToString().Split(new char[] { '|' });
        // int actorID = (strActor[0].Length > 0 && strActor.Count() > 1) ? Convert.ToInt32(strActor[0]) : 0; // string actorname = strActor[1];
        int actorId;
        int.TryParse(strActor[0], out actorId);
        if (actorId > 0)
        {
          person = VideoDatabase.GetActorInfo(actorId);
        }
        if (person != null)
        {
          if (item != null) item.Label3 = "ID = " + actorId + ", URL = " + person.ThumbnailUrl;
          vdBexists = true;
        }
        else
        {
          if (item != null) item.Label3 = "ID = " + actorId;
        }
      }
      #endregion

      if (person != null && File.Exists(filename) && !forceupdate && !person.Biography.ToLower().StartsWith("unknown") && !(person.Biography.Length > 8))
      {
        LogMyFilms.Debug("Skip update for '" + personname + "' - VDB entry and image already present !");
        if (item != null)
        {
          item.MusicTag = person;
          item.Label = item1LabelOrg;
          item.Label3 = item3LabelOrg;
        }
        if (stopLoadingViewDetails && item != null) return false; // stop download if we have exited window
        return true; // nothing to do
      }

      // region update person detail infos or load new ones ...
      if (person == null || person.DateOfBirth.Length < 1 || person.DateOfBirth.ToLower().StartsWith("unknown") || !File.Exists(filename) || forceupdate)
      {
        if (person == null) person = new IMDBActor();

        #region IMDB internet search
        if (item != null) item.Label3 = "Searching IMDB ...";

        string grabberscript = MyFilmsSettings.GetPath(MyFilmsSettings.Path.GrabberScripts) + @"\IMDB-Person.xml";
        if (File.Exists(grabberscript))
        {
          ArrayList personUrls = FindActor(personname, grabberscript);
          LogMyFilms.Debug("IMDB - " + personUrls.Count + " person(s) found for '" + personname + "' with person grabber script '" + grabberscript + "'"); 
          if (personUrls.Count > 0)
          {
            var wurl = (Grabber_URLClass.IMDBUrl)personUrls[0];
            if (wurl.URL.Length != 0)
            {
              if (item != null) item.Label3 = "Loading IMDB details ...";
              GrabActorDetails(wurl.URL, grabberscript, out person);
              LogMyFilms.Debug("IMDB - Value found - name       = '" + (person.Name ?? "") + "'");
              LogMyFilms.Debug("IMDB - Value found - birthday   = '" + (person.DateOfBirth ?? "") + "'");
              LogMyFilms.Debug("IMDB - Value found - birthplace = '" + (person.PlaceOfBirth ?? "") + "'");
              LogMyFilms.Debug("IMDB - Value found - biography  = '" + (person.Biography.Substring(0, Math.Min(person.Biography.Length, 100)) ?? "") + "'");
              LogMyFilms.Debug("IMDB - Value found - thumb url  = '" + (person.ThumbnailUrl ?? "") + "'");
            }
          }
        }
        else
        {
          LogMyFilms.Debug("IMDB - Default person grabber script not found (" + grabberscript + ")");
        }
        
        //var imdb = new IMDB();
        //imdb.FindActor(personname);
        //LogMyFilms.Debug("IMDB - " + imdb.Count + " person(s) found for '" + personname + "' with IMDB API");
        //if (imdb.Count > 0)
        //{
        //  if (imdb[0].URL.Length != 0)
        //  {
        //    if (item != null) item.Label3 = "Loading IMDB details ...";
        //    //#if MP1X
        //    // _imdb.GetActorDetails(_imdb[0], out person);
        //    //#else
        //    // _imdb.GetActorDetails(_imdb[0], false, out person);
        //    //#endif
        //    GUIUtils.GetActorDetails(imdb, imdb[0], false, out person);
        //    LogMyFilms.Debug("IMDB - Value found - name       = '" + (person.Name ?? "") + "'");
        //    LogMyFilms.Debug("IMDB - Value found - birthday   = '" + (person.DateOfBirth ?? "") + "'");
        //    LogMyFilms.Debug("IMDB - Value found - birthplace = '" + (person.PlaceOfBirth ?? "") + "'");
        //    LogMyFilms.Debug("IMDB - Value found - biography  = '" + (person.Biography.Substring(0, Math.Min(person.Biography.Length, 100)) ?? "") + "'");
        //  }
        //}

        if (stopLoadingViewDetails && item != null && !forceupdate) return false; // stop download if we have exited window

        #endregion

        #region TMDB V3 API description
        // Search
        //TmdbMovieSearch SearchMovie(string query, int page)
        //TmdbPersonSearch SearchPerson(string query, int page)
        //TmdbCompanySearch SearchCompany(string query, int page);             

        // Person Info
        //TmdbPerson GetPersonInfo(int PersonID)
        //TmdbPersonCredits GetPersonCredits(int PersonID)
        //TmdbPersonImages GetPersonImages(int PersonID)
        //Movie Info
        //TmdbMovie GetMovieInfo(int MovieID)
        //TmdbMovie GetMovieByIMDB(string IMDB_ID)
        //TmdbMovieAlternateTitles GetMovieAlternateTitles(int MovieID, string Country)
        //TmdbMovieCast GetMovieCast(int MovieID)
        //TmdbMovieImages GetMovieImages(int MovieID)
        //TmdbMovieKeywords GetMovieKeywords(int MovieID)
        //TmdbMovieReleases GetMovieReleases(int MovieID)
        //TmdbMovieTrailers GetMovieTrailers(int MovieID)
        //TmdbSimilarMovies GetSimilarMovies(int MovieID, int page)
        //TmdbTranslations GetMovieTranslations(int MovieID)

        // Social Movie Info
        //TmdbNowPlaying GetNowPlayingMovies(int page)
        //TmdbPopular GetPopularMovies(int page)
        //TmdbTopRated GetTopRatedMovies(int page)
        //TmdbUpcoming GetUpcomingMovies(int page)
        #endregion

        #region TMDB v3 infos ...
        try
        {
          if (item != null) item.Label3 = "Searching TMDB ...";

          // grabber.TheMoviedb tmdbapi = new grabber.TheMoviedb(); // we're using new v3 api here
          var api = new Tmdb(MyFilms.TmdbApiKey, CultureInfo.CurrentCulture.Name.Substring(0, 2)); // language is optional, default is "en"
          TmdbConfiguration tmdbConf = api.GetConfiguration();
          TmdbPersonSearch tmdbPerson = api.SearchPerson(personname, 1);
          List<PersonResult> persons = tmdbPerson.results;
          LogMyFilms.Debug("TMDB - " + persons.Count + " person(s) found for '" + personname + "' with TMDB API");
          if (persons != null && persons.Count > 0)
          {
            PersonResult pinfo = persons[0];
            if (item != null) item.Label3 = "Loading TMDB details ...";
            TmdbPerson singleperson = api.GetPersonInfo(pinfo.id);
            
            // TMDB.TmdbPersonImages images = api.GetPersonImages(pinfo.id);
            // TMDB.TmdbPersonCredits personFilmList = api.GetPersonCredits(pinfo.id);

            LogMyFilms.Debug("TMDB - Value found - birthday   = '" + (singleperson.birthday ?? "") + "'");
            LogMyFilms.Debug("TMDB - Value found - birthplace = '" + (singleperson.place_of_birth ?? "") + "'");
            LogMyFilms.Debug("TMDB - Value found - biography  = '" + ((!string.IsNullOrEmpty(singleperson.biography)) ? singleperson.biography.Substring(0, Math.Min(singleperson.biography.Length, 100)) : "") + "'");

            SetActorDetailsFromTmdb(singleperson, tmdbConf, ref person);

            if (!string.IsNullOrEmpty(singleperson.profile_path) && !File.Exists(filename))
            {
              if (item != null) item.Label3 = "Loading TMDB image ...";
              string filename1person = GrabUtil.DownloadPersonArtwork(MyFilms.conf.StrPathArtist, person.ThumbnailUrl, personname, false, true, out filename);
              LogMyFilms.Debug("Person Image (TMDB) '" + filename1person.Substring(filename1person.LastIndexOf("\\") + 1) + "' downloaded for '" + personname + "', path = '" + filename1person + "', filename = '" + filename + "'");
              if (item != null)
              {
                item.IconImage = filename;
                item.IconImageBig = filename;
                item.ThumbnailImage = filename;
                item.Label3 = "TMDB ID = " + singleperson.id + ", URL = " + singleperson.profile_path;
              }
            }
          }
        }
        catch (Exception tex)
        {
          LogMyFilms.DebugException("UpdatePersonDetails() - error in TMDB grabbing person '" + personname + "': " + tex.Message, tex);
        }
        if (stopLoadingViewDetails && item != null && !forceupdate) return false; // stop download if we have exited window
        #endregion

        #region Add actor to database to get infos in person facades later...
        if (item != null) item.Label3 = "Save detail info to VDB ...";
        try
        {
          //#if MP1X
          //                  int actorId = VideoDatabase.AddActor(person.Name);
          //#else
          //                  int actorId = VideoDatabase.AddActor(null, person.Name);
          //#endif
          int actorId = GUIUtils.AddActor(null, person.Name);
          if (actorId > 0)
          {
            if (!string.IsNullOrEmpty(person.Biography)) // clean up before saving ...
            {
              if (person.Biography.Contains("Wikipedia"))
              {
                string startwiki = "From Wikipedia, the free encyclopedia";
                string endwiki = "Description above from the Wikipedia article";
                person.Biography = person.Biography.TrimStart('?', '.', ' ', '\r', '\n').TrimStart();
                if (person.Biography.Contains(startwiki)) person.Biography = person.Biography.Substring(person.Biography.IndexOf(startwiki) + startwiki.Length + 1);
                if (person.Biography.Contains(endwiki)) person.Biography = person.Biography.Substring(0, person.Biography.LastIndexOf(endwiki));
                person.Biography = person.Biography.Trim().TrimStart('?', '.', ' ', '\r', '\n').TrimEnd('\r', '\n', ' ').Trim(new char[] { ' ', '\r', '\n' }).Trim();
                LogMyFilms.Debug("Biography - cleaned value = '" + person.Biography + "'");
              }
            }
            VideoDatabase.SetActorInfo(actorId, person);
            //VideoDatabase.AddActorToMovie(_movieDetails.ID, actorId);
            if (item != null) item.Label3 = (vdBexists) ? ("Updated ID" + actorId + ", URL = " + person.ThumbnailUrl) : ("Added ID" + actorId + ", URL = " + person.ThumbnailUrl);
          }
        }
        catch (Exception ex)
        {
          if (item != null) item.Label = item1LabelOrg;
          LogMyFilms.Debug("Error adding person to VDB: " + ex.Message, ex.StackTrace);
        }
        if (stopLoadingViewDetails && item != null && !forceupdate) return false; // stop download if we have exited window
        #endregion

        #region load missing images ...
        if ((person.ThumbnailUrl.Contains("http:") && !File.Exists(filename)) || forceupdate)
        {
          #region MP Thumb download deactivated, as downloading not yet working !!!
          //if (person.ThumbnailUrl != string.Empty) // to update MP person thumb dir
          //{
          //  string largeCoverArt = Utils.GetLargeCoverArtName(Thumbs.MovieActors, person.Name);
          //  string coverArt = Utils.GetCoverArtName(Thumbs.MovieActors, person.Name);
          //  Utils.FileDelete(largeCoverArt);
          //  Utils.FileDelete(coverArt);
          //  IMDBFetcher.DownloadCoverArt(Thumbs.MovieActors, person.ThumbnailUrl, person.Name);
          //  //DownloadCoverArt(Thumbs.MovieActors, imdbActor.ThumbnailUrl, imdbActor.Name);
          //}
          #endregion
          if (item != null) item.Label3 = "Loading image ...";
          LogMyFilms.Debug(" Image found for person '" + personname + "', URL = '" + person.ThumbnailUrl + "'");
          string filename1person = GrabUtil.DownloadPersonArtwork(MyFilms.conf.StrPathArtist, person.ThumbnailUrl, personname, false, true, out filename);
          LogMyFilms.Debug("Person Image '" + filename1person.Substring(filename1person.LastIndexOf("\\") + 1) + "' downloaded for '" + personname + "', path = '" + filename1person + "', filename = '" + filename + "'");

          string strThumbDirectory = MyFilmsSettings.GetPath(MyFilmsSettings.Path.ThumbsCache) + @"\MyFilms_Persons\";
          string strThumb = strThumbDirectory + personname + ".png";
          string strThumbSmall = strThumbDirectory + personname + "_s.png";
          if (File.Exists(filename) && (forceupdate || !File.Exists(strThumbSmall)))
          {
            if (item != null) item.Label3 = "Creating cache image ...";
            //Picture.CreateThumbnail(strThumbSource, strThumbDirectory + itemlabel + "_s.png", 100, 150, 0, Thumbs.SpeedThumbsSmall);
            MyFilms.CreateCacheThumb(filename, strThumbSmall, 100, 150, "small");
            //Picture.CreateThumbnail(strThumbSource, strThumb, cacheThumbWith, cacheThumbHeight, 0, Thumbs.SpeedThumbsLarge);
            MyFilms.CreateCacheThumb(filename, strThumb, MyFilms.cacheThumbWith, MyFilms.cacheThumbHeight, "large");
          }

          if (item != null)
          {
            if (File.Exists(strThumb)) // (re)check if thumbs exist...
            {
              item.IconImage = strThumbSmall;
              item.IconImageBig = strThumb;
              item.ThumbnailImage = strThumb;
            }
            else if (File.Exists(filename))
            {
              item.IconImage = filename;
              item.IconImageBig = filename;
              item.ThumbnailImage = filename;
            }
            else
            {
              {
                item.IconImage = MyFilms.conf.DefaultCoverArtist;
                item.IconImageBig = MyFilms.conf.DefaultCoverArtist;
                item.ThumbnailImage = MyFilms.conf.DefaultCoverArtist;
              }
            }

            item.Label3 = "URL = " + person.ThumbnailUrl;
            // item.NotifyPropertyChanged("ThumbnailImage");
          }
        }
        #endregion

        if (item != null)
        {
          item.MusicTag = person;
        }

        #region old stuff deactivated
        //string[] strActiveFacadeImages = SetViewThumbs(wStrSort, item.Label, strThumbDirectory, isperson, currentCustomView, defaultViewImage, reversenames);
        ////string texture = "[MyFilms:" + strActiveFacadeImages[0].GetHashCode() + "]";
        ////if (GUITextureManager.LoadFromMemory(ImageFast.FastFromFile(strActiveFacadeImages[0]), texture, 0, 0, 0) > 0)
        ////{
        ////  item.ThumbnailImage = texture;
        ////  item.IconImage = texture;
        ////  item.IconImageBig = texture;
        ////}

        //item.IconImage = strActiveFacadeImages[1];
        //item.IconImageBig = strActiveFacadeImages[0];
        //item.ThumbnailImage = strActiveFacadeImages[0];

        //// if selected force an update of thumbnail
        ////GUIListItem selectedItem = GUIControl.GetSelectedListItem(ID_MyFilms, 50);
        ////if (selectedItem == item) GUIWindowManager.SendThreadMessage(new GUIMessage(GUIMessage.MessageType.GUI_MSG_ITEM_SELECT, GUIWindowManager.ActiveWindow, 0, 50, selectedItem.ItemId, 0, null));
        #endregion
      }

      if (item != null) // reset to original values
      {
        item.Label = item1LabelOrg;
        item.Label3 = item3LabelOrg;
      }
      return true;
    }