コード例 #1
0
        // Filmograpy and bio
        public bool GetActorDetails(IMDBUrl url, out IMDBActor actor)
        {
            actor = new IMDBActor();

            try
            {
                if (InternalActorsScriptGrabber.InternalActorsGrabber.GetActorDetails(url, out actor))
                {
                    // Add filmography
                    if (actor.Count > 0)
                    {
                        actor.SortActorMoviesByYear();
                    }

                    return(true);
                }
            }
            catch (Exception ex)
            {
                Log.Error("IMDB GetActorDetails Error: {0}", ex.Message);
            }
            return(false);
        }
コード例 #2
0
    public IMDBActor GetActorInfo(int idActor)
    {
      try
      {
        if (null == m_db)
        {
          return null;
        }
        string strSql = String.Format(
            "SELECT actorinfo.biography, actorinfo.dateofbirth, actorinfo.dateofdeath, actorinfo.minibio, actors.strActor, actorinfo.placeofbirth, actorinfo.placeofdeath, actorinfo.thumbURL, actorinfo.lastupdate, actors.IMDBActorID, actorinfo.idActor FROM actors,actorinfo WHERE actors.idActor=actorinfo.idActor AND actors.idActor ={0}", idActor);
        SQLiteResultSet results = m_db.Execute(strSql);
        
        if (results.Rows.Count != 0)
        {
          IMDBActor actor = new IMDBActor();
          actor.Biography = DatabaseUtility.Get(results, 0, "actorinfo.biography".Replace("''", "'"));
          actor.DateOfBirth = DatabaseUtility.Get(results, 0, "actorinfo.dateofbirth".Replace("''", "'"));
          actor.DateOfDeath = DatabaseUtility.Get(results, 0, "actorinfo.dateofdeath".Replace("''", "'"));
          actor.MiniBiography = DatabaseUtility.Get(results, 0, "actorinfo.minibio".Replace("''", "'"));
          actor.Name = DatabaseUtility.Get(results, 0, "actors.strActor".Replace("''", "'"));
          actor.PlaceOfBirth = DatabaseUtility.Get(results, 0, "actorinfo.placeofbirth".Replace("''", "'"));
          actor.PlaceOfDeath = DatabaseUtility.Get(results, 0, "actorinfo.placeofdeath".Replace("''", "'"));
          actor.ThumbnailUrl = DatabaseUtility.Get(results, 0, "actorinfo.thumbURL");
          actor.LastUpdate = DatabaseUtility.Get(results, 0, "actorinfo.lastupdate");
          actor.IMDBActorID = DatabaseUtility.Get(results, 0, "actors.IMDBActorID");
          actor.ID = Convert.ToInt32(DatabaseUtility.Get(results, 0, "actorinfo.idActor"));

          strSql = String.Format("SELECT * FROM actorinfomovies WHERE idActor ={0}", idActor);
          results = m_db.Execute(strSql);
          
          for (int i = 0; i < results.Rows.Count; ++i)
          {
            string imdbId = DatabaseUtility.Get(results, i, "IMDBID");
            strSql = String.Format("SELECT * FROM IMDBMovies WHERE idIMDB='{0}'", imdbId);
            SQLiteResultSet resultsImdb = m_db.Execute(strSql);

            IMDBActor.IMDBActorMovie movie = new IMDBActor.IMDBActorMovie();
            movie.ActorID = Convert.ToInt32(DatabaseUtility.Get(results, i, "idActor"));
            movie.Role = DatabaseUtility.Get(results, i, "role");
            
            if (resultsImdb.Rows.Count != 0)
            {
              // Added IMDBid
              movie.MovieTitle = DatabaseUtility.Get(resultsImdb, 0, "strTitle");
              movie.Year = Int32.Parse(DatabaseUtility.Get(resultsImdb, 0, "iYear"));
              movie.MovieImdbID = DatabaseUtility.Get(resultsImdb, 0, "idIMDB");
              movie.MoviePlot = DatabaseUtility.Get(resultsImdb, 0, "strPlot");
              movie.MovieCover = DatabaseUtility.Get(resultsImdb, 0, "strPictureURL");
              movie.MovieGenre = DatabaseUtility.Get(resultsImdb, 0, "strGenre");
              movie.MovieCast = DatabaseUtility.Get(resultsImdb, 0, "strCast");
              movie.MovieCredits = DatabaseUtility.Get(resultsImdb, 0, "strCredits");
              movie.MovieRuntime = Int32.Parse(DatabaseUtility.Get(results, i, "runtime")); // Not used
              movie.MovieMpaaRating = DatabaseUtility.Get(resultsImdb, 0, "mpaa");
            }
            actor.Add(movie);
          }
          return actor;
        }
      }
      catch (Exception ex)
      {
        Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }
      return null;
    }
