[Approved] How to Video database section and My Movies get to life (3 Viewers)

Deda

Lead Dev MP1 Videos
  • Premium Supporter
  • March 18, 2009
    2,423
    2,385
    Zagreb
    Home Country
    Croatia Croatia
    Re: AW: How to Video database section and My Movies get to life

    Hi Deda,

    will using

    private void OnVideoArtistInfo(IMDBActor actor)

    With actor as a string only be supported? I try getting the actor dialog with just an actor name.
    Or do I have to first get ID from database?

    Thanks,

    Guzzi

    Edit:

    Is there a way to get actor infos by name - following call only supports actorID, right?

    MediaPortal.Video.Database.IMDBActor actor = MediaPortal.Video.Database.VideoDatabase.GetActorInfo("actorID");

    Yes, there is no direct access by name as search string, I will create one from which you can then get name or names (if there is more than one with equal name) and their corresponding dbID. After select one, then it's easy to get all infos because you will have actordbID.
    I need to go to some kiddie birthday party but later I will update patched files with that (I think only Database.dll will be changed).
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,159
    750
    AW: Re: AW: How to Video database section and My Movies get to life

    Hi Deda,

    will using

    private void OnVideoArtistInfo(IMDBActor actor)

    With actor as a string only be supported? I try getting the actor dialog with just an actor name.
    Or do I have to first get ID from database?

    Thanks,

    Guzzi

    Edit:

    Is there a way to get actor infos by name - following call only supports actorID, right?

    MediaPortal.Video.Database.IMDBActor actor = MediaPortal.Video.Database.VideoDatabase.GetActorInfo("actorID");

    Yes, there is no direct access by name as search string, I will create one from which you can then get name or names (if there is more than one with equal name) and their corresponding dbID. After select one, then it's easy to get all infos because you will have actordbID.
    I need to go to some kiddie birthday party but later I will update patched files with that (I think only Database.dll will be changed).

    Thanks a lot - so I will try later again using that function - for the moment I use a hardcoded actorID to play with skinfile and other parts of the code - I want to load the actormovies in a listcontrol to make it more userconvenient, so copied the existing class and trying some modification ... btw., I just came back from some kiddie bicycle tour ;-)
     

    Deda

    Lead Dev MP1 Videos
  • Premium Supporter
  • March 18, 2009
    2,423
    2,385
    Zagreb
    Home Country
    Croatia Croatia
    OK, try this Database.dll in attachment (just replace that from patched files). Now you have method GetActorByName(string strActorName, ArrayList actors) which will return one or more result in array. SQL query use LIKE'%name%' expression (case insensitive).
    Each string in array list contains id and name separated by char "|" which can easily be extracted and used.

    Quick example
    Code:
    private void Example (string searchName)
        {
          ArrayList actorList = new ArrayList();
          // Search with searchName parameter which contain wanted actor name, result(s) is in array
          // which conatin id and name separated with char "|"
          VideoDatabase.GetActorByName(searchName, actorList);
          // Check result
          if (actorList.Count == 0)
            return;
          
          int actorID;
          string actor = "";
          // Define splitter for string
          char[] splitter = { '|' };
          // Iterate through list
          foreach (string act in actorList)
          {
            // Split id from actor name (two substrings, [0] is id and [1] is name)
            string[] strActor = act.Split(splitter);
            // From here we have all what we want, now we can populate datatable, gridview, listview....)
            // actorID originally is integer in the databse (it can be string in results but if we want get details from
            // IMDBActor  GetActorInfo(int idActor) we need integer)
            actorID = Convert.ToInt32(strActor[0]);
            actor = strActor[1];
          }
        }

    Try it and if you need something extra or some changes so I can do it before include this in patch.
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,159
    750
    AW: How to Video database section and My Movies get to life

    Thanks a lot. May I post another question:
    If I want to display the actor's movies (from table ActorinfoMovies by Actorid) and their local availability - is there a class to use or do I need to check the movies against the movies-table?
    Result should be a list of the movies belonging to an actor (from actorinfomovies) with a status if that movie is locally available (thus in movie)


    Edit:

    Hi Deda,

    if I didn't make a mistake, the GetActorByName Class is not included in the above attached database.dll - there is GetActors, but this seems not to work. Any hints?
     

    Deda

    Lead Dev MP1 Videos
  • Premium Supporter
  • March 18, 2009
    2,423
    2,385
    Zagreb
    Home Country
    Croatia Croatia
    Re: AW: How to Video database section and My Movies get to life

    Hi Deda,

    if I didn't make a mistake, the GetActorByName Class is not included in the above attached database.dll - there is GetActors, but this seems not to work. Any hints?

    It should be there, try to add namespace as:
    using MediaPortal.Video.Database;

    or using it directly as
    MediaPortal.Video.Database.VideoDatabase.GetActorByName(searchName, actorList);
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,159
    750
    AW: How to Video database section and My Movies get to life

    Hi Deda,
    sorry, you were right - I forgot to copy latest database.dll in my link folder - it IS there .... thanks; will now try to use it (currently fighting with filling the facadelist...
    Any hint on the other question?
     

    Deda

    Lead Dev MP1 Videos
  • Premium Supporter
  • March 18, 2009
    2,423
    2,385
    Zagreb
    Home Country
    Croatia Croatia
    Re: AW: How to Video database section and My Movies get to life

    Thanks a lot. May I post another question:
    If I want to display the actor's movies (from table ActorinfoMovies by Actorid) and their local availability - is there a class to use or do I need to check the movies against the movies-table?
    Result should be a list of the movies belonging to an actor (from actorinfomovies) with a status if that movie is locally available (thus in movie)

    No, there is not direct class and I banged my head to the wall how to do it for a few days. As this was impossible with original tables, I had to add IMDBid column for every movie in actor info table and after I did it with method: GetMoviesByFilter(string sql, out ArrayList movies, bool actorTable, bool movieinfoTable, bool genreTable) in this case i populate datagrid with movies and mark movie in collection.

    Code:
            IMDBActor actdetail = new IMDBActor();
            actdetail = VideoDatabase.GetActorInfo(actorID);
            // If no detail, finish
            if (actdetail == null)
            {
              return;
            }
            // Populate datagrid
            for (int i = 0; i < actdetail.Count; i++)
            {
              dgActorMovies.Rows.Add();
              dgActorMovies.Rows[i].Cells[0].Value = actdetail[i].Year.ToString();
              dgActorMovies.Rows[i].Cells[1].Value = actdetail[i].MovieTitle;
              dgActorMovies.Rows[i].Cells[1].ToolTipText = "http://www.imdb.com/title/" + actdetail[i].imdbID;
              dgActorMovies.Rows[i].Cells[2].Value = actdetail[i].Role;
              dgActorMovies.Rows[i].Cells[3].Value = actdetail[i].imdbID;
    
              // Mark movie in our collection (compare between movieinfo table IMDBid column and actordetail movie IMDBid  
              // column)
              ArrayList movies = new ArrayList();
              string sql = "SELECT * FROM movieinfo WHERE IMDBID = '" + actdetail[i].imdbID + "'";
              VideoDatabase.GetMoviesByFilter(sql, out movies, false, true, false);
              // Bold and blue as movie in collection
              if (movies.Count > 0)
              {
                dgActorMovies.Rows[i].DefaultCellStyle.ForeColor = Color.Blue;
                dgActorMovies.Rows[i].DefaultCellStyle.Font = new Font(dgActorMovies.Font, FontStyle.Bold);
              }
            }
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,159
    750
    AW: How to Video database section and My Movies get to life

    Hmmm, of course, comparing the IMDBid is a reliable thing .... IF it's available. If it's missing, the movies will be missing. On the other hand, comparing by e.g. movie title plus year gives probably only bad hits ... indeed this is difficult...
     

    Deda

    Lead Dev MP1 Videos
  • Premium Supporter
  • March 18, 2009
    2,423
    2,385
    Zagreb
    Home Country
    Croatia Croatia
    Well yes, I wondered myself what to use to explicitly distinguish movies in tables because of comparing and other fetch issue. As a user I don't like to click 1000 times just to confirm something or to get some strange result just because of name comparing so I involved in all fetch parts IMDBid as this is widely used number in many internet movie pages. So IMDB script put for every movie that ID and to fetch covers, fanarts and actors with details (TMDB and IMPAwards use those numbers, also many movie subtitles web sites) is a easy and 100% correct. If there is no IMDBid then all is guessing and needs to be recheck (I left that option too but this is just a additional function which needs to be user validated as today there is so many movies with equal or similar name).
     

    Guzzi

    Retired Team Member
  • Premium Supporter
  • August 20, 2007
    2,159
    750
    AW: How to Video database section and My Movies get to life

    You're probably right - it's a good thing to rely on a 100% match, as far as it's possible.
    Regarding lot's of movies etc. - here's the stats of IMDB ;-) ... Database Statistics
    Thanks Deda for the great work you do ...
     

    Users who are viewing this thread

    Top Bottom