コード例 #3
0
 public void SetActorInfo(int idActor, IMDBActor actor)
 {
   try
   {
     if (null == m_db)
     {
       return;
     }
     
     string strSQL = String.Format("SELECT * FROM actorinfo WHERE idActor ={0}", idActor);
     SQLiteResultSet results = m_db.Execute(strSQL);
     
     if (results.Rows.Count == 0)
     {
       // doesnt exists, add it
       strSQL =
         String.Format(
           "INSERT INTO actorinfo (idActor , dateofbirth , placeofbirth , minibio , biography, thumbURL, IMDBActorID, dateofdeath , placeofdeath, lastupdate ) VALUES( {0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}')",
           idActor, 
           DatabaseUtility.RemoveInvalidChars(actor.DateOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.MiniBiography),
           DatabaseUtility.RemoveInvalidChars(actor.Biography),
           DatabaseUtility.RemoveInvalidChars(actor.ThumbnailUrl),
           DatabaseUtility.RemoveInvalidChars(actor.IMDBActorID),
           DatabaseUtility.RemoveInvalidChars(actor.DateOfDeath),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfDeath),
           DatabaseUtility.RemoveInvalidChars(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
       m_db.Execute(strSQL);
     }
     else
     {
       // exists, modify it
       strSQL =
         String.Format(
           "UPDATE actorinfo SET dateofbirth='{1}', placeofbirth='{2}', minibio='{3}', biography='{4}', thumbURL='{5}', IMDBActorID='{6}', dateofdeath='{7}', placeofdeath='{8}', lastupdate ='{9}' WHERE idActor={0}",
           idActor, 
           DatabaseUtility.RemoveInvalidChars(actor.DateOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.MiniBiography),
           DatabaseUtility.RemoveInvalidChars(actor.Biography),
           DatabaseUtility.RemoveInvalidChars(actor.ThumbnailUrl),
           DatabaseUtility.RemoveInvalidChars(actor.IMDBActorID),
           DatabaseUtility.RemoveInvalidChars(actor.DateOfDeath),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfDeath),
           DatabaseUtility.RemoveInvalidChars(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
       m_db.Execute(strSQL);
       RemoveActorInfoMovie(idActor);
     }
     
     for (int i = 0; i < actor.Count; ++i)
     {
       AddActorInfoMovie(idActor, actor[i]);
     }
     
     return;
   }
   catch (Exception ex)
   {
     Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
     Open();
   }
   return;
 }
コード例 #4
0
ファイル: VideoDatabase.cs プロジェクト: nio22/MediaPortal-1
 public static void AddActorInfoMovie(int idActor, IMDBActor.IMDBActorMovie movie)
 {
   _database.AddActorInfoMovie(idActor, movie);
 }
コード例 #5
0
 public static void SetActorInfo(int idActor, IMDBActor actor)
 {
     _database.SetActorInfo(idActor, actor);
 }
コード例 #6
0
    private void OnVideoArtistInfo(IMDBActor actor)
    {
      GUIVideoArtistInfo infoDlg =
        (GUIVideoArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_ARTIST_INFO);

      if (infoDlg == null)
      {
        return;
      }

      if (actor == null)
      {
        OnInfo(facadeLayout.SelectedListItemIndex);
        return;
      }

      infoDlg.Actor = actor;
      ArrayList movies = new ArrayList();
      IMDBMovie movie = new IMDBMovie();
      VideoDatabase.GetMoviesByActor(actor.Name, ref movies);
      
      if (movies.Count > 0)
      {
        Random rnd = new Random();

        for (int i = movies.Count - 1; i > 0; i--)
        {
          int position = rnd.Next(i + 1);
          object temp = movies[i];
          movies[i] = movies[position];
          movies[position] = temp;
        }

        movie = (IMDBMovie)movies[0];
      }

      m_history.Set(facadeLayout.SelectedListItem.Label, currentFolder);
      infoDlg.Movie = movie;
      GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_ARTIST_INFO);
    }
コード例 #7
0
 private static void DownloadDirector(IMDBMovie movieDetails)
 {
   string actor = movieDetails.Director;
   string strThumb = Util.Utils.GetCoverArtName(Thumbs.MovieActors, actor);
   if (!File.Exists(strThumb))
   {
     _imdb.FindActor(actor);
     IMDBActor imdbActor = new IMDBActor();
     for (int x = 0; x < _imdb.Count; ++x)
     {
       _imdb.GetActorDetails(_imdb[x], true, out imdbActor);
       if (imdbActor.ThumbnailUrl != null && imdbActor.ThumbnailUrl.Length > 0)
       {
         break;
       }
     }
     if (imdbActor.ThumbnailUrl != null)
     {
       if (imdbActor.ThumbnailUrl.Length != 0)
       {
         //ShowProgress(GUILocalizeStrings.Get(1009), actor, "", 0);
         DownloadThumbnail(Thumbs.MovieActors, imdbActor.ThumbnailUrl, actor);
       }
       else
       {
         Log.Debug("GUIVideoFiles: url=empty for director {0}", actor);
       }
     }
     else
     {
       Log.Debug("GUIVideoFiles: url=null for director {0}", actor);
     }
   }
 }
コード例 #8
0
        // Changed - parsing all actor DB fields through HTML (IMDB changed HTML code)
        public bool GetActorDetails(IMDBUrl url, bool director, out IMDBActor actor)
        {
            actor = new IMDBActor();
            try
            {
                string absoluteUri;
                string strBody = GetPage(url.URL, "utf-8", out absoluteUri);
                if (strBody == null)
                {
                    return(false);
                }
                if (strBody.Length == 0)
                {
                    return(false);
                }
                // IMDBActorID
                try
                {
                    int    pos = url.URL.LastIndexOf("nm");
                    string id  = url.URL.Substring(pos, 9).Replace("/", string.Empty);
                    actor.IMDBActorID = id;
                }
                catch (Exception) {}

                HTMLParser parser   = new HTMLParser(strBody);
                string     strThumb = string.Empty;
                string     value    = string.Empty;
                string     value2   = string.Empty;
                // Actor name
                if ((parser.skipToEndOf("<title>")) &&
                    (parser.extractTo("- IMDb</title>", ref value)))
                {
                    value      = new HTMLUtil().ConvertHTMLToAnsi(value);
                    value      = Util.Utils.RemoveParenthesis(value).Trim();
                    actor.Name = HttpUtility.HtmlDecode(value.Trim());
                }
                if (actor.Name == string.Empty)
                {
                    actor.Name = url.Title;
                }
                // Photo
                string parserTxt  = parser.Content;
                string photoBlock = string.Empty;
                if (parser.skipToStartOf("<td id=\"img_primary\"") &&
                    (parser.extractTo("</td>", ref photoBlock)))
                {
                    parser.Content = photoBlock;
                    if ((parser.skipToEndOf("<img src=\"")) &&
                        (parser.extractTo("\"", ref strThumb)))
                    {
                        actor.ThumbnailUrl = strThumb;
                    }
                    parser.Content = parserTxt;
                }
                // Birth date
                if ((parser.skipToEndOf("Born:")) &&
                    (parser.skipToEndOf("birth_monthday=")) &&
                    (parser.skipToEndOf(">")) &&
                    (parser.extractTo("<", ref value)) &&
                    (parser.skipToEndOf("year=")) &&
                    (parser.extractTo("\"", ref value2)))

                {
                    actor.DateOfBirth = value + " " + value2;
                }
                // Death date
                if ((parser.skipToEndOf(">Died:</h4>")) &&
                    (parser.skipToEndOf("deaths\">")) &&
                    (parser.extractTo("<", ref value)) &&
                    (parser.skipToEndOf("death_date=")) &&
                    (parser.extractTo("\"", ref value2)))
                {
                    if (actor.DateOfBirth == string.Empty)
                    {
                        actor.DateOfBirth = "?";
                    }
                    actor.DateOfBirth += " ~ " + value + " " + value2;
                }

                parser.resetPosition();
                // Birth place
                if ((parser.skipToEndOf("birth_place=")) &&
                    (parser.skipToEndOf(">")) &&
                    (parser.extractTo("<", ref value)))
                {
                    actor.PlaceOfBirth = HttpUtility.HtmlDecode(value);
                }
                //Mini Biography
                parser.resetPosition();
                if ((parser.skipToEndOf("<td id=\"overview-top\">")) &&
                    (parser.skipToEndOf("<p>")) &&
                    (parser.extractTo("See full bio</a>", ref value)))
                {
                    value = new HTMLUtil().ConvertHTMLToAnsi(value);
                    actor.MiniBiography = Util.Utils.stripHTMLtags(value);
                    actor.MiniBiography = actor.MiniBiography.Replace("See full bio »", string.Empty).Trim();
                    actor.MiniBiography = HttpUtility.HtmlDecode(actor.MiniBiography); // Remove HTML entities like &#189;
                    if (actor.MiniBiography != string.Empty)
                    {
                        // get complete biography
                        string bioURL = absoluteUri;
                        if (!bioURL.EndsWith("/"))
                        {
                            bioURL += "/bio";
                        }
                        else
                        {
                            bioURL += "bio";
                        }
                        string strBioBody = GetPage(bioURL, "utf-8", out absoluteUri);
                        if (!string.IsNullOrEmpty(strBioBody))
                        {
                            HTMLParser parser1 = new HTMLParser(strBioBody);
                            if (parser1.skipToEndOf("<h5>Mini Biography</h5>") &&
                                parser1.extractTo("</p>", ref value))
                            {
                                value           = new HTMLUtil().ConvertHTMLToAnsi(value);
                                actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                                actor.Biography = HttpUtility.HtmlDecode(actor.Biography); // Remove HTML entities like &#189;
                            }
                        }
                    }
                }
                // Person is movie director or an actor/actress
                bool isActorPass    = false;
                bool isDirectorPass = false;
                parser.resetPosition();

                if (director)
                {
                    if ((parser.skipToEndOf("name=\"Director\">Director</a>")) &&
                        (parser.skipToEndOf("</div>")))
                    {
                        isDirectorPass = true;
                    }
                }
                else
                {
                    if (parser.skipToEndOf("name=\"Actress\">Actress</a>") || parser.skipToEndOf("name=\"Actor\">Actor</a>"))
                    {
                        isActorPass = true;
                    }
                }
                // Get filmography
                if (isDirectorPass | isActorPass)
                {
                    string movies = string.Empty;
                    // Get films and roles block
                    if (parser.extractTo("<div id", ref movies))
                    {
                        parser.Content = movies;
                    }
                    // Parse block for evey film and get year, title and it's imdbID and role
                    while (parser.skipToStartOf("<span class=\"year_column\""))
                    {
                        string movie = string.Empty;
                        if (parser.extractTo("<div class", ref movie))
                        {
                            movie += "</li>";
                            HTMLParser movieParser = new HTMLParser(movie);
                            string     title       = string.Empty;
                            string     strYear     = string.Empty;
                            string     role        = string.Empty;
                            string     imdbID      = string.Empty;
                            // IMDBid
                            movieParser.skipToEndOf("title/");
                            movieParser.extractTo("/", ref imdbID);
                            // Title
                            movieParser.resetPosition();
                            movieParser.skipToEndOf("<a");
                            movieParser.skipToEndOf(">");
                            movieParser.extractTo("<br/>", ref title);
                            title = Util.Utils.stripHTMLtags(title);
                            title = title.Replace("\n", " ").Replace("\r", string.Empty);
                            title = HttpUtility.HtmlDecode(title.Trim()); // Remove HTML entities like &#189;
                            // Year
                            movieParser.resetPosition();
                            if (movieParser.skipToStartOf(">20") &&
                                movieParser.skipToEndOf(">"))
                            {
                                movieParser.extractTo("<", ref strYear);
                            }
                            else if (movieParser.skipToStartOf(">19") &&
                                     movieParser.skipToEndOf(">"))
                            {
                                movieParser.extractTo("<", ref strYear);
                            }
                            // Roles
                            if ((director == false) && (movieParser.skipToEndOf("<br/>"))) // Role case 1, no character link
                            {
                                movieParser.extractTo("<", ref role);
                                role = Util.Utils.stripHTMLtags(role).Trim();
                                role = HttpUtility.HtmlDecode(role.Replace("\n", " ")
                                                              .Replace("\r", string.Empty).Trim());
                                if (role == string.Empty) // Role case 2, with character link
                                {
                                    movieParser.resetPosition();
                                    movieParser.skipToEndOf("<br/>");
                                    movieParser.extractTo("</a>", ref role);
                                    role = Util.Utils.stripHTMLtags(role).Trim();
                                    role = HttpUtility.HtmlDecode(role.Replace("\n", " ")
                                                                  .Replace("\r", string.Empty).Trim());
                                }
                            }
                            else
                            {
                                // Just director
                                if (director)
                                {
                                    role = "Director";
                                }
                            }

                            int year = 0;
                            try
                            {
                                year = Int32.Parse(strYear.Substring(0, 4));
                            }
                            catch (Exception)
                            {
                                year = 1900;
                            }
                            IMDBActor.IMDBActorMovie actorMovie = new IMDBActor.IMDBActorMovie();
                            actorMovie.MovieTitle = title;
                            actorMovie.Role       = role;
                            actorMovie.Year       = year;
                            actorMovie.imdbID     = imdbID;
                            actor.Add(actorMovie);
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error("IMDB.GetActorDetails({0} exception:{1} {2} {3}", url.URL, ex.Message, ex.Source, ex.StackTrace);
            }
            return(false);
        }
コード例 #9
0
        // Filmograpy and bio
        public bool GetActorDetails(IMDBUrl url, out IMDBActor actor)
        {
            actor = new IMDBActor();

            string[] vdbParserStr = VdbParserStringActorDetails();

            if (vdbParserStr == null || vdbParserStr.Length != 46)
            {
                return(false);
            }

            try
            {
                string absoluteUri;
                string strBody = GetPage(url.URL, "utf-8", out absoluteUri);

                if (strBody == null)
                {
                    return(false);
                }

                if (strBody.Length == 0)
                {
                    return(false);
                }

                #region Actor imdb id

                // IMDBActorID
                try
                {
                    int    pos = url.URL.LastIndexOf("nm");
                    string id  = url.URL.Substring(pos, 9).Replace("/", string.Empty);
                    actor.IMDBActorID = id;
                }
                catch (Exception) { }

                #endregion

                HTMLParser parser   = new HTMLParser(strBody);
                string     strThumb = string.Empty;
                string     value    = string.Empty;
                string     value2   = string.Empty;

                #region Actor name

                // Actor name
                if ((parser.skipToEndOf(vdbParserStr[0])) &&        // <title>
                    (parser.extractTo(vdbParserStr[1], ref value))) // - IMDb</title>
                {
                    value      = new HTMLUtil().ConvertHTMLToAnsi(value);
                    value      = Util.Utils.RemoveParenthesis(value).Trim();
                    actor.Name = HttpUtility.HtmlDecode(value.Trim());
                }

                if (actor.Name == string.Empty)
                {
                    actor.Name = url.Title;
                }

                #endregion

                // Photo
                string parserTxt  = parser.Content;
                string photoBlock = string.Empty;

                #region Actor photo

                if (parser.skipToStartOf(vdbParserStr[2]) &&             // <td id="img_primary"
                    (parser.extractTo(vdbParserStr[3], ref photoBlock))) // </td>
                {
                    parser.Content = photoBlock;

                    if ((parser.skipToEndOf(vdbParserStr[4])) &&           // <img src="
                        (parser.extractTo(vdbParserStr[5], ref strThumb))) // "
                    {
                        actor.ThumbnailUrl = strThumb;
                    }
                    parser.Content = parserTxt;
                }

                #endregion

                #region Actor birth date

                // Birth date
                if ((parser.skipToEndOf(vdbParserStr[6])) &&          // >Born:</h4>
                    (parser.skipToEndOf(vdbParserStr[7])) &&          // birth_monthday=
                    (parser.skipToEndOf(vdbParserStr[8])) &&          // >
                    (parser.extractTo(vdbParserStr[9], ref value)) && // <
                    (parser.skipToEndOf(vdbParserStr[10])) &&         // year=
                    (parser.extractTo(vdbParserStr[11], ref value2))) // "

                {
                    actor.DateOfBirth = value + " " + value2;
                }

                #endregion

                #region Actor death date

                // Death date
                if ((parser.skipToEndOf(vdbParserStr[12])) &&          // >Died:</h4>
                    (parser.skipToEndOf(vdbParserStr[13])) &&          // death_monthday="
                    (parser.skipToEndOf(vdbParserStr[14])) &&          // >
                    (parser.extractTo(vdbParserStr[15], ref value)) && // <
                    (parser.skipToEndOf(vdbParserStr[16])) &&          // death_date="
                    (parser.extractTo(vdbParserStr[17], ref value2)))  // "
                {
                    actor.DateOfDeath = value + " " + value2;
                }

                #endregion

                parser.resetPosition();

                #region Actor birth place

                // Birth place
                if ((parser.skipToEndOf(vdbParserStr[18])) &&        // birth_place=
                    (parser.skipToEndOf(vdbParserStr[19])) &&        // >
                    (parser.extractTo(vdbParserStr[20], ref value))) // <
                {
                    actor.PlaceOfBirth = HttpUtility.HtmlDecode(value);
                }

                #endregion

                #region Actor death place

                // Death place
                if ((parser.skipToEndOf(vdbParserStr[21])) &&        // death_place=
                    (parser.skipToEndOf(vdbParserStr[22])) &&        // >
                    (parser.extractTo(vdbParserStr[23], ref value))) // <
                {
                    actor.PlaceOfDeath = HttpUtility.HtmlDecode(value);
                }

                #endregion

                //Mini Biography
                parser.resetPosition();

                #region Actor biography

                if ((parser.skipToEndOf(vdbParserStr[24])) &&        // <td id="overview-top">
                    (parser.skipToEndOf(vdbParserStr[25])) &&        // <p>
                    (parser.extractTo(vdbParserStr[26], ref value))) // See full bio</a>
                {
                    value = new HTMLUtil().ConvertHTMLToAnsi(value);
                    actor.MiniBiography = Util.Utils.stripHTMLtags(value);
                    actor.MiniBiography = actor.MiniBiography.Replace(vdbParserStr[45], string.Empty).Trim(); // See full bio »
                    actor.MiniBiography = HttpUtility.HtmlDecode(actor.MiniBiography);                        // Remove HTML entities like &#189;

                    if (actor.MiniBiography != string.Empty)
                    {
                        // get complete biography
                        string bioURL = absoluteUri;

                        if (!bioURL.EndsWith(vdbParserStr[27])) // /
                        {
                            bioURL += vdbParserStr[28];         // /bio
                        }
                        else
                        {
                            bioURL += vdbParserStr[29]; // bio
                        }

                        string strBioBody = GetPage(bioURL, "utf-8", out absoluteUri);

                        if (!string.IsNullOrEmpty(strBioBody))
                        {
                            HTMLParser parser1 = new HTMLParser(strBioBody);

                            if (parser1.skipToEndOf(vdbParserStr[30]) &&        // <h5>Mini Biography</h5>
                                parser1.skipToEndOf(vdbParserStr[31]) &&        // <div class="wikipedia_bio">
                                parser1.extractTo(vdbParserStr[32], ref value)) // </div>
                            {
                                value           = new HTMLUtil().ConvertHTMLToAnsi(value);
                                value           = Regex.Replace(value, @"</h5>\s<h5>", "\n\r");
                                value           = Regex.Replace(value, @"<h5>", "\n\r\n\r");
                                value           = Regex.Replace(value, @"</h5>", ":\n\r");
                                actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                                actor.Biography = HttpUtility.HtmlDecode(actor.Biography);
                            }
                            else
                            {
                                parser1.resetPosition();

                                if (parser1.skipToEndOf(vdbParserStr[33]) &&        // <h5>Mini Biography</h5>
                                    parser1.extractTo(vdbParserStr[34], ref value)) // </p>
                                {
                                    value           = new HTMLUtil().ConvertHTMLToAnsi(value);
                                    actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                                    actor.Biography = HttpUtility.HtmlDecode(actor.Biography);
                                }
                            }
                        }
                    }
                }

                #endregion

                // Person is movie director or an actor/actress
                bool isActorPass    = false;
                bool isDirectorPass = false;
                bool isWriterPass   = false;

                parser.resetPosition();

                HTMLParser dirParser = new HTMLParser(); // HTML body for Director
                HTMLParser wriParser = new HTMLParser(); // HTML body for Writers

                #region Check person role in movie (actor, director or writer)

                if ((parser.skipToEndOf(vdbParserStr[35])) && // name="Director">Director</a>
                    (parser.skipToEndOf(vdbParserStr[36])))   // </div>
                {
                    isDirectorPass    = true;
                    dirParser.Content = parser.Content;
                }

                parser.resetPosition();

                if ((parser.skipToEndOf(vdbParserStr[37])) && // name="Writer">Writer</a>
                    (parser.skipToEndOf(vdbParserStr[38])))   // </div>
                {
                    isWriterPass      = true;
                    wriParser.Content = parser.Content;
                }

                parser.resetPosition();

                if (parser.skipToEndOf(vdbParserStr[39]) || // name="Actress">Actress</a>
                    parser.skipToEndOf(vdbParserStr[40]))   // name="Actor">Actor</a>
                {
                    isActorPass = true;
                }

                #endregion

                #region Get movies for every role

                // Get filmography Actor
                if (isActorPass)
                {
                    GetActorMovies(actor, parser, false, false);
                }

                // Get filmography for writers
                if (isWriterPass)
                {
                    parser = wriParser;
                    parser.resetPosition();

                    if ((parser.skipToEndOf(vdbParserStr[41])) && // name="Writer">Writer</a>
                        (parser.skipToEndOf(vdbParserStr[42])))   // </div>
                    {
                        GetActorMovies(actor, parser, false, true);
                    }
                }

                // Get filmography Director
                if (isDirectorPass)
                {
                    parser = dirParser;
                    parser.resetPosition();

                    if (parser.skipToEndOf(vdbParserStr[43]) && // name="Director">Director</a>
                        parser.skipToEndOf(vdbParserStr[44]))   // </div>
                    {
                        GetActorMovies(actor, parser, true, false);
                    }
                }

                #endregion

                // Add filmography
                if (actor.Count > 0)
                {
                    actor.SortActorMoviesByYear();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.Error("IMDB.GetActorDetails({0} exception:{1} {2} {3}", url.URL, ex.Message, ex.Source, ex.StackTrace);
            }
            return(false);
        }
コード例 #10
0
        private void GetActorMovies(IMDBActor actor, HTMLParser parser, bool director, bool writer)
        {
            string[] vdbParserStr = VdbParserStringActorMovies();

            if (vdbParserStr == null || vdbParserStr.Length != 19)
            {
                return;
            }

            string movies = string.Empty;

            // Get films and roles block
            if (parser.extractTo(vdbParserStr[0], ref movies)) // <div id
            {
                parser.Content = movies;
            }

            // Parse block for evey film and get year, title and it's imdbID and role
            while (parser.skipToStartOf(vdbParserStr[1])) // <span class="year_column"
            {
                string movie = string.Empty;

                if (parser.extractTo(vdbParserStr[2], ref movie)) // <div class
                {
                    movie += vdbParserStr[3];                     // </li>

                    HTMLParser movieParser = new HTMLParser(movie);
                    string     title       = string.Empty;
                    string     strYear     = string.Empty;
                    string     role        = string.Empty;
                    string     imdbID      = string.Empty;

                    // IMDBid
                    movieParser.skipToEndOf(vdbParserStr[4]);           // title/
                    movieParser.extractTo(vdbParserStr[5], ref imdbID); // /

                    // Title
                    movieParser.resetPosition();
                    movieParser.skipToEndOf(vdbParserStr[6]);          // <a
                    movieParser.skipToEndOf(vdbParserStr[7]);          // >
                    movieParser.extractTo(vdbParserStr[8], ref title); // <br/>
                    title = CleanCrlf(title);

                    if (!SkipNoMovies(title))
                    {
                        // Year
                        movieParser.resetPosition();

                        if (movieParser.skipToStartOf(vdbParserStr[9]) &&         // year_column">20
                            movieParser.skipToEndOf(vdbParserStr[10]))            // >
                        {
                            movieParser.extractTo(vdbParserStr[11], ref strYear); // <
                        }
                        else
                        {
                            movieParser.resetPosition();

                            if (movieParser.skipToStartOf(vdbParserStr[12]) &&        // year_column">19
                                movieParser.skipToEndOf(vdbParserStr[13]))            // >
                            {
                                movieParser.extractTo(vdbParserStr[14], ref strYear); // <
                            }
                        }

                        strYear = strYear.Trim();

                        if (strYear.Length > 4)
                        {
                            strYear = strYear.Substring(0, 4);
                        }

                        // Roles actor
                        if (!director && !writer)
                        {
                            // Role case 1, no character link
                            if (movieParser.skipToEndOf(vdbParserStr[15]))         // <br/>
                            {
                                movieParser.extractTo(vdbParserStr[16], ref role); // <
                                role = CleanCrlf(role);

                                // Role case 2, with character link
                                if (role == string.Empty)
                                {
                                    movieParser.resetPosition();
                                    movieParser.skipToEndOf(vdbParserStr[17]);         // <br/>
                                    movieParser.extractTo(vdbParserStr[18], ref role); // </a>
                                    role = CleanCrlf(role);
                                }
                            }
                        }
                        else if (director)
                        {
                            role = GUILocalizeStrings.Get(199).Replace(":", string.Empty);
                        }
                        else // Writer
                        {
                            string wRole = string.Empty;

                            if (title != null)
                            {
                                // Check for cases like "(movie type)(role)" and use "(role)" only
                                MatchCollection mc = Regex.Matches(title, @"\([^)]+\)");

                                if (mc.Count > 0)
                                {
                                    if (mc.Count > 1)
                                    {
                                        wRole = mc[mc.Count - 1].Value;
                                    }
                                    else
                                    {
                                        wRole = mc[0].Value;
                                    }
                                }
                                else
                                {
                                    continue;
                                }

                                if (!string.IsNullOrEmpty(wRole))
                                {
                                    // Remove parentheses (leave text inside)
                                    wRole = Regex.Replace(wRole, "([(]|[)])", string.Empty);
                                    role  = GUILocalizeStrings.Get(200) + " " + wRole;
                                }
                                else
                                {
                                    role = GUILocalizeStrings.Get(200).Replace(":", string.Empty);
                                }
                            }
                        }

                        int year = 0;
                        // Set near future for movies without year (99% it's a future project)
                        if (!Int32.TryParse(strYear, out year))
                        {
                            year = DateTime.Today.Year + 3;
                        }

                        IMDBActor.IMDBActorMovie actorMovie = new IMDBActor.IMDBActorMovie();
                        title = Util.Utils.RemoveParenthesis(title).Trim();
                        role  = Util.Utils.RemoveParenthesis(role).Trim();
                        actorMovie.MovieTitle  = title;
                        actorMovie.Role        = role;
                        actorMovie.Year        = year;
                        actorMovie.MovieImdbID = imdbID;
                        // Check if director/writer movie exists in actors movies, concatenate role
                        // to already fetched actor movie (no duplicate movie entries)
                        bool skipAdd = false;

                        if (writer)
                        {
                            for (int i = 0; i < actor.Count; i++)
                            {
                                if (actor[i].MovieImdbID == imdbID)
                                {
                                    if (actor[i].Role != string.Empty)
                                    {
                                        actor[i].Role = role + ", " + actor[i].Role;
                                    }
                                    else
                                    {
                                        actor[i].Role = role;
                                    }

                                    skipAdd = true;
                                    break;
                                }
                            }
                        }

                        if (director)
                        {
                            for (int i = 0; i < actor.Count; i++)
                            {
                                if (actor[i].MovieImdbID == imdbID)
                                {
                                    if (actor[i].Role != string.Empty)
                                    {
                                        actor[i].Role = role + ", " + actor[i].Role;
                                    }
                                    else
                                    {
                                        actor[i].Role = role;
                                    }
                                    skipAdd = true;
                                    break;
                                }
                            }
                        }

                        if (!skipAdd)
                        {
                            actor.Add(actorMovie);
                        }
                    }
                }
            }
        }
コード例 #11
0
ファイル: MyFilmsDetail.cs プロジェクト: drtak34/my-films
    public static bool GrabActorDetails(string url, string wscript, out IMDBActor person)
    {
      LogMyFilms.Debug("launching (GrabActorDetails) with url = '" + url + "', wscript = '" + wscript + "'");

      person = new IMDBActor();
      var Grab = new Grabber_URLClass();
      var Result = new string[80];

      #region load internet data
      try
      {
        Result = Grab.GetDetail(url, "", wscript, false, null, null, null, null);
        // Result = Grab.GetDetail(url, downLoadPath, wscript, true, MyFilms.conf.GrabberOverrideLanguage, MyFilms.conf.GrabberOverridePersonLimit, MyFilms.conf.GrabberOverrideTitleLimit, MyFilms.conf.GrabberOverrideGetRoles, null);
        for (int i = 0; i < 40; i++) // copy mapped values to original values
        {
          Result[i] = Result[i + 40];
        }
      }
      catch (Exception ex)
      {
        LogMyFilms.ErrorException("GrabActorDetails() - exception = '" + ex.Message + "'", ex);
        return false;
      }
      #endregion

      #region load details data for person
      person.Name = Result[(int)Grabber_URLClass.Grabber_Output.OriginalTitle];
      person.DateOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Comments];
      person.PlaceOfBirth = Result[(int)Grabber_URLClass.Grabber_Output.Country];
      person.Biography = Result[(int)Grabber_URLClass.Grabber_Output.Description];
      person.ThumbnailUrl = Result[(int)Grabber_URLClass.Grabber_Output.PictureURL];
      #endregion
      LogMyFilms.Debug("GrabActorDetails() done for person : '" + person.Name + "'");
      return true;
    }
コード例 #12
0
ファイル: MyFilmsDetail.cs プロジェクト: drtak34/my-films
    private static void SetActorDetailsFromTmdb(TmdbPerson tmdbPerson, TmdbConfiguration conf, ref IMDBActor imdbPerson)
    {
      if (tmdbPerson == null)
      {
        LogMyFilms.Debug("SetActorDetailsFromTMDB() - TMDB person is 'null' - return");
        return;
      }
      if (imdbPerson == null)
      {
        LogMyFilms.Debug("SetActorDetailsFromTMDB() - IMDB person is 'null' - return");
        return;
      }
      string tmdbProfileSize = "original";
      foreach (string profileSize in conf.images.profile_sizes.Where(profileSize => profileSize == "h632"))
      {
        tmdbProfileSize = profileSize;
      }

      // imdbPerson.IMDBActorID = 
      // imdbPerson.Name = tmdbPerson.name;
      // imdbPerson.MiniBiography = tmdbPerson.biography;
      // LogMyFilms.Debug("SetActorDetailsFromTMDB() - update IMDB name     - old : '" + imdbPerson.Name + "', new: '" + tmdbPerson.name + "'");
      if (!string.IsNullOrEmpty(tmdbPerson.biography) && tmdbPerson.biography.Length > imdbPerson.Biography.Length)
      {
        // LogMyFilms.Debug("SetActorDetailsFromTMDB() - update IMDB bio      - old : '" + imdbPerson.Biography + "', new: '" + tmdbPerson.biography + "'");
        imdbPerson.Biography = tmdbPerson.biography;
      }

      if (!string.IsNullOrEmpty(tmdbPerson.birthday))
      {
        LogMyFilms.Debug("SetActorDetailsFromTMDB() - update IMDB birthday - old : '" + imdbPerson.DateOfBirth + "', new: '" + tmdbPerson.birthday + "'");
        imdbPerson.DateOfBirth = tmdbPerson.birthday + ((!string.IsNullOrEmpty(tmdbPerson.deathday)) ? " (" + tmdbPerson.deathday + ")" : "");
      }
      if (!string.IsNullOrEmpty(tmdbPerson.place_of_birth))
      {
        LogMyFilms.Debug("SetActorDetailsFromTMDB() - update IMDB b-place  - old : '" + imdbPerson.PlaceOfBirth + "', new: '" + tmdbPerson.place_of_birth + "'");
        imdbPerson.PlaceOfBirth = tmdbPerson.place_of_birth;
      }
      if (!string.IsNullOrEmpty(tmdbPerson.profile_path))
      {
        LogMyFilms.Debug("SetActorDetailsFromTMDB() - update IMDB thumb    - old : '" + imdbPerson.ThumbnailUrl + "', new: '" + conf.images.base_url + tmdbProfileSize + tmdbPerson.profile_path + "'");
        imdbPerson.ThumbnailUrl = conf.images.base_url + tmdbProfileSize + tmdbPerson.profile_path;
      }
    }
コード例 #13
0
ファイル: MyFilmsDetail.cs プロジェクト: drtak34/my-films
    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;
    }
コード例 #14
0
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      GUIPropertyManager.SetProperty("#groupmovielist", string.Empty);
      
      if (handler.CurrentLevel > 0)
      {
        FilterDefinition defCurrent = (FilterDefinition)handler.View.Filters[handler.CurrentLevel - 1];
        string selectedValue = defCurrent.SelectedValue;

        if (Regex.Match(selectedValue, @"[\d]*").Success)
        {
          if (defCurrent.Where == "actor" || defCurrent.Where == "director")
          {
            selectedValue = VideoDatabase.GetActorNameById(Convert.ToInt32(defCurrent.SelectedValue));
          }

          if (defCurrent.Where == "genre")
          {
            selectedValue = VideoDatabase.GetGenreById(Convert.ToInt32(defCurrent.SelectedValue));
          }

          if (defCurrent.Where == "user groups")
          {
            selectedValue = VideoDatabase.GetUserGroupById(Convert.ToInt32(defCurrent.SelectedValue));
          }
        }
        GUIPropertyManager.SetProperty("#currentmodule",
                                       String.Format("{0}/{1} - {2}", GUILocalizeStrings.Get(100006),
                                                     handler.LocalizedCurrentView, selectedValue));
      }
      
      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      
      // Set current item if thumb thread is working (thread can still update thumbs while user changed
      // item) thus preventing sudden jump to initial selected item before thread start
      if (_setThumbs != null && _setThumbs.IsAlive)
      {
        currentSelectedItem = facadeLayout.SelectedListItemIndex;
      }

      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
      
      if (movie == null)
      {
        movie = new IMDBMovie();
      }
      
      ArrayList files = new ArrayList();
      VideoDatabase.GetFilesForMovie(movie.ID, ref files);
      
      if (files.Count > 0)
      {
        movie.SetProperties(false, (string)files[0]);
      }
      else
      {
        movie.SetProperties(false, string.Empty);

        // Set title properties for other views (year, genres..)
        if (!string.IsNullOrEmpty(item.Label))
        {
          GUIPropertyManager.SetProperty("#title", item.Label);
          GUIPropertyManager.SetProperty("#groupmovielist", SetMovieListGroupedBy(item));
        }
      }
      
      IMDBActor actor = VideoDatabase.GetActorInfo(movie.ActorID);
      
      if (actor != null)
      {
        actor.SetProperties();
      }
      else
      {
        actor = new IMDBActor();
        actor.SetProperties();
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      if (movie.Actor != string.Empty)
      {
        GUIPropertyManager.SetProperty("#title", movie.Actor);
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, movie.ActorID.ToString());
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      // Random movieId by view (for FA) for selected groups
      string view = handler.CurrentLevelWhere;
      ArrayList mList = new ArrayList();
      GetItemViewHistory(view, mList);
    }
コード例 #15
0
    public bool MakeNfo (int movieId)
    {
      string moviePath = string.Empty;
      string movieFile = string.Empty;
      ArrayList movieFiles = new ArrayList();
      ArrayList nfoFiles = new ArrayList();
      string nfoFile = string.Empty;
      int fileCounter = 0;

      try
      {
        // Get files
        GetFilesForMovie(movieId, ref movieFiles);

        foreach (string file in movieFiles)
        {
          if (!File.Exists(file))
          {
            return false;
          }

          movieFile = file;
          Util.Utils.Split(movieFile, out moviePath, out movieFile);

          // Check for DVD folder
          if (movieFile.ToUpperInvariant() == "VIDEO_TS.IFO" || movieFile.ToUpperInvariant() == "INDEX.BDMV")
          {
            // Remove \VIDEO_TS from directory structure
            string directoryDVD = moviePath.Substring(0, moviePath.LastIndexOf(@"\"));

            if (Directory.Exists(directoryDVD))
            {
              moviePath = directoryDVD;
              movieFile = directoryDVD;
            }
          }
          else
          {
            if (fileCounter > 0)
            {
              return true;
            }
          }
          // remove stack endings (CDx..) form filename
          Util.Utils.RemoveStackEndings(ref movieFile);
          // Remove file extension
          movieFile = Util.Utils.GetFilename(movieFile, true).Trim();
          // Add nfo extension
          nfoFile = moviePath + @"\" + movieFile + ".nfo";
          Util.Utils.FileDelete(nfoFile);
          nfoFiles.Add(nfoFile);
          //}

          IMDBMovie movieDetails = new IMDBMovie();
          GetMovieInfoById(movieId, ref movieDetails);
          // Prepare XML
          XmlDocument doc = new XmlDocument();
          XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", "UTF-8", null);

          // Main tag
          XmlNode mainNode = doc.CreateElement("movie");
          XmlNode subNode;

          #region Movie fields

          // Filenames
          foreach (string strMovieFile in movieFiles)
          {
            CreateXmlNode(mainNode, doc, "filenameandpath", strMovieFile);
          }

          // Title
          CreateXmlNode(mainNode, doc, "title", movieDetails.Title);
          // Sort Title
          if (!string.IsNullOrEmpty(movieDetails.SortTitle))
          {
            CreateXmlNode(mainNode, doc, "sorttitle", movieDetails.SortTitle);
          }
          else
          {
            CreateXmlNode(mainNode, doc, "sorttitle", movieDetails.Title);
          }

          //  movie IMDB number
          CreateXmlNode(mainNode, doc, "imdb", movieDetails.IMDBNumber);
          CreateXmlNode(mainNode, doc, "id", movieDetails.IMDBNumber);
          //  Language
          CreateXmlNode(mainNode, doc, "language", movieDetails.Language);
          //  Country
          CreateXmlNode(mainNode, doc, "country", movieDetails.Country);
          //  Year
          CreateXmlNode(mainNode, doc, "year", movieDetails.Year.ToString());
          //  Rating
          CreateXmlNode(mainNode, doc, "rating", movieDetails.Rating.ToString().Replace(",", "."));
          //  Runtime
          CreateXmlNode(mainNode, doc, "runtime", movieDetails.RunTime.ToString());
          // MPAA
          CreateXmlNode(mainNode, doc, "mpaa", movieDetails.MPARating);
          // Votes
          CreateXmlNode(mainNode, doc, "votes", movieDetails.Votes);
          // TOp 250
          CreateXmlNode(mainNode, doc, "top250", movieDetails.Top250.ToString());
          // Studio
          CreateXmlNode(mainNode, doc, "studio", movieDetails.Studios);
          //  Director
          CreateXmlNode(mainNode, doc, "director", movieDetails.Director);
          //  Director imdbId
          CreateXmlNode(mainNode, doc, "directorimdb", GetActorImdbId(movieDetails.ID));
          // Credits
          CreateXmlNode(mainNode, doc, "credits", movieDetails.WritingCredits);
          // Tagline
          CreateXmlNode(mainNode, doc, "tagline", movieDetails.TagLine);
          // Plot outline (short one)
          CreateXmlNode(mainNode, doc, "outline", movieDetails.PlotOutline);
          // Plot - long
          CreateXmlNode(mainNode, doc, "plot", movieDetails.Plot);
          // Review
          CreateXmlNode(mainNode, doc, "review", movieDetails.UserReview);
          // Watched
          string watched = "false";

          if (movieDetails.Watched > 0)
          {
            watched = "true";
          }

          CreateXmlNode(mainNode, doc, "watched", watched);

          // Watched count
          int percent = 0;
          int watchedCount = 0;
          GetMovieWatchedStatus(movieId, out percent, out watchedCount);
          CreateXmlNode(mainNode, doc, "playcount", watchedCount.ToString());

          // Poster
          string titleExt = movieDetails.Title + "{" + movieId + "}";
          string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
          string coverFilename = moviePath + @"\" + movieFile + ".jpg";

          if (File.Exists(largeCoverArtImage))
          {
            try
            {
              File.Copy(largeCoverArtImage, coverFilename, true);
              File.SetAttributes(coverFilename, FileAttributes.Normal);
              CreateXmlNode(mainNode, doc, "thumb", movieFile + ".jpg");
            }
            catch (Exception ex)
            {
              Log.Info("VideoDatabase: Error in creating nfo - poster node:{0}", ex.Message);
            }
          }

          // Fanart
          string faFile = string.Empty;
          subNode = doc.CreateElement("fanart");

          for (int i = 0; i < 5; i++)
          {
            FanArt.GetFanArtfilename(movieId, i, out faFile);
            string index = string.Empty;

            if (File.Exists(faFile))
            {
              if (i > 0)
              {
                index = i.ToString();
              }

              try
              {
                string faFilename = moviePath + @"\" + movieFile + "-fanart" + index + ".jpg";
                File.Copy(faFile, faFilename, true);
                File.SetAttributes(faFilename, FileAttributes.Normal);
                CreateXmlNode(subNode, doc, "thumb", movieFile + "-fanart" + index + ".jpg");
              }
              catch (Exception ex)
              {
                Log.Info("VideoDatabas: Error in creating nfo - fanart section:{0}", ex.Message);
              }

            }
          }
          mainNode.AppendChild(subNode);

          // Genre
          string szGenres = movieDetails.Genre;

          if (szGenres.IndexOf("/") >= 0 || szGenres.IndexOf("|") >= 0)
          {
            Tokens f = new Tokens(szGenres, new[] {'/', '|'});

            foreach (string strGenre in f)
            {
              if (!string.IsNullOrEmpty(strGenre))
              {
                CreateXmlNode(mainNode, doc, "genre", strGenre.Trim());
              }
            }
          }
          else
          {
            CreateXmlNode(mainNode, doc, "genre", movieDetails.Genre);
          }

          // Cast
          ArrayList castList = new ArrayList();
          GetActorsByMovieID(movieId, ref castList);

          foreach (string actor in castList)
          {
            IMDBActor actorInfo = new IMDBActor();
            subNode = doc.CreateElement("actor");

            char[] splitter = {'|'};
            string[] temp = actor.Split(splitter);
            actorInfo = GetActorInfo(Convert.ToInt32(temp[0]));

            CreateXmlNode(subNode, doc, "name", temp[1]);
            CreateXmlNode(subNode, doc, "role", temp[3]);
            CreateXmlNode(subNode, doc, "imdb", temp[2]);

            if (actorInfo != null)
            {
              CreateXmlNode(subNode, doc, "thumb", actorInfo.ThumbnailUrl);
              CreateXmlNode(subNode, doc, "birthdate", actorInfo.DateOfBirth);
              CreateXmlNode(subNode, doc, "birthplace", actorInfo.PlaceOfBirth);
              CreateXmlNode(subNode, doc, "deathdate", actorInfo.DateOfDeath);
              CreateXmlNode(subNode, doc, "deathplace", actorInfo.PlaceOfDeath);
              CreateXmlNode(subNode, doc, "minibiography", actorInfo.MiniBiography);
              CreateXmlNode(subNode, doc, "biography", actorInfo.Biography);
            }

            mainNode.AppendChild(subNode);
          }

          // User groups
          ArrayList userGroups = new ArrayList();
          GetMovieUserGroups(movieId, userGroups);

          if (userGroups.Count > 0)
          {
            foreach (string userGroup in userGroups)
            {
              CreateXmlNode(mainNode, doc, "set", userGroup);
            }
          }

          // Trailer
          CreateXmlNode(mainNode, doc, "trailer", string.Empty);

          #endregion

          // End and save
          doc.AppendChild(mainNode);
          doc.InsertBefore(xmldecl, mainNode);
          doc.Save(nfoFile);
          fileCounter++;
        }
      }
      catch(Exception ex)
      {
        Log.Info("VideoDatabase: Error in creating nfo file:{0} Error:{1}", nfoFile ,ex.Message);
        return false;
      }

      return true;
    }
コード例 #16
0
ファイル: IMDB.cs プロジェクト: sekotin/MediaPortal-1
    private void GetActorMovies(IMDBActor actor, HTMLParser parser, bool director, bool writer)
    {
      string[] vdbParserStr = VdbParserStringActorMovies();

      if (vdbParserStr == null || vdbParserStr.Length != 19)
      {
        return;
      }

      string movies = string.Empty;
      
      // Get films and roles block
      if (parser.extractTo(vdbParserStr[0], ref movies)) // <div id
      {
        parser.Content = movies;
      }
      
      // Parse block for evey film and get year, title and it's imdbID and role
      while (parser.skipToStartOf(vdbParserStr[1])) // <span class="year_column"
      {
        string movie = string.Empty;

        if (parser.extractTo(vdbParserStr[2], ref movie)) // <div class
        {
          movie += vdbParserStr[3]; // </li>

          HTMLParser movieParser = new HTMLParser(movie);
          string title = string.Empty;
          string strYear = string.Empty;
          string role = string.Empty;
          string imdbID = string.Empty;

          // IMDBid
          movieParser.skipToEndOf(vdbParserStr[4]);           // title/
          movieParser.extractTo(vdbParserStr[5], ref imdbID); // /

          // Title
          movieParser.resetPosition();
          movieParser.skipToEndOf(vdbParserStr[6]);           // <a
          movieParser.skipToEndOf(vdbParserStr[7]);           // >
          movieParser.extractTo(vdbParserStr[8], ref title);  // <br/>
          title = CleanCrlf(title);

          if (!SkipNoMovies(title))
          {
            // Year
            movieParser.resetPosition();

            if (movieParser.skipToStartOf(vdbParserStr[9]) &&       // year_column">20
                movieParser.skipToEndOf(vdbParserStr[10]))          // >
            {
              movieParser.extractTo(vdbParserStr[11], ref strYear); // <
            }
            else
            {
              movieParser.resetPosition();
              
              if (movieParser.skipToStartOf(vdbParserStr[12]) &&      // year_column">19
                  movieParser.skipToEndOf(vdbParserStr[13]))          // >
              {
                movieParser.extractTo(vdbParserStr[14], ref strYear); // <
              }
            }

            strYear = strYear.Trim();

            if (strYear.Length > 4)
            {
              strYear = strYear.Substring(0, 4);
            }

            // Roles actor
            if (!director && !writer)
            {
              // Role case 1, no character link
              if (movieParser.skipToEndOf(vdbParserStr[15]))       // <br/>
              {
                movieParser.extractTo(vdbParserStr[16], ref role); // <
                role = CleanCrlf(role);

                // Role case 2, with character link
                if (role == string.Empty)
                {
                  movieParser.resetPosition();
                  movieParser.skipToEndOf(vdbParserStr[17]);          // <br/>
                  movieParser.extractTo(vdbParserStr[18], ref role);  // </a>
                  role = CleanCrlf(role);
                }
              }
            }
            else if (director)
            {
              role = GUILocalizeStrings.Get(199).Replace(":", string.Empty);
            }
            else // Writer
            {
              string wRole = string.Empty;

              if (title != null)
              {
                // Check for cases like "(movie type)(role)" and use "(role)" only
                MatchCollection mc = Regex.Matches(title, @"\([^)]+\)");

                if (mc.Count > 0)
                {
                  if (mc.Count > 1)
                  {
                    wRole = mc[mc.Count - 1].Value;
                  }
                  else
                  {
                    wRole = mc[0].Value;
                  }
                }
                else
                {
                  continue;
                }

                if (!string.IsNullOrEmpty(wRole))
                {
                  // Remove parentheses (leave text inside)
                  wRole = Regex.Replace(wRole, "([(]|[)])", string.Empty);
                  role = GUILocalizeStrings.Get(200) + " " + wRole;
                }
                else
                {
                  role = GUILocalizeStrings.Get(200).Replace(":", string.Empty);
                }
              }
            }

            int year = 0;
            // Set near future for movies without year (99% it's a future project)
            if (!Int32.TryParse(strYear, out year))
            {
             year = DateTime.Today.Year + 3;
            }
            
            IMDBActor.IMDBActorMovie actorMovie = new IMDBActor.IMDBActorMovie();
            title = Util.Utils.RemoveParenthesis(title).Trim();
            role = Util.Utils.RemoveParenthesis(role).Trim();
            actorMovie.MovieTitle = title;
            actorMovie.Role = role;
            actorMovie.Year = year;
            actorMovie.MovieImdbID = imdbID;
            // Check if director/writer movie exists in actors movies, concatenate role
            // to already fetched actor movie (no duplicate movie entries)
            bool skipAdd = false;

            if (writer)
            {
              for (int i = 0; i < actor.Count; i++)
              {
                if (actor[i].MovieImdbID == imdbID)
                {
                  if (actor[i].Role != string.Empty)
                  {
                    actor[i].Role = role + ", " + actor[i].Role;
                  }
                  else
                  {
                    actor[i].Role = role;
                  }

                  skipAdd = true;
                  break;
                }
              }
            }

            if (director)
            {
              for (int i = 0; i < actor.Count; i++)
              {
                if (actor[i].MovieImdbID == imdbID)
                {
                  if (actor[i].Role != string.Empty)
                  {
                    actor[i].Role = role + ", " + actor[i].Role;
                  }
                  else
                  {
                    actor[i].Role = role;
                  }
                  skipAdd = true;
                  break;
                }
              }
            }

            if (!skipAdd)
            {
              actor.Add(actorMovie);
            }
          }
        }
      }
    }
コード例 #17
0
 // Changed thumbURl added - IMDBActorID added
 public void SetActorInfo(int idActor, IMDBActor actor)
 {
   //"CREATE TABLE actorinfo ( idActor integer, dateofbirth text, placeofbirth text, minibio text, biography text
   try
   {
     if (null == m_db)
     {
       return;
     }
     string strSQL = String.Format("select * from actorinfo where idActor ={0}", idActor);
     SQLiteResultSet results = m_db.Execute(strSQL);
     if (results.Rows.Count == 0)
     {
       // doesnt exists, add it
       strSQL =
         String.Format(
           "insert into actorinfo (idActor , dateofbirth , placeofbirth , minibio , biography, thumbURL, IMDBActorID ) values( {0},'{1}','{2}','{3}','{4}','{5}','{6}')",
           idActor, DatabaseUtility.RemoveInvalidChars(actor.DateOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.MiniBiography),
           DatabaseUtility.RemoveInvalidChars(actor.Biography),
           DatabaseUtility.RemoveInvalidChars(actor.ThumbnailUrl),
           DatabaseUtility.RemoveInvalidChars(actor.IMDBActorID));
       m_db.Execute(strSQL);
     }
     else
     {
       // exists, modify it
       strSQL =
         String.Format(
           "update actorinfo set dateofbirth='{1}', placeofbirth='{2}' , minibio='{3}' , biography='{4}' , thumbURL='{5}' , IMDBActorID='{6}' where idActor={0}",
           idActor, DatabaseUtility.RemoveInvalidChars(actor.DateOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.PlaceOfBirth),
           DatabaseUtility.RemoveInvalidChars(actor.MiniBiography),
           DatabaseUtility.RemoveInvalidChars(actor.Biography),
           DatabaseUtility.RemoveInvalidChars(actor.ThumbnailUrl),
           DatabaseUtility.RemoveInvalidChars(actor.IMDBActorID));
       m_db.Execute(strSQL);
       RemoveActorInfoMovie(idActor);
     }
     for (int i = 0; i < actor.Count; ++i)
     {
       AddActorInfoMovie(idActor, actor[i]);
     }
     return;
   }
   catch (Exception ex)
   {
     Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
     Open();
   }
   return;
 }
コード例 #18
0
    private void FetchActorDetails()
    {
      string line1 = _actor;
      string line2 = string.Empty;
      string line3 = string.Empty;
      OnProgress(line1, line2, line3, -1);
      _imdb.GetActorDetails(_imdb[_actorIndex], out _imdbActor);

      // Try to update role
      for (int j = 0; j < _imdbActor.Count; j++)
      {
        string actorRole = _imdbActor[j].Role;
        string actorMovieId = _imdbActor[j].MovieImdbID;
        
        if (actorMovieId == _movieDetails.IMDBNumber)
        {
          if (!string.IsNullOrEmpty(actorRole))
          {
            VideoDatabase.AddActorToMovie(_movieDetails.ID, _actorId, actorRole);
          }

          break;
        }
      }

      // Update ActorImdbId
      string sql = string.Format("update Actors set IMDBActorId='{0}' where idActor ={1}",
                                  _imdbActor.IMDBActorID,
                                  _actorId);
      bool error = false;
      VideoDatabase.ExecuteSql(sql, out error);

      // Keep user actor image
      bool userActorImage = false;
      IMDBActor tmpActor = new IMDBActor();
      tmpActor = VideoDatabase.GetActorInfo(_actorId);

      if (tmpActor != null && tmpActor.ThumbnailUrl.StartsWith("file://"))
      {
        _imdbActor.ThumbnailUrl = tmpActor.ThumbnailUrl;
        userActorImage = true;
      }

      VideoDatabase.SetActorInfo(_actorId, _imdbActor);
      
      // Actor thumbs
      if (!string.IsNullOrEmpty(_imdbActor.ThumbnailUrl) && !userActorImage)
      {
        string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, _actorId.ToString());
        string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieActors, _actorId.ToString());
        Util.Utils.FileDelete(largeCoverArtImage);
        Util.Utils.FileDelete(coverArtImage);
        line1 = _actor;
        line2 = GUILocalizeStrings.Get(1009); //Downloading cover art
        line3 = string.Empty;
        OnProgress(line1, line2, line3, -1);
        DownloadCoverArt(Thumbs.MovieActors, _imdbActor.ThumbnailUrl, _actorId.ToString());
      }
      //else
      //{
      //  // Sometimes we can have wrong actor pic (wrong actor selected in list before) so delete it
      //  string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, _actorId.ToString());
      //  string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieActors, _actorId.ToString());
      //  Util.Utils.FileDelete(largeCoverArtImage);
      //  Util.Utils.FileDelete(coverArtImage);
      //}
      _imdbActor = VideoDatabase.GetActorInfo(_actorId);
    }
コード例 #19
0
 public void AddActorInfoMovie(int idActor, IMDBActor.IMDBActorMovie movie)
 {
   //idActor, idDirector , strPlotOutline , strPlot , strTagLine , strVotes , fRating ,strCast ,strCredits , iYear , strGenre , strPictureURL , strTitle , IMDBID , mpaa ,runtime , iswatched , role 
   string movieTitle = DatabaseUtility.RemoveInvalidChars(movie.MovieTitle);
   try
   {
     if (null == m_db)
     {
       return;
     }
     // Changed-added IMDBid value
     string strSQL =
       String.Format(
         "insert into actorinfomovies (idActor, idDirector , strPlotOutline , strPlot , strTagLine , strVotes , fRating ,strCast ,strCredits , iYear , strGenre , strPictureURL , strTitle , IMDBID , mpaa ,runtime , iswatched , role  ) values( {0} ,{1} ,'{2}' , '{3}' , '{4}' , '{5}' , '{6}' ,'{7}' ,'{8}' , {9} , '{10}' , '{11}' , '{12}' , '{13}' ,'{14}',{15} , {16} , '{17}' )",
         idActor, -1, "-", "-", "-", "-", "-", "-", "-", movie.Year, "-", "-", movieTitle, movie.imdbID, "-", -1, 0,
         DatabaseUtility.RemoveInvalidChars(movie.Role));
     m_db.Execute(strSQL);
     return;
   }
   catch (Exception ex)
   {
     Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
     Open();
   }
   return;
 }
コード例 #20
0
 private static void DownloadActors(IMDBMovie movieDetails)
 {
   char[] splitter = {'\n', ','};
   string[] actors = movieDetails.Cast.Split(splitter);
   if (actors.Length > 0)
   {
     for (int i = 0; i < actors.Length; ++i)
     {
       int percent = (int)(i * 100) / (1 + actors.Length);
       int pos = actors[i].IndexOf(" as ");
       string actor = actors[i];
       if (pos >= 0)
       {
         actor = actors[i].Substring(0, pos);
       }
       actor = actor.Trim();
       string strThumb = Util.Utils.GetCoverArtName(Thumbs.MovieActors, actor);
       if (!File.Exists(strThumb))
       {
         _imdb.FindActor(actor);
         IMDBActor imdbActor = new IMDBActor();
         for (int x = 0; x < _imdb.Count; ++x)
         {
           _imdb.GetActorDetails(_imdb[x], false, out imdbActor);
           if (imdbActor.ThumbnailUrl != null && imdbActor.ThumbnailUrl.Length > 0)
           {
             break;
           }
         }
         if (imdbActor.ThumbnailUrl != null)
         {
           if (imdbActor.ThumbnailUrl.Length != 0)
           {
             int actorId = VideoDatabase.AddActor(actor);
             if (actorId > 0)
             {
               VideoDatabase.SetActorInfo(actorId, imdbActor);
             }
             //ShowProgress(GUILocalizeStrings.Get(1009), actor, "", percent);
             DownloadThumbnail(Thumbs.MovieActors, imdbActor.ThumbnailUrl, actor);
           }
           else
           {
             Log.Debug("GUIVideoFiles: url=empty for actor {0}", actor);
           }
         }
         else
         {
           Log.Debug("GUIVideoFiles: url=null for actor {0}", actor);
         }
       }
     }
   }
 }
コード例 #21
0
    // Changed get thumbnailURL - IMDBActorID - IMDBID for movies
    public IMDBActor GetActorInfo(int idActor)
    {
      //"CREATE TABLE actorinfo ( idActor integer, dateofbirth text, placeofbirth text, minibio text, biography text
      try
      {
        if (null == m_db)
        {
          return null;
        }
        string strSQL =
          String.Format(
            "select * from actors,actorinfo where actors.idActor=actorinfo.idActor and actors.idActor ={0}", idActor);
        SQLiteResultSet results = m_db.Execute(strSQL);
        if (results.Rows.Count != 0)
        {
          IMDBActor actor = new IMDBActor();
          actor.Biography = DatabaseUtility.Get(results, 0, "actorinfo.biography".Replace("''", "'"));
          actor.DateOfBirth = DatabaseUtility.Get(results, 0, "actorinfo.dateofbirth");
          actor.MiniBiography = DatabaseUtility.Get(results, 0, "actorinfo.minibio".Replace("''", "'"));
          actor.Name = DatabaseUtility.Get(results, 0, "actors.strActor".Replace("''", "'"));
          actor.PlaceOfBirth = DatabaseUtility.Get(results, 0, "actorinfo.placeofbirth".Replace("''", "'"));
          actor.ThumbnailUrl = DatabaseUtility.Get(results, 0, "actorinfo.thumbURL");
          actor.IMDBActorID = DatabaseUtility.Get(results, 0, "actorinfo.IMDBActorID");

          strSQL = String.Format("select * from actorinfomovies where idActor ={0}", idActor);
          results = m_db.Execute(strSQL);
          for (int i = 0; i < results.Rows.Count; ++i)
          {
            IMDBActor.IMDBActorMovie movie = new IMDBActor.IMDBActorMovie();
            movie.MovieTitle = DatabaseUtility.Get(results, i, "strTitle");
            movie.Role = DatabaseUtility.Get(results, i, "role");
            movie.Year = Int32.Parse(DatabaseUtility.Get(results, i, "iYear"));
            // Added IMDBid
            movie.imdbID = DatabaseUtility.Get(results, i, "IMDBID");
            actor.Add(movie);
          }
          return actor;
        }
      }
      catch (Exception ex)
      {
        Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
        Open();
      }
      return null;
    }
コード例 #22
0
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      GUIPropertyManager.SetProperty("#groupmovielist", string.Empty);
      string strView = string.Empty;
      int currentViewlvl = 0;
      
      if (handler != null)
      {
        strView = handler.CurrentLevelWhere.ToLowerInvariant();
        currentViewlvl = handler.CurrentLevel;

        if (handler.CurrentLevel > 0)
        {
          FilterDefinition defCurrent = (FilterDefinition) handler.View.Filters[handler.CurrentLevel - 1];
          string selectedValue = defCurrent.SelectedValue;
          Int32 iSelectedValue;
          
          if (Int32.TryParse(selectedValue, out iSelectedValue))
          {
            if (strView == "actor" || strView == "director")
            {
              selectedValue = VideoDatabase.GetActorNameById(iSelectedValue);
            }

            if (strView == "genre")
            {
              selectedValue = VideoDatabase.GetGenreById(iSelectedValue);
            }

            if (strView == "user groups")
            {
              selectedValue = VideoDatabase.GetUserGroupById(iSelectedValue);
            }
          }

          GUIPropertyManager.SetProperty("#currentmodule",
                                         String.Format("{0}/{1} - {2}", GUILocalizeStrings.Get(100006),
                                                       handler.LocalizedCurrentView, selectedValue));
        }
      }

      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.IsEmpty = true;
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      
      // Set current item if thumb thread is working (thread can still update thumbs while user changed
      // item) thus preventing sudden jump to initial selected item before thread start
      if (_setThumbs != null && _setThumbs.IsAlive)
      {
        currentSelectedItem = facadeLayout.SelectedListItemIndex;
      }

      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;
      
      if (movie == null)
      {
        movie = new IMDBMovie();
      }
      
      if (!string.IsNullOrEmpty(movie.VideoFileName))
      {
        movie.SetProperties(false, movie.VideoFileName);
      }
      else
      {
        switch (strView)
        {
          case "actorindex":
          case "directorindex":
          case "titleindex":
            movie.IsEmpty = true;
            movie.SetProperties(false, string.Empty);
            break;

          default:
            movie.SetProperties(false, string.Empty);
            break;
        }
        
        // Set title properties for other views (year, genres..)
        if (!string.IsNullOrEmpty(item.Label))
        {
          GUIPropertyManager.SetProperty("#title", item.Label);

          if (item.MusicTag != null)
          {
            GUIPropertyManager.SetProperty("#groupmovielist", item.MusicTag.ToString());
          }
        }
      }
      
      IMDBActor actor = VideoDatabase.GetActorInfo(movie.ActorID);
      
      if (actor != null)
      {
        actor.SetProperties();
      }
      else
      {
        actor = new IMDBActor();
        actor.SetProperties();
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      if (movie.Actor != string.Empty)
      {
        GUIPropertyManager.SetProperty("#title", movie.Actor);
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, movie.ActorID.ToString());
        
        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
      
      // Random movieId by view (for FA) for selected group
      ArrayList mList = new ArrayList();
      GetItemViewHistory(strView, mList, currentViewlvl);
    }
コード例 #23
0
    // Changed actors find & count display on progress bar window
    private void FetchActorsInMovie()
    {
      bool director = false; // Actor is director
      bool byImdbId = true;
      // Lookup by movie IMDBid number from which will get actorIMDBid, lookup by name is not so db friendly

      if (_movieDetails == null)
      {
        return;
      }
      ArrayList actors = new ArrayList();
      // Try first by IMDBMovieId to find IMDBactorID (100% accuracy)
      IMDBSearch actorlist = new IMDBSearch();
      // New actor search method
      actorlist.SearchActors(_movieDetails.IMDBNumber, ref actors);

      // If search by IMDBid fails try old fetch method (by name, less accurate)
      if (actors.Count == 0)
      {
        byImdbId = false;
        string cast = _movieDetails.Cast + "," + _movieDetails.Director;
        char[] splitter = {'\n', ','};
        string[] temp = cast.Split(splitter);

        foreach (string element in temp)
        {
          string el = element.Trim();
          if (el != string.Empty)
          {
            actors.Add(el);
          }
        }
      }

      if (actors.Count > 0)
      {
        int percent = 0;
        for (int i = 0; i < actors.Count; ++i)
        {
          // Is actor movie director??
          switch (byImdbId) // True-new method, false-old method
          {
            case true:
              {
                // Director
                if (actors[i].ToString().Length > 1 && actors[i].ToString().Substring(0, 2) == "*d")
                {
                  director = true;
                  // Remove director prefix (came from IMDBmovieID actor search)
                  actors[i] = actors[0].ToString().Replace("*d", string.Empty);
                }
                else
                {
                  director = false;
                }
                break;
              }
            case false:
              {
                // from old method (just comparing name with dbmoviedetail director name)
                if (actors[i].ToString().Contains(_movieDetails.Director))
                {
                  director = true;
                }
                else
                {
                  director = false;
                }
                break;
              }
          }
          string actor = (string)actors[i];
          string role = string.Empty;

          if (byImdbId == false)
          {
            int pos = actor.IndexOf(" as ");
            if (pos >= 0)
            {
              role = actor.Substring(pos + 4);
              actor = actor.Substring(0, pos);
            }
          }

          actor = actor.Trim();
          string line1 = GUILocalizeStrings.Get(986) + " " + (i + 1) + "/" + actors.Count;
          string line2 = actor;
          string line3 = string.Empty;
          OnProgress(line1, line2, line3, percent);
          _imdb.FindActor(actor);
          IMDBActor imdbActor = new IMDBActor();

          if (_imdb.Count > 0)
          {
            int index = FuzzyMatch(actor);
            if (index == -1)
            {
              index = 0;
            }

            //Log.Info("Getting actor:{0}", _imdb[index].Title);
            _imdb.GetActorDetails(_imdb[index], director, out imdbActor);
            //Log.Info("Adding actor:{0}({1}),{2}", imdbActor.Name, actor, percent);
            int actorId = VideoDatabase.AddActor(imdbActor.Name);
            if (actorId > 0)
            {
              line1 = GUILocalizeStrings.Get(986) + " " + (i + 1) + "/" + actors.Count;
              line2 = imdbActor.Name;
              line3 = string.Empty;
              OnProgress(line1, line2, line3, -1);
              VideoDatabase.SetActorInfo(actorId, imdbActor);
              VideoDatabase.AddActorToMovie(_movieDetails.ID, actorId);

              if (imdbActor.ThumbnailUrl != string.Empty)
              {
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieActors, imdbActor.Name);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieActors, imdbActor.Name);
                Util.Utils.FileDelete(largeCoverArt);
                Util.Utils.FileDelete(coverArt);
                line1 = GUILocalizeStrings.Get(986) + " " + (i + 1) + "/" + actors.Count;
                line2 = GUILocalizeStrings.Get(1009);
                OnProgress(line1, line2, line3, percent);
                DownloadCoverArt(Thumbs.MovieActors, imdbActor.ThumbnailUrl, imdbActor.Name);
              }
            }
          }
          else
          {
            line1 = GUILocalizeStrings.Get(986) + " " + (i + 1) + "/" + actors.Count;
            line2 = actor;
            line3 = string.Empty;
            OnProgress(line1, line2, line3, -1);
            int actorId = VideoDatabase.AddActor(actor);
            imdbActor.Name = actor;
            IMDBActor.IMDBActorMovie imdbActorMovie = new IMDBActor.IMDBActorMovie();
            imdbActorMovie.MovieTitle = _movieDetails.Title;
            imdbActorMovie.Year = _movieDetails.Year;
            imdbActorMovie.Role = role;
            imdbActor.Add(imdbActorMovie);
            VideoDatabase.SetActorInfo(actorId, imdbActor);
            VideoDatabase.AddActorToMovie(_movieDetails.ID, actorId);
          }
          percent += 100 / actors.Count;
        }
      }
    }
コード例 #24
0
ファイル: VideoDatabase.cs プロジェクト: nio22/MediaPortal-1
 public static void SetActorInfo(int idActor, IMDBActor actor)
 {
   _database.SetActorInfo(idActor, actor);
 }
コード例 #25
0
    private void OnItemSelected(GUIListItem item, GUIControl parent)
    {
      if (item.Label == "..")
      {
        IMDBMovie notMovie = new IMDBMovie();
        notMovie.SetProperties(true, string.Empty);
        IMDBActor notActor = new IMDBActor();
        notActor.SetProperties();
        return;
      }
      IMDBMovie movie = item.AlbumInfoTag as IMDBMovie;

      if (movie == null)
      {
        movie = new IMDBMovie();
      }

      ArrayList files = new ArrayList();
      VideoDatabase.GetFilesForMovie(movie.ID, ref files);

      if (files.Count > 0)
      {
        movie.SetProperties(false, (string)files[0]);
      }
      else
      {
        movie.SetProperties(false, string.Empty);
      }

      if (movie.ID >= 0)
      {
        string titleExt = movie.Title + "{" + movie.ID + "}";
        string coverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);

        if (Util.Utils.FileExistsInCache(coverArtImage))
        {
          facadeLayout.FilmstripLayout.InfoImageFileName = coverArtImage;
        }
      }
    }
コード例 #26
0
ファイル: IMDB.cs プロジェクト: npcomplete111/MediaPortal-1
    // Changed - parsing all actor DB fields through HTML (IMDB changed HTML code)
    public bool GetActorDetails(IMDBUrl url, bool director, out IMDBActor actor)
    {
      actor = new IMDBActor();
      try
      {
        string absoluteUri;
        string strBody = GetPage(url.URL, "utf-8", out absoluteUri);
        if (strBody == null)
        {
          return false;
        }
        if (strBody.Length == 0)
        {
          return false;
        }
        // IMDBActorID
        try
        {
          int pos = url.URL.LastIndexOf("nm");
          string id = url.URL.Substring(pos, 9).Replace("/", string.Empty);
          actor.IMDBActorID = id;
        }
        catch (Exception) {}

        HTMLParser parser = new HTMLParser(strBody);
        string strThumb = string.Empty;
        string value = string.Empty;
        string value2 = string.Empty;
        // Actor name
        if ((parser.skipToEndOf("<title>")) &&
            (parser.extractTo("- IMDb</title>", ref value)))
        {
          value = new HTMLUtil().ConvertHTMLToAnsi(value);
          value = Util.Utils.RemoveParenthesis(value).Trim();
          actor.Name = HttpUtility.HtmlDecode(value.Trim());
        }
        if (actor.Name == string.Empty)
        {
          actor.Name = url.Title;
        }
        // Photo
        string parserTxt = parser.Content;
        string photoBlock = string.Empty;
        if (parser.skipToStartOf("<td id=\"img_primary\"") &&
            (parser.extractTo("</td>", ref photoBlock)))
        {
          parser.Content = photoBlock;
          if ((parser.skipToEndOf("<img src=\"")) &&
              (parser.extractTo("\"", ref strThumb)))
          {
            actor.ThumbnailUrl = strThumb;
          }
          parser.Content = parserTxt;
        }
        // Birth date
        if ((parser.skipToEndOf("Born:")) &&
            (parser.skipToEndOf("birth_monthday=")) &&
            (parser.skipToEndOf(">")) &&
            (parser.extractTo("<", ref value)) &&
            (parser.skipToEndOf("year=")) &&
            (parser.extractTo("\"", ref value2)))
          
        {
          actor.DateOfBirth = value + " " + value2;
        }
        // Death date
        if ((parser.skipToEndOf(">Died:</h4>")) &&
            (parser.skipToEndOf("deaths\">")) &&
            (parser.extractTo("<", ref value)) &&
            (parser.skipToEndOf("death_date=")) &&
            (parser.extractTo("\"", ref value2)))
        {
          if (actor.DateOfBirth == string.Empty)
            actor.DateOfBirth = "?";
          actor.DateOfBirth += " ~ " + value + " " + value2;
        }

        parser.resetPosition();
        // Birth place
        if ((parser.skipToEndOf("birth_place=")) &&
            (parser.skipToEndOf(">")) &&
            (parser.extractTo("<", ref value)))
        {
          actor.PlaceOfBirth = HttpUtility.HtmlDecode(value);
        }
        //Mini Biography
        parser.resetPosition();
        if ((parser.skipToEndOf("<td id=\"overview-top\">")) &&
            (parser.skipToEndOf("<p>")) &&
            (parser.extractTo("See full bio</a>", ref value)))
        {
          value = new HTMLUtil().ConvertHTMLToAnsi(value);
          actor.MiniBiography = Util.Utils.stripHTMLtags(value);
          actor.MiniBiography = actor.MiniBiography.Replace("See full bio »", string.Empty).Trim();
          actor.MiniBiography = HttpUtility.HtmlDecode(actor.MiniBiography); // Remove HTML entities like &#189;
          if (actor.MiniBiography != string.Empty)
          {
            // get complete biography
            string bioURL = absoluteUri;
            if (!bioURL.EndsWith("/"))
            {
              bioURL += "/bio";
            }
            else
              bioURL += "bio";
            string strBioBody = GetPage(bioURL, "utf-8", out absoluteUri);
            if (!string.IsNullOrEmpty(strBioBody))
            {
              HTMLParser parser1 = new HTMLParser(strBioBody);
              if (parser1.skipToEndOf("<h5>Mini Biography</h5>") &&
                  parser1.extractTo("</p>", ref value))
              {
                value = new HTMLUtil().ConvertHTMLToAnsi(value);
                actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                actor.Biography = HttpUtility.HtmlDecode(actor.Biography); // Remove HTML entities like &#189;
              }
            }
          }
        }
        // Person is movie director or an actor/actress
        bool isActorPass = false;
        bool isDirectorPass = false;
        parser.resetPosition();

        if (director)
        {
          if ((parser.skipToEndOf("name=\"Director\">Director</a>")) &&
              (parser.skipToEndOf("</div>")))
          {
            isDirectorPass = true;
          }
        }
        else
        {
          if (parser.skipToEndOf("name=\"Actress\">Actress</a>") || parser.skipToEndOf("name=\"Actor\">Actor</a>"))
          {
            isActorPass = true;
          }
        }
        // Get filmography
        if (isDirectorPass | isActorPass)
        {
          string movies = string.Empty;
          // Get films and roles block
          if (parser.extractTo("<div id", ref movies))
          {
            parser.Content = movies;
          }
          // Parse block for evey film and get year, title and it's imdbID and role
          while (parser.skipToStartOf("<span class=\"year_column\""))
          {
            string movie = string.Empty;
            if (parser.extractTo("<div class", ref movie))
            {
              movie += "</li>";
              HTMLParser movieParser = new HTMLParser(movie);
              string title = string.Empty;
              string strYear = string.Empty;
              string role = string.Empty;
              string imdbID = string.Empty;
              // IMDBid
              movieParser.skipToEndOf("title/");
              movieParser.extractTo("/", ref imdbID);
              // Title
              movieParser.resetPosition();
              movieParser.skipToEndOf("<a");
              movieParser.skipToEndOf(">");
              movieParser.extractTo("<br/>", ref title);
              title = Util.Utils.stripHTMLtags(title);
              title = title.Replace("\n", " ").Replace("\r", string.Empty);
              title = HttpUtility.HtmlDecode(title.Trim()); // Remove HTML entities like &#189;
              // Year
              movieParser.resetPosition();
              if (movieParser.skipToStartOf(">20") &&
                  movieParser.skipToEndOf(">"))
              {
                movieParser.extractTo("<", ref strYear);
              }
              else if (movieParser.skipToStartOf(">19") &&
                       movieParser.skipToEndOf(">"))
              {
                movieParser.extractTo("<", ref strYear);
              }
              // Roles
              if ((director == false) && (movieParser.skipToEndOf("<br/>"))) // Role case 1, no character link
              {
                movieParser.extractTo("<", ref role);
                role = Util.Utils.stripHTMLtags(role).Trim();
                role = HttpUtility.HtmlDecode(role.Replace("\n", " ")
                                                .Replace("\r", string.Empty).Trim());
                if (role == string.Empty) // Role case 2, with character link
                {
                  movieParser.resetPosition();
                  movieParser.skipToEndOf("<br/>");
                  movieParser.extractTo("</a>", ref role);
                  role = Util.Utils.stripHTMLtags(role).Trim();
                  role = HttpUtility.HtmlDecode(role.Replace("\n", " ")
                                                  .Replace("\r", string.Empty).Trim());
                }
              }
              else
              {
                // Just director
                if (director)
                  role = "Director";
              }

              int year = 0;
              try
              {
                year = Int32.Parse(strYear.Substring(0, 4));
              }
              catch (Exception)
              {
                year = 1900;
              }
              IMDBActor.IMDBActorMovie actorMovie = new IMDBActor.IMDBActorMovie();
              actorMovie.MovieTitle = title;
              actorMovie.Role = role;
              actorMovie.Year = year;
              actorMovie.imdbID = imdbID;
              actor.Add(actorMovie);
            }
          }
        }
        return true;
      }
      catch (Exception ex)
      {
        Log.Error("IMDB.GetActorDetails({0} exception:{1} {2} {3}", url.URL, ex.Message, ex.Source, ex.StackTrace);
      }
      return false;
    }
コード例 #27
0
    protected override void OnPageDestroy(int newWindowId)
    {
      //if (m_bRunning)
      //{
      //  m_bRunning = false;
      //  m_pParentWindow = null;
      //  GUIWindowManager.UnRoute();
      //}

      currentActor = null;

      base.OnPageDestroy(newWindowId);
    }
コード例 #28
0
 public void AddActorInfoMovie(int idActor, IMDBActor.IMDBActorMovie movie)
 {
   string movieTitle = DatabaseUtility.RemoveInvalidChars(movie.MovieTitle);
   string movieRole = DatabaseUtility.RemoveInvalidChars(movie.Role);
   
   try
   {
     if (null == m_db)
     {
       return;
     }
     
     string strSQL =
       String.Format(
         "INSERT INTO actorinfomovies (idActor, idDirector , strPlotOutline , strPlot , strTagLine , strVotes , fRating ,strCast ,strCredits , iYear , strGenre , strPictureURL , strTitle , IMDBID , mpaa ,runtime , iswatched , role  ) VALUES( {0} ,{1} ,'{2}' , '{3}' , '{4}' , '{5}' , '{6}' ,'{7}' ,'{8}' , {9} , '{10}' , '{11}' , '{12}' , '{13}' ,'{14}',{15} , {16} , '{17}' )",
                                       idActor, 
                                       -1, 
                                       "",
                                       "", 
                                       "", 
                                       "", 
                                       "",
                                       "",
                                       "", 
                                       1900,
                                       "",
                                       "",
                                       "", 
                                       movie.MovieImdbID, 
                                       "", 
                                       -1, 
                                       0,
                                       movieRole);
     m_db.Execute(strSQL);
     
     // populate IMDB Movies
     if (CheckMovieImdbId(movie.MovieImdbID))
     {
       strSQL = String.Format("SELECT * FROM IMDBMovies WHERE idIMDB='{0}'", movie.MovieImdbID);
       SQLiteResultSet results = m_db.Execute(strSQL);
       
       if (results.Rows.Count == 0)
       {
         strSQL = String.Format("INSERT INTO IMDBMovies (  idIMDB, idTmdb, strPlot, strCast, strCredits, iYear, strGenre, strPictureURL, strTitle, mpaa) VALUES( '{0}' ,'{1}' ,'{2}' , '{3}' , '{4}' , {5} , '{6}' ,'{7}' ,'{8}' , '{9}')",
                                   movie.MovieImdbID,
                                   "", // Not used (TMDBid)
                                   "",
                                   "",
                                   "",
                                   movie.Year,
                                   "",
                                   "",
                                   movieTitle,
                                   "");
         m_db.Execute(strSQL);
       }
       else
       {
         strSQL = String.Format("UPDATE IMDBMovies SET iYear={0}, strTitle='{1}' WHERE idIMDB='{2}'",
                                   movie.Year,
                                   movieTitle,
                                   movie.MovieImdbID);
         m_db.Execute(strSQL);
       }
     }
     return;
   }
   catch (Exception ex)
   {
     Log.Error("videodatabase exception err:{0} stack:{1}", ex.Message, ex.StackTrace);
     Open();
   }
   return;
 }
コード例 #29
0
ファイル: GUIVideoInfo.cs プロジェクト: akhilgt/MediaPortal-1
    private void OnVideoArtistInfo(IMDBActor actor, bool refresh)
    {
      GUIVideoArtistInfo infoDlg =
        (GUIVideoArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_ARTIST_INFO);
      
      if (infoDlg == null)
      {
        return;
      }

      if (actor != null)
      {
        string restriction = "30"; // Refresh every week actor info and movies

        TimeSpan ts = new TimeSpan(Convert.ToInt32(restriction), 0, 0, 0);
        DateTime searchDate = DateTime.Today - ts;
        DateTime lastUpdate;

        if (DateTime.TryParse(actor.LastUpdate, out lastUpdate))
        {
          if (searchDate > lastUpdate)
          {
            refresh = true;
          }
        }
      }


      // Scan if no actor record or actor movies are unknown or refresh
      if (actor == null || actor.Count == 0 || refresh)
      {
        string selectedActor;

        if (VideoDatabase.CheckActorImdbId(listActors.SelectedListItem.Label3))
        {
           selectedActor = listActors.SelectedListItem.Label3; // ActorImdbId
        }
        else
        {
          selectedActor = listActors.SelectedListItem.Label2; // Actor Name
        }
        
        GUIListItem item = listActors.SelectedListItem;
        item.AlbumInfoTag = _currentMovie;
        IMDBFetcher.FetchMovieActor(this, _currentMovie, selectedActor, item.ItemId);
        actor = VideoDatabase.GetActorInfo(item.ItemId);

        if (actor == null)
          return;

        // Refresh selected item
        item.Label = actor.Name + " - " + VideoDatabase.GetRoleByMovieAndActorId(Movie.ID, item.ItemId);
      }
      
      infoDlg.Actor = actor;
      infoDlg.Movie = _currentMovie;
      GUIWindowManager.ActivateWindow((int)Window.WINDOW_VIDEO_ARTIST_INFO);
    }
コード例 #30
0
    public void ImportNfo(string nfoFile, bool skipExisting, bool refreshdbOnly)
    {
      IMDBMovie movie = new IMDBMovie();
      bool isMovieFolder = Util.Utils.IsFolderDedicatedMovieFolder(Path.GetFullPath(nfoFile));
      bool useInternalNfoScraper = false;
      
      using (Profile.Settings xmlreader = new Profile.MPSettings())
      {
        // Use only nfo scrapper
        useInternalNfoScraper = xmlreader.GetValueAsBool("moviedatabase", "useonlynfoscraper", false);
      }

      try
      {
        XmlDocument doc = new XmlDocument();
        doc.Load(nfoFile);
        Log.Debug("Importing nfo file:{0}", nfoFile);

        if (doc.DocumentElement != null)
        {
          int id = -1;

          XmlNodeList movieList = doc.DocumentElement.SelectNodes("/movie");
          
          if (movieList == null)
          {
            Log.Debug("Movie tag for nfo file:{0} not exist. Nfo skipped.", nfoFile);
            return;
          }

          foreach (XmlNode nodeMovie in movieList)
          {
            string genre = string.Empty;
            string cast = string.Empty;
            string path = string.Empty;
            string nfofileName = string.Empty;
            
            #region nodes

            XmlNode nodeTitle = nodeMovie.SelectSingleNode("title");
            XmlNode nodeSortTitle = nodeMovie.SelectSingleNode("sorttitle");
            XmlNode nodeRating = nodeMovie.SelectSingleNode("rating");
            XmlNode nodeYear = nodeMovie.SelectSingleNode("year");
            XmlNode nodeDuration = nodeMovie.SelectSingleNode("runtime");
            XmlNode nodePlotShort = nodeMovie.SelectSingleNode("outline");
            XmlNode nodePlot = nodeMovie.SelectSingleNode("plot");
            XmlNode nodeTagline = nodeMovie.SelectSingleNode("tagline");
            XmlNode nodeDirector = nodeMovie.SelectSingleNode("director");
            XmlNode nodeDirectorImdb = nodeMovie.SelectSingleNode("directorimdb");
            XmlNode nodeImdbNumber = nodeMovie.SelectSingleNode("imdb");
            XmlNode nodeIdImdbNumber = nodeMovie.SelectSingleNode("id");
            XmlNode nodeMpaa = nodeMovie.SelectSingleNode("mpaa");
            XmlNode nodeTop250 = nodeMovie.SelectSingleNode("top250");
            XmlNode nodeVotes = nodeMovie.SelectSingleNode("votes");
            XmlNode nodeStudio = nodeMovie.SelectSingleNode("studio");
            XmlNode nodePlayCount = nodeMovie.SelectSingleNode("playcount");
            XmlNode nodeWatched = nodeMovie.SelectSingleNode("watched");
            XmlNode nodeFanart = nodeMovie.SelectSingleNode("fanart");
            XmlNode nodePoster = nodeMovie.SelectSingleNode("thumb");
            XmlNode nodeLanguage = nodeMovie.SelectSingleNode("language");
            XmlNode nodeCountry = nodeMovie.SelectSingleNode("country");
            XmlNode nodeReview = nodeMovie.SelectSingleNode("review");
            XmlNode nodeCredits = nodeMovie.SelectSingleNode("credits");
            
            #endregion

            #region Moviefiles

            // Get path from *.nfo file)
            Util.Utils.Split(nfoFile, out path, out nfofileName);
            // Movie filename to search from gathered files from nfo path
            nfofileName = Util.Utils.GetFilename(nfofileName, true);
            // Get all video files from nfo path
            ArrayList files = new ArrayList();
            GetVideoFiles(path, ref files);
            bool isDvdBdFolder = false;

            foreach (String file in files)
            {
              //Log.Debug("Import nfo-processing video file:{0} (Total files: {1})", file, files.Count);
              string logFilename = Path.GetFileName(file);

              if ((file.ToUpperInvariant().Contains("VIDEO_TS.IFO") ||
                  file.ToUpperInvariant().Contains("INDEX.BDMV")) && files.Count == 1)
              {
                var pattern = Util.Utils.StackExpression();
                int stackSequence = -1; // seq 0 = [x-y], seq 1 = CD1, Part1....
                int digit = 0;

                for (int i = 0; i < pattern.Length; i++)
                {
                  if (pattern[i].IsMatch(file))
                  {
                    digit = Convert.ToInt16(pattern[i].Match(file).Groups["digit"].Value);
                    stackSequence = i;
                    break;
                  }
                }
                if (digit > 1)
                {
                  Log.Debug("Import nfo-file: {0} is stack part.", file);
                  string filename;
                  string tmpPath = string.Empty;
                  DatabaseUtility.Split(file, out path, out filename);

                  try
                  {
                    if (stackSequence == 0)
                    {
                      string strReplace = "[" + digit;
                      int stackIndex = path.LastIndexOf(strReplace);
                      tmpPath = path.Remove(stackIndex, 2);
                      tmpPath = tmpPath.Insert(stackIndex, "[1");
                    }
                    else
                    {
                      int stackIndex = path.LastIndexOf(digit.ToString());
                      tmpPath = path.Remove(stackIndex, 1);
                      tmpPath = tmpPath.Insert(stackIndex, "1");
                    }

                    int movieId = VideoDatabase.GetMovieId(tmpPath + filename);
                    int pathId = VideoDatabase.AddPath(path);
                    Log.Debug("Import nfo-Adding file: {0}", logFilename);
                    VideoDatabase.AddFile(movieId, pathId, filename);
                    return;
                  }
                  catch(Exception ex)
                  {
                    Log.Error("Import nfo error-stack check for path {0} Error: {1}", path, ex.Message);
                    return;
                  }
                }

                id = VideoDatabase.AddMovie(file, true);
                movie.ID = id;
                isDvdBdFolder = true;
              }
              else
              {
                string tmpFile = string.Empty;
                string tmpPath = string.Empty;
                
                // Read filename
                Util.Utils.Split(file, out tmpPath, out tmpFile);
                // Remove extension
                tmpFile = Util.Utils.GetFilename(tmpFile, true);
                // Remove stack endings (CD1...)
                Util.Utils.RemoveStackEndings(ref tmpFile);
                Util.Utils.RemoveStackEndings(ref nfofileName);
                
                // Check and add to vdb and get movieId
                if (tmpFile.Equals(nfofileName, StringComparison.InvariantCultureIgnoreCase))
                {
                  Log.Debug("Import nfo-Adding file: {0}", logFilename);
                  id = VideoDatabase.AddMovie(file, true);
                  movie.ID = id;
                }
                else if (isMovieFolder && tmpPath.Length > 0) // Every movie in it's own folder, compare by folder name
                {
                  try
                  {
                    tmpPath = tmpPath.Substring(tmpPath.LastIndexOf(@"\") + 1).Trim();

                    if (tmpPath.Equals(nfofileName, StringComparison.InvariantCultureIgnoreCase) || nfofileName.ToLowerInvariant() == "movie")
                    {
                      Log.Debug("Import nfo-Adding file: {0}", logFilename);
                      id = VideoDatabase.AddMovie(file, true);
                      movie.ID = id;
                    }
                    else
                    {
                      Log.Debug("Import nfo-Skipping file:{0}", logFilename);
                    }
                  }
                  catch (Exception ex)
                  {
                    Log.Error("Import nfo-Error comparing path name. File:{0} Err.:{1}", file, ex.Message);
                  }
                }
                else
                {
                  Log.Debug("Import nfo-Skipping file: {0}", logFilename);
                }
              }
            }

            #endregion

            #region Check for existing movie or refresh database only
            
            GetMovieInfoById(id, ref movie);

            if (skipExisting && !movie.IsEmpty || refreshdbOnly && movie.IsEmpty || id < 1)
            {
              Log.Debug("Import nfo-Skipping import for movieId = {0}).", id);
              return;
            }

            movie = new IMDBMovie();
            movie.ID = id;

            #endregion

            #region Genre

            XmlNodeList genres = nodeMovie.SelectNodes("genre");
            
            foreach (XmlNode nodeGenre in genres)
            {
              if (nodeGenre.InnerText != null)
              {
                if (genre.Length > 0)
                {
                  genre += " / ";
                }
                genre += nodeGenre.InnerText;
              }
            }

            if (string.IsNullOrEmpty(genre))
            {
              genres = nodeMovie.SelectNodes("genres/genre");

              foreach (XmlNode nodeGenre in genres)
              {
                if (nodeGenre.InnerText != null)
                {
                  if (genre.Length > 0)
                  {
                    genre += " / ";
                  }
                  genre += nodeGenre.InnerText;
                }
              }
            }

            movie.Genre = genre;
            
            #endregion

            #region Credits (Writers)

            // Writers
            if (nodeCredits != null)
            {
              movie.WritingCredits = nodeCredits.InnerText;
            }
            #endregion

            #region DateAdded

            movie.DateAdded = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            
            #endregion

            #region Title

            // Title
            if (nodeTitle != null)
            {
              movie.Title = nodeTitle.InnerText;
            }

            #endregion

            #region Sort Title

            // SortTitle
            if (nodeSortTitle != null)
            {
              if (!string.IsNullOrEmpty(nodeTitle.InnerText))
              {
                movie.SortTitle = nodeSortTitle.InnerText;
              }
              else
              {
                movie.SortTitle = movie.Title;
              }
            }

            #endregion

            #region Language

            // Title
            if (nodeLanguage != null)
            {
              movie.Language = nodeLanguage.InnerText;
            }

            #endregion

            #region Country

            // Title
            if (nodeCountry != null)
            {
              movie.Country = nodeCountry.InnerText;
            }

            #endregion

            #region IMDB number

            // IMDB number
            if (nodeImdbNumber != null)
            {
              if (CheckMovieImdbId(nodeImdbNumber.InnerText))
              {
                movie.IMDBNumber = nodeImdbNumber.InnerText;
              }
            }

            if (string.IsNullOrEmpty(movie.IMDBNumber) && nodeIdImdbNumber != null)
            {
              if (CheckMovieImdbId(nodeIdImdbNumber.InnerText))
              {
                movie.IMDBNumber = nodeIdImdbNumber.InnerText;
              }
            }

            #endregion

            #region CD/DVD labels

            // CD label
            movie.CDLabel = string.Empty;

            // DVD label
            movie.DVDLabel = string.Empty;

            #endregion

            #region Director

            // Director
            string dirImdb = string.Empty;
            if (nodeDirectorImdb != null)
            {
              dirImdb = nodeDirectorImdb.InnerText;
              
              if (!CheckActorImdbId(dirImdb))
              {
                dirImdb = string.Empty;
              }
            }
            if (nodeDirector != null)
            {
              movie.Director = nodeDirector.InnerText;
              movie.DirectorID = VideoDatabase.AddActor(dirImdb, movie.Director);
            }
            #endregion

            #region Studio

            // Studio
            if (nodeStudio != null)
            {
              movie.Studios = nodeStudio.InnerText;
            }

            #endregion

            #region MPAA

            // MPAA
            if (nodeMpaa != null)
            {
              movie.MPARating = nodeMpaa.InnerText;
            }
            else
            {
              movie.MPARating = "NR";
            }
            
            #endregion
            
            #region Plot/Short plot

            // Plot
            if (nodePlot != null)
            {
              movie.Plot = nodePlot.InnerText;
            }
            else
            {
              movie.Plot = string.Empty;
            }
            // Short plot
            if (nodePlotShort != null)
            {
              movie.PlotOutline = nodePlotShort.InnerText;
            }
            else
            {
              movie.PlotOutline = string.Empty;
            }

            #endregion

            #region Review

            // Title
            if (nodeReview != null)
            {
              movie.UserReview = nodeReview.InnerText;
            }

            #endregion

            #region Rating (n.n/10)

            // Rating
            if (nodeRating != null)
            {
              double rating = 0;
              if (Double.TryParse(nodeRating.InnerText.Replace(".", ","), out rating))
              {
                movie.Rating = (float) rating;
                
                if (movie.Rating > 10.0f)
                {
                  movie.Rating /= 10.0f;
                }
              }
            }

            #endregion

            #region Duration

            // Duration
            if (nodeDuration != null)
            {
              int runtime = 0;
              if (Int32.TryParse(nodeDuration.InnerText, out runtime))
              {
                movie.RunTime = runtime;
              }
              else
              {
                string regex = "(?<h>[0-9]*)h.(?<m>[0-9]*)";
                MatchCollection mc = Regex.Matches(nodeDuration.InnerText, regex, RegexOptions.Singleline | RegexOptions.IgnoreCase);
                if (mc.Count > 0)
                {
                  foreach (Match m in mc)
                  {
                    int hours = 0;
                    Int32.TryParse(m.Groups["h"].Value, out hours);
                    int minutes = 0;
                    Int32.TryParse(m.Groups["m"].Value, out minutes);
                    hours = hours*60;
                    minutes = hours + minutes;
                    movie.RunTime = minutes;
                  }
                }
                else
                {
                  regex = @"\d*\s*min.";
                  if (Regex.Match(nodeDuration.InnerText, regex, RegexOptions.IgnoreCase).Success)
                  {
                    regex = @"\d*";
                    int minutes = 0;
                    Int32.TryParse(Regex.Match(nodeDuration.InnerText, regex).Value, out minutes);
                    movie.RunTime = minutes;
                  }
                }
              }
            }
            else
            {
              movie.RunTime = 0;
            }

            #endregion
            
            #region Tagline

            // Tagline
            if (nodeTagline != null)
            {
              movie.TagLine = nodeTagline.InnerText;
            }

            #endregion

            #region TOP250

            // Top250
            if (nodeTop250 != null)
            {
              int top250 = 0;
              Int32.TryParse(nodeTop250.InnerText, out top250);
              movie.Top250 = top250;
            }
            else
            {
              movie.Top250 = 0;
            }


            #endregion

            #region votes

            // Votes
            if (nodeVotes != null)
            {
              movie.Votes = nodeVotes.InnerText;
            }

            #endregion

            #region Watched/watched count

            // Watched
            int percent = 0;
            int watchedCount = 0;
            GetMovieWatchedStatus(movie.ID, out percent, out watchedCount);

            if (watchedCount < 1)
            {
              if (nodeWatched != null)
              {
                if (nodeWatched.InnerText.ToLowerInvariant() == "true" || nodeWatched.InnerText == "1")
                {
                  movie.Watched = 1;
                  VideoDatabase.SetMovieWatchedStatus(movie.ID, true, 100);
                }
                else
                {
                  movie.Watched = 0;
                  VideoDatabase.SetMovieWatchedStatus(movie.ID, false, 0);
                }
              }
              // Watched count
              if (nodePlayCount != null)
              {
                watchedCount = 0;
                Int32.TryParse(nodePlayCount.InnerText, out watchedCount);
                SetMovieWatchedCount(movie.ID, watchedCount);
                
                if (watchedCount > 0 && movie.Watched == 0)
                {
                  movie.Watched = 1;
                  VideoDatabase.SetMovieWatchedStatus(movie.ID, true, 100);
                }
                else if (watchedCount == 0 && movie.Watched > 0)
                {
                  SetMovieWatchedCount(movie.ID, 1);
                }
              }
            }
            else
            {
              movie.Watched = 1;
            }

            #endregion

            #region Year

            // Year
            if (nodeYear != null)
            {
              int year = 0;
              Int32.TryParse(nodeYear.InnerText, out year);
              movie.Year = year;
            }

            #endregion

            #region poster

            // Poster
            string thumbJpgFile = string.Empty;
            string thumbTbnFile = string.Empty;
            string thumbFolderJpgFile = string.Empty;
            string thumbFolderTbnFile = string.Empty;
            string titleExt = movie.Title + "{" + id + "}";
            string jpgExt = @".jpg";
            string tbnExt = @".tbn";
            string folderJpg = @"\folder.jpg";
            string folderTbn = @"\folder.tbn";

            if (isDvdBdFolder)
            {
              thumbJpgFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + jpgExt;
              thumbTbnFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + tbnExt;
              thumbFolderJpgFile = path + @"\" + folderJpg;
              thumbFolderTbnFile = path + @"\" + folderTbn;
            }
            else
            {
              thumbJpgFile = path + @"\" + nfofileName + jpgExt;
              thumbTbnFile = path + @"\" + nfofileName + tbnExt;

              if (isMovieFolder)
              {
                thumbFolderJpgFile = path + @"\" + folderJpg;
                thumbFolderTbnFile = path + @"\" + folderTbn;
              }
            }

            if (nodePoster != null)
            {
              // Local source cover
              if (File.Exists(thumbJpgFile))
              {
                CreateCovers(titleExt, thumbJpgFile, movie);
              }
              else if (File.Exists(thumbTbnFile))
              {
                CreateCovers(titleExt, thumbTbnFile, movie);
              }
              else if (!string.IsNullOrEmpty(thumbFolderJpgFile) && File.Exists(thumbFolderJpgFile))
              {
                CreateCovers(titleExt, thumbFolderJpgFile, movie);
              }
              else if (!string.IsNullOrEmpty(thumbFolderTbnFile) && File.Exists(thumbFolderTbnFile))
              {
                CreateCovers(titleExt, thumbFolderTbnFile, movie);
              }
              else if (!nodePoster.InnerText.StartsWith("http:") && File.Exists(nodePoster.InnerText))
              {
                CreateCovers(titleExt, nodePoster.InnerText, movie);
              }
              else if (!nodePoster.InnerText.StartsWith("http:") && File.Exists(path + @"\" + nodePoster.InnerText))
              {
                CreateCovers(titleExt, path + @"\" + nodePoster.InnerText, movie);
              }
              // web source cover
              else if (nodePoster.InnerText.StartsWith("http:"))
              {
                try
                {
                  string imageUrl = nodePoster.InnerText;
                  if (imageUrl.Length > 0)
                  {
                    string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                    string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                    if (!File.Exists(coverArtImage))
                    {
                      string imageExtension = Path.GetExtension(imageUrl);
                      if (imageExtension == string.Empty)
                      {
                        imageExtension = jpgExt;
                      }
                      string temporaryFilename = "MPTempImage";
                      temporaryFilename += imageExtension;
                      temporaryFilename = Path.Combine(Path.GetTempPath(), temporaryFilename);
                      Util.Utils.FileDelete(temporaryFilename);
                      Util.Utils.DownLoadAndOverwriteCachedImage(imageUrl, temporaryFilename);
                        
                      if (File.Exists(temporaryFilename))
                      {
                        if (Util.Picture.CreateThumbnail(temporaryFilename, largeCoverArtImage, (int)Thumbs.ThumbLargeResolution,
                                                          (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                        {
                          Util.Picture.CreateThumbnail(temporaryFilename, coverArtImage, (int)Thumbs.ThumbResolution,
                                                        (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                        }
                      }

                      Util.Utils.FileDelete(temporaryFilename);
                    }
                  }
                }
                catch (Exception ex)
                {
                  Log.Error("Import nfo - Poster node: {0}", ex.Message);
                }
                movie.ThumbURL = nodePoster.InnerText;
              }
              // MP scrapers cover
              else
              {
                if (movie.ThumbURL == string.Empty && !useInternalNfoScraper)
                {
                  // IMPAwards
                  IMPAwardsSearch impSearch = new IMPAwardsSearch();
                  impSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                  if ((impSearch.Count > 0) && (impSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = impSearch[0];
                  }

                  // If no IMPAwards lets try TMDB 
                  TMDBCoverSearch tmdbSearch = new TMDBCoverSearch();

                  if (impSearch.Count == 0)
                  {
                    tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                    if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty))
                    {
                      movie.ThumbURL = tmdbSearch[0];
                    }
                  }
                  // All fail, last try IMDB
                  if (impSearch.Count == 0 && tmdbSearch.Count == 0)
                  {
                    IMDBSearch imdbSearch = new IMDBSearch();
                    imdbSearch.SearchCovers(movie.IMDBNumber, true);

                    if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty))
                    {
                      movie.ThumbURL = imdbSearch[0];
                    }
                  }
                }

                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (movie.ID >= 0)
                {
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    Util.Utils.FileDelete(largeCoverArt);
                    Util.Utils.FileDelete(coverArt);
                  }
                  
                  // Save cover thumbs
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt);
                  }
                }
              }
            }
            else // Node thumb not exist
            {
              if (File.Exists(thumbJpgFile))
              {
                CreateCovers(titleExt, thumbJpgFile, movie);
              }
              else if (File.Exists(thumbTbnFile))
              {
                CreateCovers(titleExt, thumbTbnFile, movie);
              }
              else if (!string.IsNullOrEmpty(thumbFolderJpgFile) && File.Exists(thumbFolderJpgFile))
              {
                CreateCovers(titleExt, thumbFolderJpgFile, movie);
              }
              else if (!string.IsNullOrEmpty(thumbFolderTbnFile) && File.Exists(thumbFolderTbnFile))
              {
                CreateCovers(titleExt, thumbFolderTbnFile, movie);
              }
              else if (movie.ThumbURL == string.Empty && !useInternalNfoScraper)
              {
                // IMPAwards
                IMPAwardsSearch impSearch = new IMPAwardsSearch();
                impSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                if ((impSearch.Count > 0) && (impSearch[0] != string.Empty))
                {
                  movie.ThumbURL = impSearch[0];
                }

                // If no IMPAwards lets try TMDB 
                TMDBCoverSearch tmdbSearch = new TMDBCoverSearch();

                if (impSearch.Count == 0)
                {
                  tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                  if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = tmdbSearch[0];
                  }
                }
                // All fail, last try IMDB
                if (impSearch.Count == 0 && tmdbSearch.Count == 0)
                {
                  IMDBSearch imdbSearch = new IMDBSearch();
                  imdbSearch.SearchCovers(movie.IMDBNumber, true);

                  if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = imdbSearch[0];
                  }
                }
                
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (movie.ID >= 0)
                {
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    Util.Utils.FileDelete(largeCoverArt);
                    Util.Utils.FileDelete(coverArt);
                  }

                  // Save cover thumbs
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt);
                  }
                }
              }
            }

            #endregion

            #region Fanart

            // Fanart
            XmlNodeList fanartNodeList = nodeMovie.SelectNodes("fanart/thumb");

            int faIndex = 0;
            bool faFound = false;
            string faFile = string.Empty;
            FanArt fa = new FanArt();

            foreach (XmlNode fanartNode in fanartNodeList)
            {
              if (fanartNode != null)
              {
                faFile = path + @"\" + fanartNode.InnerText;
                
                if (File.Exists(faFile))
                {
                  fa.GetLocalFanart(id, "file://" + faFile, faIndex);
                  movie.FanartURL = faFile;
                  faFound = true;
                }
              }
              faIndex ++;

              if (faIndex == 5)
              {
                break;
              }
            }

            if (!faFound)
            {
              List<string> localFanart = new List<string>(); 
              faIndex = 0;
              faFile = path + @"\" + nfofileName + "-fanart.jpg";
              localFanart.Add(faFile);
              faFile = path + @"\" + nfofileName + "-backdrop.jpg";
              localFanart.Add(faFile);
              faFile= path + @"\" + "backdrop.jpg";
              localFanart.Add(faFile);
              faFile = path + @"\" + "fanart.jpg";
              localFanart.Add(faFile);

              foreach (string fanart in localFanart)
              {
                if (File.Exists(fanart))
                {
                  fa.GetLocalFanart(id, "file://" + fanart, faIndex);
                  movie.FanartURL = fanart;
                  faFound = true;
                  break;
                }
              }
              
              if (!faFound && !useInternalNfoScraper)
              {
                fa.GetTmdbFanartByApi(movie.ID, movie.IMDBNumber, string.Empty, false, 1, string.Empty);
              }
            }

            #endregion

            #region Cast

            // Cast parse
            XmlNodeList actorsList = nodeMovie.SelectNodes("actor");
            
            foreach (XmlNode nodeActor in actorsList)
            {
              string name = string.Empty;
              string role = string.Empty;
              string actorImdbId = string.Empty;
              string line = string.Empty;
              XmlNode nodeActorName = nodeActor.SelectSingleNode("name");
              XmlNode nodeActorRole = nodeActor.SelectSingleNode("role");
              XmlNode nodeActorImdbId = nodeActor.SelectSingleNode("imdb");

              XmlNode nodeActorBirthDate = nodeActor.SelectSingleNode("birthdate");
              XmlNode nodeActorBirthPlace = nodeActor.SelectSingleNode("birthplace");
              XmlNode nodeActorDeathDate = nodeActor.SelectSingleNode("deathdate");
              XmlNode nodeActorDeathPlace = nodeActor.SelectSingleNode("deathplace");
              XmlNode nodeActorMiniBio = nodeActor.SelectSingleNode("minibiography");
              XmlNode nodeActorBiography= nodeActor.SelectSingleNode("biography");
              XmlNode nodeActorThumbnail = nodeActor.SelectSingleNode("thumb");

              if (nodeActorName != null && nodeActorName.InnerText != null)
              {
                name = nodeActorName.InnerText;
              }
              if (nodeActorRole != null && nodeActorRole.InnerText != null)
              {
                role = nodeActorRole.InnerText;
              }
              if (nodeActorImdbId != null)
              {
                if (CheckActorImdbId(nodeActorImdbId.InnerText))
                {
                  actorImdbId = nodeActorImdbId.InnerText;
                }
              }
              if (!string.IsNullOrEmpty(name))
              {
                if (!string.IsNullOrEmpty(role))
                {
                  line = String.Format("{0} as {1}\n", name, role);
                }
                else
                {
                  line = String.Format("{0}\n", name);
                }
                cast += line;

                int actId = VideoDatabase.AddActor(actorImdbId, name);
                
                VideoDatabase.AddActorToMovie(id, actId, role);

                if (CheckActorImdbId(actorImdbId))
                {
                  IMDBActor info = new IMDBActor();
                  info.IMDBActorID = actorImdbId;
                  
                  if (nodeActorBirthDate != null)
                  {
                    info.DateOfBirth = nodeActorBirthDate.InnerText;
                  }
                  if (nodeActorBirthPlace != null)
                  {
                    info.PlaceOfBirth = nodeActorBirthPlace.InnerText;
                  }
                  if (nodeActorDeathDate != null)
                  {
                    info.DateOfDeath = nodeActorDeathDate.InnerText;
                  }
                  if (nodeActorDeathPlace != null)
                  {
                    info.PlaceOfDeath = nodeActorDeathPlace.InnerText;
                  }
                  if (nodeActorMiniBio != null)
                  {
                    info.MiniBiography = nodeActorMiniBio.InnerText;
                  }
                  if (nodeActorBiography != null)
                  {
                    info.Biography = nodeActorBiography.InnerText;
                  }
                  
                  if (info.DateOfBirth != string.Empty || 
                      info.PlaceOfBirth != string.Empty||
                      info.DateOfDeath != string.Empty ||
                      info.PlaceOfBirth != string.Empty ||
                      info.MiniBiography != string.Empty ||
                      info.Biography != string.Empty)
                  {
                    SetActorInfo(actId, info);
                  }
                }
              }
            }
            // Cast
            movie.Cast = cast;

            #endregion

            #region UserGroups

            XmlNodeList userGroups = nodeMovie.SelectNodes("set");
            
            foreach (XmlNode nodeUserGroup in userGroups)
            {
              string strUserGroup = string.Empty;
              
              if (nodeUserGroup != null && nodeUserGroup.InnerText != null)
              {
                strUserGroup = nodeUserGroup.InnerText;

                if (!string.IsNullOrEmpty(strUserGroup))
                {
                  int iUserGroup = AddUserGroup(strUserGroup);
                  AddUserGroupToMovie(movie.ID, iUserGroup);
                }
              }
            }

            #endregion

            VideoDatabase.SetMovieInfoById(id, ref movie, true);
          }
        }
      }
      catch (Exception ex)
      {
        Log.Error("videodatabase exception error importing nfo file {0}:{1} ", nfoFile, ex.Message);
      }
    }
コード例 #31
0
    protected override void OnPageDestroy(int newWindowId)
    {
      if ((_scanThread != null) && (_scanThread.IsAlive))
      {
        _scanThread.Abort();
        _scanThread = null;
      }
      
      // Refresh actor info
      if (_currentActor != null)
      {
        _currentActor = VideoDatabase.GetActorInfo(_currentActor.ID);
        SaveState();
        //Clean properties
        _currentActor.ResetProperties();
      }

      ReleaseResources();
      base.OnPageDestroy(newWindowId);
    }
コード例 #32
0
ファイル: IMDB.cs プロジェクト: arangas/MediaPortal-1
    // Filmograpy and bio
    public bool GetActorDetails(IMDBUrl url, out IMDBActor actor)
    {
      actor = new IMDBActor();

      try
      {
        if (InternalActorsScriptGrabber.InternalActorsGrabber.GetActorDetails(url, out actor))
        {
          // Add filmography
          if (actor.Count > 0)
          {
            actor.SortActorMoviesByYear();
          }

          return true;
        }
      }
      catch (Exception ex)
      {
        Log.Error("IMDB GetActorDetails Error: {0}", ex.Message);
      }
      return false;
    }
コード例 #33
0
    public void ImportNfo(string nfoFile)
    {
      IMDBMovie movie = new IMDBMovie();
      try
      {
        XmlDocument doc = new XmlDocument();
        doc.Load(nfoFile);
        
        if (doc.DocumentElement != null)
        {
          int id = 0;

          XmlNodeList movieList = doc.DocumentElement.SelectNodes("/movie");
          
          if (movieList == null)
          {
            return;
          }

          foreach (XmlNode nodeMovie in movieList)
          {
            string genre = string.Empty;
            string cast = string.Empty;
            string path = string.Empty;
            string fileName = string.Empty;
            
            #region nodes

            XmlNode nodeTitle = nodeMovie.SelectSingleNode("title");
            XmlNode nodeRating = nodeMovie.SelectSingleNode("rating");
            XmlNode nodeYear = nodeMovie.SelectSingleNode("year");
            XmlNode nodeDuration = nodeMovie.SelectSingleNode("runtime");
            XmlNode nodePlotShort = nodeMovie.SelectSingleNode("outline");
            XmlNode nodePlot = nodeMovie.SelectSingleNode("plot");
            XmlNode nodeTagline = nodeMovie.SelectSingleNode("tagline");
            XmlNode nodeDirector = nodeMovie.SelectSingleNode("director");
            XmlNode nodeDirectorImdb = nodeMovie.SelectSingleNode("directorimdb");
            XmlNode nodeImdbNumber = nodeMovie.SelectSingleNode("imdb");
            XmlNode nodeMpaa = nodeMovie.SelectSingleNode("mpaa");
            XmlNode nodeTop250 = nodeMovie.SelectSingleNode("top250");
            XmlNode nodeVotes = nodeMovie.SelectSingleNode("votes");
            XmlNode nodeStudio = nodeMovie.SelectSingleNode("studio");
            XmlNode nodePlayCount = nodeMovie.SelectSingleNode("playcount");
            XmlNode nodeWatched = nodeMovie.SelectSingleNode("watched");
            XmlNode nodeFanart = nodeMovie.SelectSingleNode("fanart");
            XmlNode nodePoster = nodeMovie.SelectSingleNode("thumb");
            XmlNode nodeLanguage = nodeMovie.SelectSingleNode("language");
            XmlNode nodeCountry = nodeMovie.SelectSingleNode("country");
            XmlNode nodeReview = nodeMovie.SelectSingleNode("review");
            XmlNode nodeCredits = nodeMovie.SelectSingleNode("credits");
            
            
            #endregion

            #region Genre

            XmlNodeList genres = nodeMovie.SelectNodes("genres/genre");
            
            foreach (XmlNode nodeGenre in genres)
            {
              if (nodeGenre.InnerText != null)
              {
                if (genre.Length > 0)
                {
                  genre += " / ";
                }
                genre += nodeGenre.InnerText;
              }
            }

            if (string.IsNullOrEmpty(genre))
            {
              XmlNode nodeGenre = nodeMovie.SelectSingleNode("genre");
              
              if (nodeGenre != null)
              {
                genre = nodeGenre.InnerText;
              }
            }

            // Genre
            movie.Genre = genre;
            
            #endregion

            #region Credits (Writers)

            // Writers
            if (nodeCredits != null)
            {
              movie.WritingCredits = nodeCredits.InnerText;
            }
            #endregion

            #region Moviefiles
            
            // Get path from *.nfo file)
            Util.Utils.Split(nfoFile, out path, out fileName);
            // Movie filename to search from gathered files from nfo path
            fileName = Util.Utils.GetFilename(fileName, true);
            // Get all video files from nfo path
            ArrayList files = new ArrayList();
            GetVideoFiles(path, ref files);
            bool isDvdBdFolder = false;

            foreach (String file in files)
            {
              if ((file.ToUpperInvariant().Contains("VIDEO_TS.IFO") ||
                  file.ToUpperInvariant().Contains("INDEX.BDMV")) && files.Count == 1)
              {
                id = VideoDatabase.AddMovie(file, true);
                movie.ID = id;
                isDvdBdFolder = true;
              }
              else
              {
                string tmpFile = string.Empty;
                string tmpPath = string.Empty;
                // Read filename
                Util.Utils.Split(file, out tmpPath, out tmpFile);
                // Remove extension
                tmpFile = Util.Utils.GetFilename(tmpFile, true);
                // Remove stack endings (CD1...)
                Util.Utils.RemoveStackEndings(ref tmpFile);
                // Check and add to vdb and get movieId
                if (tmpFile.Equals(fileName, StringComparison.InvariantCultureIgnoreCase))
                {
                  id = VideoDatabase.AddMovie(file, true);
                  movie.ID = id;
                }
              }
            }

            #endregion

            #region DateAdded

            movie.DateAdded = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            
            #endregion

            #region Title

            // Title
            if (nodeTitle != null)
            {
              movie.Title = nodeTitle.InnerText;
            }

            #endregion

            #region Language

            // Title
            if (nodeLanguage != null)
            {
              movie.Language = nodeLanguage.InnerText;
            }

            #endregion

            #region Country

            // Title
            if (nodeCountry != null)
            {
              movie.Country = nodeCountry.InnerText;
            }

            #endregion

            #region IMDB number

            // IMDB number
            if (nodeImdbNumber != null)
            {
              if (CheckMovieImdbId(nodeImdbNumber.InnerText))
              {
                movie.IMDBNumber = nodeImdbNumber.InnerText;
              }
            }

            #endregion

            #region CD/DVD labels

            // CD label
            movie.CDLabel = string.Empty;

            // DVD label
            movie.DVDLabel = string.Empty;

            #endregion

            #region Director

            // Director
            string dirImdb = string.Empty;
            if (nodeDirectorImdb != null)
            {
              dirImdb = nodeDirector.InnerText;
              
              if (!CheckActorImdbId(dirImdb))
              {
                dirImdb = string.Empty;
              }
            }
            if (nodeDirector != null)
            {
              movie.Director = nodeDirector.InnerText;
              movie.DirectorID = VideoDatabase.AddActor(dirImdb, movie.Director);
            }
            #endregion

            #region Studio

            // Studio
            if (nodeStudio != null)
            {
              movie.Studios = nodeStudio.InnerText;
            }

            #endregion

            #region MPAA

            // MPAA
            if (nodeMpaa != null)
            {
              movie.MPARating = nodeMpaa.InnerText;
            }
            else
            {
              movie.MPARating = "NR";
            }
            
            #endregion
            
            #region Plot/Short plot

            // Plot
            if (nodePlot != null)
            {
              movie.Plot = nodePlot.InnerText;
            }
            else
            {
              movie.Plot = string.Empty;
            }
            // Short plot
            if (nodePlotShort != null)
            {
              movie.PlotOutline = nodePlotShort.InnerText;
            }
            else
            {
              movie.PlotOutline = string.Empty;
            }

            #endregion

            #region Review

            // Title
            if (nodeReview != null)
            {
              movie.UserReview = nodeReview.InnerText;
            }

            #endregion

            #region Rating (n.n/10)

            // Rating
            if (nodeRating != null)
            {
              double rating = 0;
              if (Double.TryParse(nodeRating.InnerText.Replace(".", ","), out rating))
              {
                movie.Rating = (float) rating;
                
                if (movie.Rating > 10.0f)
                {
                  movie.Rating /= 10.0f;
                }
              }
            }

            #endregion

            #region Duration

            // Duration
            if (nodeDuration != null)
            {
              int runtime = 0;
              if (Int32.TryParse(nodeDuration.InnerText, out runtime))
              {
                movie.RunTime = runtime;
              }
              else
              {
                string regex = "(?<h>[0-9]*)h.(?<m>[0-9]*)";
                MatchCollection mc = Regex.Matches(nodeDuration.InnerText, regex, RegexOptions.Singleline);
                if (mc.Count > 0)
                {
                  foreach (Match m in mc)
                  {
                    int hours = 0;
                    Int32.TryParse(m.Groups["h"].Value, out hours);
                    int minutes = 0;
                    Int32.TryParse(m.Groups["m"].Value, out minutes);
                    hours = hours*60;
                    minutes = hours + minutes;
                    movie.RunTime = minutes;
                  }
                }
              }
            }
            else
            {
              movie.RunTime = 0;
            }

            #endregion
            
            #region Tagline

            // Tagline
            if (nodeTagline != null)
            {
              movie.TagLine = nodeTagline.InnerText;
            }

            #endregion

            #region TOP250

            // Top250
            if (nodeTop250 != null)
            {
              int top250 = 0;
              Int32.TryParse(nodeTop250.InnerText, out top250);
              movie.Top250 = top250;
            }
            else
            {
              movie.Top250 = 0;
            }


            #endregion

            #region votes

            // Votes
            if (nodeVotes != null)
            {
              movie.Votes = nodeVotes.InnerText;
            }

            #endregion

            #region Watched/watched count

            // Watched
            int percent = 0;
            int watchedCount = 0;
            GetMovieWatchedStatus(movie.ID, out percent, out watchedCount);

            if (watchedCount < 1)
            {
              if (nodeWatched != null)
              {
                if (nodeWatched.InnerText == "true" || nodeWatched.InnerText == "1")
                {
                  movie.Watched = 1;
                  VideoDatabase.SetMovieWatchedStatus(movie.ID, true, 100);
                }
                else
                {
                  movie.Watched = 0;
                  VideoDatabase.SetMovieWatchedStatus(movie.ID, false, 0);
                }
              }
              // Watched count
              if (nodePlayCount != null)
              {
                watchedCount = 0;
                Int32.TryParse(nodePlayCount.InnerText, out watchedCount);
                SetMovieWatchedCount(movie.ID, watchedCount);
              }
            }
            else
            {
              movie.Watched = 1;
            }

            #endregion

            #region Year

            // Year
            if (nodeYear != null)
            {
              int year = 0;
              Int32.TryParse(nodeYear.InnerText, out year);
              movie.Year = year;
            }

            #endregion

            #region poster

            // Poster
            if (nodePoster != null)
            {
              string thumbJpgFile = string.Empty;
              string thumbTbnFile = string.Empty;
              
              if (nodePoster.InnerText == string.Empty)
              {
                if (isDvdBdFolder)
                {
                  thumbJpgFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + ".jpg";
                  thumbTbnFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + ".tbn";
                }
                else
                {
                  thumbJpgFile = path + @"\" + fileName + ".jpg";
                  thumbTbnFile = path + @"\" + fileName + ".tbn";
                }
                
              }
              else
              {
                thumbJpgFile = path + @"\" + nodePoster.InnerText;
                thumbTbnFile = path + @"\" + nodePoster.InnerText;
              }
              
              string titleExt = movie.Title + "{" + id + "}";
              
              if (File.Exists(thumbJpgFile))
              {
                movie.ThumbURL = thumbJpgFile;
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (Util.Picture.CreateThumbnail(thumbJpgFile, largeCoverArt, (int)Thumbs.ThumbLargeResolution,
                                                 (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                {
                  Util.Picture.CreateThumbnail(thumbJpgFile, coverArt, (int)Thumbs.ThumbResolution,
                                                (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                }
              }
              else if (File.Exists(thumbTbnFile))
              {
                movie.ThumbURL = thumbTbnFile;
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                
                if (Util.Picture.CreateThumbnail(thumbTbnFile, largeCoverArt, (int)Thumbs.ThumbLargeResolution,
                                                 (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                {
                  Util.Picture.CreateThumbnail(thumbTbnFile, coverArt, (int)Thumbs.ThumbResolution,
                                                (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                }
              }
              else if (nodePoster.InnerText.StartsWith("http:"))
              {
                try
                {
                  string imageUrl = nodePoster.InnerText;
                  if (imageUrl.Length > 0)
                  {
                    string largeCoverArtImage = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                    string coverArtImage = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);
                    if (!File.Exists(coverArtImage))
                    {
                      string imageExtension = Path.GetExtension(imageUrl);
                      if (imageExtension == string.Empty)
                      {
                        imageExtension = ".jpg";
                      }
                      string temporaryFilename = "temp";
                      temporaryFilename += imageExtension;
                      Util.Utils.FileDelete(temporaryFilename);

                      Util.Utils.DownLoadAndCacheImage(imageUrl, temporaryFilename);
                        
                      if (File.Exists(temporaryFilename))
                      {
                        if (Util.Picture.CreateThumbnail(temporaryFilename, largeCoverArtImage, (int)Thumbs.ThumbLargeResolution,
                                                          (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                        {
                          Util.Picture.CreateThumbnail(temporaryFilename, coverArtImage, (int)Thumbs.ThumbResolution,
                                                        (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                        }
                      }

                      Util.Utils.FileDelete(temporaryFilename);
                    }
                  }
                }
                catch (Exception) { }
                movie.ThumbURL = nodePoster.InnerText;
              }
              else
              {
                if (movie.ThumbURL == string.Empty)
                {
                  // IMPAwards
                  IMPAwardsSearch impSearch = new IMPAwardsSearch();
                  impSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                  if ((impSearch.Count > 0) && (impSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = impSearch[0];
                  }

                  // If no IMPAwards lets try TMDB 
                  TMDBCoverSearch tmdbSearch = new TMDBCoverSearch();

                  if (impSearch.Count == 0)
                  {
                    tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                    if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty))
                    {
                      movie.ThumbURL = tmdbSearch[0];
                    }
                  }
                  // All fail, last try IMDB
                  if (impSearch.Count == 0 && tmdbSearch.Count == 0)
                  {
                    IMDBSearch imdbSearch = new IMDBSearch();
                    imdbSearch.SearchCovers(movie.IMDBNumber, true);

                    if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty))
                    {
                      movie.ThumbURL = imdbSearch[0];
                    }
                  }
                }

                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (movie.ID >= 0)
                {
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    Util.Utils.FileDelete(largeCoverArt);
                    Util.Utils.FileDelete(coverArt);
                  }
                  
                  // Save cover thumbs
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt);
                  }
                }
              }
            }
            else
            {
              string thumbJpgFile = string.Empty;
              string thumbTbnFile = string.Empty;

              if (isDvdBdFolder)
              {
                thumbJpgFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + ".jpg";
                thumbTbnFile = path + @"\" + Path.GetFileNameWithoutExtension(path) + ".tbn";
              }
              else
              {
                thumbJpgFile = path + @"\" + fileName + ".jpg";
                thumbTbnFile = path + @"\" + fileName + ".tbn";
              }
              
              string titleExt = movie.Title + "{" + id + "}";

              if (File.Exists(thumbJpgFile))
              {
                movie.ThumbURL = thumbJpgFile;
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (Util.Picture.CreateThumbnail(thumbJpgFile, largeCoverArt, (int)Thumbs.ThumbLargeResolution,
                                                 (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                {
                  Util.Picture.CreateThumbnail(thumbJpgFile, coverArt, (int)Thumbs.ThumbResolution,
                                                (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                }
              }
              else if (File.Exists(thumbTbnFile))
              {
                movie.ThumbURL = thumbTbnFile;
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (Util.Picture.CreateThumbnail(thumbTbnFile, largeCoverArt, (int)Thumbs.ThumbLargeResolution,
                                                 (int)Thumbs.ThumbLargeResolution, 0, Thumbs.SpeedThumbsSmall))
                {
                  Util.Picture.CreateThumbnail(thumbTbnFile, coverArt, (int)Thumbs.ThumbResolution,
                                                (int)Thumbs.ThumbResolution, 0, Thumbs.SpeedThumbsLarge);
                }
              }
              else if (movie.ThumbURL == string.Empty)
              {
                // IMPAwards
                IMPAwardsSearch impSearch = new IMPAwardsSearch();
                impSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                if ((impSearch.Count > 0) && (impSearch[0] != string.Empty))
                {
                  movie.ThumbURL = impSearch[0];
                }

                // If no IMPAwards lets try TMDB 
                TMDBCoverSearch tmdbSearch = new TMDBCoverSearch();

                if (impSearch.Count == 0)
                {
                  tmdbSearch.SearchCovers(movie.Title, movie.IMDBNumber);

                  if ((tmdbSearch.Count > 0) && (tmdbSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = tmdbSearch[0];
                  }
                }
                // All fail, last try IMDB
                if (impSearch.Count == 0 && tmdbSearch.Count == 0)
                {
                  IMDBSearch imdbSearch = new IMDBSearch();
                  imdbSearch.SearchCovers(movie.IMDBNumber, true);

                  if ((imdbSearch.Count > 0) && (imdbSearch[0] != string.Empty))
                  {
                    movie.ThumbURL = imdbSearch[0];
                  }
                }
                
                string largeCoverArt = Util.Utils.GetLargeCoverArtName(Thumbs.MovieTitle, titleExt);
                string coverArt = Util.Utils.GetCoverArtName(Thumbs.MovieTitle, titleExt);

                if (movie.ID >= 0)
                {
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    Util.Utils.FileDelete(largeCoverArt);
                    Util.Utils.FileDelete(coverArt);
                  }

                  // Save cover thumbs
                  if (!string.IsNullOrEmpty(movie.ThumbURL))
                  {
                    IMDBFetcher.DownloadCoverArt(Thumbs.MovieTitle, movie.ThumbURL, titleExt);
                  }
                }
              }
            }

            #endregion

            #region Fanart

            // Fanart
            XmlNodeList fanartNodeList = nodeMovie.SelectNodes("fanart/thumb");

            int faIndex = 0;
            bool faFound = false;
            string faFile = string.Empty;
            FanArt fa = new FanArt();

            foreach (XmlNode fanartNode in fanartNodeList)
            {
              if (fanartNode != null)
              {
                faFile = path + @"\" + fanartNode.InnerText;
                
                if (File.Exists(faFile))
                {
                  fa.GetLocalFanart(id, "file://" + faFile, faIndex);
                  movie.FanartURL = faFile;
                  faFound = true;
                }
              }
              faIndex ++;
            }

            if (!faFound)
            {
              faFile = path + @"\" + Path.GetFileNameWithoutExtension(fileName) + "-fanart.jpg";
              
              if (File.Exists(faFile))
              {
                fa.GetLocalFanart(id, "file://" + faFile, faIndex);
                movie.FanartURL = faFile;
              }
              else
              {
                fa.GetTmdbFanartByApi(movie.ID, movie.IMDBNumber, string.Empty, false, 1, string.Empty);
              }
            }

            #endregion

            #region Cast

            // Cast parse
            XmlNodeList actorsList = nodeMovie.SelectNodes("actor");
            foreach (XmlNode nodeActor in actorsList)
            {
              string name = string.Empty;
              string role = string.Empty;
              string actorImdbId = string.Empty;
              string line = string.Empty;
              XmlNode nodeActorName = nodeActor.SelectSingleNode("name");
              XmlNode nodeActorRole = nodeActor.SelectSingleNode("role");
              XmlNode nodeActorImdbId = nodeActor.SelectSingleNode("imdb");

              XmlNode nodeActorBirthDate = nodeActor.SelectSingleNode("birthdate");
              XmlNode nodeActorBirthPlace = nodeActor.SelectSingleNode("birthplace");
              XmlNode nodeActorDeathDate = nodeActor.SelectSingleNode("deathdate");
              XmlNode nodeActorDeathPlace = nodeActor.SelectSingleNode("deathplace");
              XmlNode nodeActorMiniBio = nodeActor.SelectSingleNode("minibiography");
              XmlNode nodeActorBiography= nodeActor.SelectSingleNode("biography");
              XmlNode nodeActorThumbnail = nodeActor.SelectSingleNode("thumb");

              if (nodeActorName != null && nodeActorName.InnerText != null)
              {
                name = nodeActorName.InnerText;
              }
              if (nodeActorRole != null && nodeActorRole.InnerText != null)
              {
                role = nodeActorRole.InnerText;
              }
              if (nodeActorImdbId != null)
              {
                if (CheckActorImdbId(nodeActorImdbId.InnerText))
                {
                  actorImdbId = nodeActorImdbId.InnerText;
                }
              }
              if (!string.IsNullOrEmpty(name))
              {
                if (!string.IsNullOrEmpty(role))
                {
                  line = String.Format("{0} as {1}\n", name, role);
                }
                else
                {
                  line = String.Format("{0}\n", name);
                }
                cast += line;

                int actId = VideoDatabase.AddActor(actorImdbId, name);
                
                VideoDatabase.AddActorToMovie(id, actId, role);

                if (CheckActorImdbId(actorImdbId))
                {
                  IMDBActor info = new IMDBActor();
                  info.IMDBActorID = actorImdbId;
                  
                  if (nodeActorBirthDate != null)
                  {
                    info.DateOfBirth = nodeActorBirthDate.InnerText;
                  }
                  if (nodeActorBirthPlace != null)
                  {
                    info.PlaceOfBirth = nodeActorBirthPlace.InnerText;
                  }
                  if (nodeActorDeathDate != null)
                  {
                    info.DateOfDeath = nodeActorDeathDate.InnerText;
                  }
                  if (nodeActorDeathPlace != null)
                  {
                    info.PlaceOfDeath = nodeActorDeathPlace.InnerText;
                  }
                  if (nodeActorMiniBio != null)
                  {
                    info.MiniBiography = nodeActorMiniBio.InnerText;
                  }
                  if (nodeActorBiography != null)
                  {
                    info.Biography = nodeActorBiography.InnerText;
                  }
                  
                  if (info.DateOfBirth != string.Empty || 
                      info.PlaceOfBirth != string.Empty||
                      info.DateOfDeath != string.Empty ||
                      info.PlaceOfBirth != string.Empty ||
                      info.MiniBiography != string.Empty ||
                      info.Biography != string.Empty)
                  {
                    SetActorInfo(actId, info);
                  }
                }
              }
            }
            // Cast
            movie.Cast = cast;

            #endregion

            VideoDatabase.SetMovieInfoById(id, ref movie, true);
          }
        }
      }
      catch (Exception ex)
      {
        Log.Error("Error importing nfo file {0}:{1} ", nfoFile, ex);
      }
    }
コード例 #34
0
ファイル: IMDB.cs プロジェクト: sekotin/MediaPortal-1
    // Filmograpy and bio
    public bool GetActorDetails(IMDBUrl url, out IMDBActor actor)
    {
      actor = new IMDBActor();

      string[] vdbParserStr = VdbParserStringActorDetails();

      if (vdbParserStr == null || vdbParserStr.Length != 46)
      {
        return false;
      }

      try
      {
        string absoluteUri;
        string strBody = GetPage(url.URL, "utf-8", out absoluteUri);
        
        if (strBody == null)
        {
          return false;
        }
        
        if (strBody.Length == 0)
        {
          return false;
        }
        
        #region Actor imdb id

        // IMDBActorID
        try
        {
          int pos = url.URL.LastIndexOf("nm");
          string id = url.URL.Substring(pos, 9).Replace("/", string.Empty);
          actor.IMDBActorID = id;
        }
        catch (Exception) { }

        #endregion

        HTMLParser parser = new HTMLParser(strBody);
        string strThumb = string.Empty;
        string value = string.Empty;
        string value2 = string.Empty;
        
        #region Actor name

        // Actor name
        if ((parser.skipToEndOf(vdbParserStr[0])) &&        // <title>
            (parser.extractTo(vdbParserStr[1], ref value))) // - IMDb</title>
        {
          value = new HTMLUtil().ConvertHTMLToAnsi(value);
          value = Util.Utils.RemoveParenthesis(value).Trim();
          actor.Name = HttpUtility.HtmlDecode(value.Trim());
        }
        
        if (actor.Name == string.Empty)
        {
          actor.Name = url.Title;
        }

        #endregion

        // Photo
        string parserTxt = parser.Content;
        string photoBlock = string.Empty;

        #region Actor photo

        if (parser.skipToStartOf(vdbParserStr[2]) &&              // <td id="img_primary"
            (parser.extractTo(vdbParserStr[3], ref photoBlock)))  // </td>
        {
          parser.Content = photoBlock;
        
          if ((parser.skipToEndOf(vdbParserStr[4])) &&            // <img src="
              (parser.extractTo(vdbParserStr[5], ref strThumb)))  // "
          {
            actor.ThumbnailUrl = strThumb;
          }
          parser.Content = parserTxt;
        }
        
        #endregion

        #region Actor birth date

        // Birth date
        if ((parser.skipToEndOf(vdbParserStr[6])) &&          // >Born:</h4>
            (parser.skipToEndOf(vdbParserStr[7])) &&          // birth_monthday=
            (parser.skipToEndOf(vdbParserStr[8])) &&          // >
            (parser.extractTo(vdbParserStr[9], ref value)) && // <
            (parser.skipToEndOf(vdbParserStr[10])) &&         // year=
            (parser.extractTo(vdbParserStr[11], ref value2))) // "

        {
          actor.DateOfBirth = value + " " + value2;
        }

        #endregion

        #region Actor death date

        // Death date
        if ((parser.skipToEndOf(vdbParserStr[12])) &&           // >Died:</h4>
            (parser.skipToEndOf(vdbParserStr[13])) &&           // death_monthday="
            (parser.skipToEndOf(vdbParserStr[14])) &&           // >
            (parser.extractTo(vdbParserStr[15], ref value)) &&  // <
            (parser.skipToEndOf(vdbParserStr[16])) &&           // death_date="
            (parser.extractTo(vdbParserStr[17], ref value2)))   // "
        {
          actor.DateOfDeath = value + " " + value2;
        }

        #endregion

        parser.resetPosition();

        #region Actor birth place

        // Birth place
        if ((parser.skipToEndOf(vdbParserStr[18])) &&         // birth_place=
            (parser.skipToEndOf(vdbParserStr[19])) &&         // >
            (parser.extractTo(vdbParserStr[20], ref value)))  // <
        {
          actor.PlaceOfBirth = HttpUtility.HtmlDecode(value);
        }

        #endregion

        #region Actor death place

        // Death place
        if ((parser.skipToEndOf(vdbParserStr[21])) &&         // death_place=
            (parser.skipToEndOf(vdbParserStr[22])) &&         // >
            (parser.extractTo(vdbParserStr[23], ref value)))  // <
        {
          actor.PlaceOfDeath = HttpUtility.HtmlDecode(value);
        }

        #endregion

        //Mini Biography
        parser.resetPosition();

        #region Actor biography

        if ((parser.skipToEndOf(vdbParserStr[24])) &&         // <td id="overview-top">
            (parser.skipToEndOf(vdbParserStr[25])) &&         // <p>
            (parser.extractTo(vdbParserStr[26], ref value)))  // See full bio</a>
        {
          value = new HTMLUtil().ConvertHTMLToAnsi(value);
          actor.MiniBiography = Util.Utils.stripHTMLtags(value);
          actor.MiniBiography = actor.MiniBiography.Replace(vdbParserStr[45], string.Empty).Trim(); // See full bio »
          actor.MiniBiography = HttpUtility.HtmlDecode(actor.MiniBiography); // Remove HTML entities like &#189;
          
          if (actor.MiniBiography != string.Empty)
          {
            // get complete biography
            string bioURL = absoluteUri;
            
            if (!bioURL.EndsWith(vdbParserStr[27])) // /
            {
              bioURL += vdbParserStr[28];           // /bio
            }
            else
            {
              bioURL += vdbParserStr[29];           // bio
            }

            string strBioBody = GetPage(bioURL, "utf-8", out absoluteUri);
            
            if (!string.IsNullOrEmpty(strBioBody))
            {
              HTMLParser parser1 = new HTMLParser(strBioBody);

              if (parser1.skipToEndOf(vdbParserStr[30]) &&        // <h5>Mini Biography</h5>
                  parser1.skipToEndOf(vdbParserStr[31]) &&        // <div class="wikipedia_bio">
                  parser1.extractTo(vdbParserStr[32], ref value)) // </div>
              {
                value = new HTMLUtil().ConvertHTMLToAnsi(value);
                value = Regex.Replace(value, @"</h5>\s<h5>", "\n\r");
                value = Regex.Replace(value, @"<h5>", "\n\r\n\r");
                value = Regex.Replace(value, @"</h5>", ":\n\r");
                actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                actor.Biography = HttpUtility.HtmlDecode(actor.Biography);
              }
              else
              {
                parser1.resetPosition();
                
                if (parser1.skipToEndOf(vdbParserStr[33]) &&      // <h5>Mini Biography</h5>
                  parser1.extractTo(vdbParserStr[34], ref value)) // </p>
                {
                  value = new HTMLUtil().ConvertHTMLToAnsi(value);
                  actor.Biography = Util.Utils.stripHTMLtags(value).Trim();
                  actor.Biography = HttpUtility.HtmlDecode(actor.Biography);
                }
              }
            }
          }
        }

        #endregion

        // Person is movie director or an actor/actress
        bool isActorPass = false;
        bool isDirectorPass = false;
        bool isWriterPass = false;
        
        parser.resetPosition();

        HTMLParser dirParser = new HTMLParser(); // HTML body for Director
        HTMLParser wriParser = new HTMLParser(); // HTML body for Writers

        #region Check person role in movie (actor, director or writer)

        if ((parser.skipToEndOf(vdbParserStr[35])) && // name="Director">Director</a>
            (parser.skipToEndOf(vdbParserStr[36])))   // </div>
        {
          isDirectorPass = true;
          dirParser.Content = parser.Content;
        }
        
        parser.resetPosition();

        if ((parser.skipToEndOf(vdbParserStr[37])) && // name="Writer">Writer</a>
            (parser.skipToEndOf(vdbParserStr[38])))   // </div>
        {
          isWriterPass = true;
          wriParser.Content = parser.Content;
        }

        parser.resetPosition();

        if (parser.skipToEndOf(vdbParserStr[39]) || // name="Actress">Actress</a>
          parser.skipToEndOf(vdbParserStr[40]))     // name="Actor">Actor</a>
        {
          isActorPass = true;
        }

        #endregion

        #region Get movies for every role

        // Get filmography Actor
        if (isActorPass)
        {
          GetActorMovies(actor, parser, false, false);
        }
        
        // Get filmography for writers
        if (isWriterPass)
        {
          parser = wriParser;
          parser.resetPosition();

          if ((parser.skipToEndOf(vdbParserStr[41])) && // name="Writer">Writer</a>
            (parser.skipToEndOf(vdbParserStr[42])))     // </div>
          {
            GetActorMovies(actor, parser, false, true);
          }
        }

        // Get filmography Director
        if (isDirectorPass)
        {
          parser = dirParser;
          parser.resetPosition();
          
          if (parser.skipToEndOf(vdbParserStr[43]) && // name="Director">Director</a>
              parser.skipToEndOf(vdbParserStr[44]))   // </div>
          {
            GetActorMovies(actor, parser, true, false);
          }
        }

        #endregion

        // Add filmography
        if (actor.Count > 0)
        {
          actor.SortActorMoviesByYear();
        }

        return true;
      }
      catch (Exception ex)
      {
        Log.Error("IMDB.GetActorDetails({0} exception:{1} {2} {3}", url.URL, ex.Message, ex.Source, ex.StackTrace);
      }
      return false;
    }
コード例 #35
0
ファイル: GUIVideoTitle.cs プロジェクト: djblu/MediaPortal-1
 private void OnVideoArtistInfo(IMDBActor actor)
 {
   GUIVideoArtistInfo infoDlg =
     (GUIVideoArtistInfo)GUIWindowManager.GetWindow((int)Window.WINDOW_VIDEO_ARTIST_INFO);
   if (infoDlg == null)
   {
     return;
   }
   if (actor == null)
   {
     return;
   }
   infoDlg.Actor = actor;
   infoDlg.DoModal(GetID);
 }