Database: Refactor MP1 database for multi seat usage (2 Viewers)

Anthony Vaughan

MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    But as @ajs has said, we must not remove function merely because we personally do not see the value of it.
    You seem to be under the impression that I am changing functionality. That is not the case. I am pointing out where there is functionality that doesn't do what it says on the tin and suggesting that we remove the redundant stuff - there's so much stuff going on that we need to get rid of the clutter when it serves no purpose. I have also, on occasion, questioned whether the original purpose is really valid or necessary.

    I've been taking an even closer look at scanning. This is what is does at the moment. When there is no information about a movie in the database when you do a scan, the configuration app searches the internet for data based on which scripts you choose to use. You are shown a list of possible titles to choose from. You choose the title you want information for and the system goes and gets that information, loading into the database. This information includes getting actor information - this is the bit that takes forever. There is an option (checkbox) that offers fetch actor information when updating movies. When you run a scan using the refresh option, the same process happens - but it still gets everything - again.

    Here's how I would do things in an ideal world.:
    a) Use the list titles option for the first time around; i.e. populating the movie information - but making fetching actor information optional;
    b) Use refresh to get the actor information - without having to select from a list of titles.

    Here is my reasoning. When I have a load of new movies to scan in, I don't want that process to take forever because the main task here is to get the right title for each movie and to get the movie information into the database - quickly. To cater for only adding a few movies, I would have a checkbox that offers actor downloading as an option. Then I would use the refresh option to load actor information (optionally) when we know that we have the desired titles already set up. In other words, I would change the existing checkbox to refer to fetching actor data irrespective of whether you are scanning for the first time or doing a refresh. Does that make sense to you? For those of you that aren't interested in getting actor information you simply never choose to check the fetch actors option.

    Okay. That's the first step. Now for what the application actually does. When you press the Update Database From Selected Shares button, the application calls a method called RebuildDatabase().

    This calls the following code:

    IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, true, true,
    false);

    Here is the definition for that method

    public static bool ScanIMDB(IMDB.IProgress progress, ArrayList paths, bool fuzzyMatching, bool skipExisting,
    bool getActors, bool refreshDBonly)
    {

    Notice the fifth parameter - bool getActors. See how it is hard-coded to true. This parameter is passed on to two other methods:

    GetInfoFromIMDB(progress, ref movieDetails, fuzzyMatching, getActors);

    and then

    if (RefreshIMDB(progress, ref movieDetails, isFuzzyMatching, getActors, addToDB))

    This is why you always get actor data - even when you don't want or need it. This is the required code change:

    IMDBFetcher.ScanIMDB(this, availablePaths, _isFuzzyMatching, true, chbFetchActors.Checked,
    false);

    Job done. But, hold on a minute! I'm still getting actor data! What's going on? Here's the code that gets actors:

    if (VideoDatabase.CheckMovieImdbId(_movieDetails.IMDBNumber) && _addToDatabase)
    {
    line1 = GUILocalizeStrings.Get(344); // **Progress bar actors start sets actual value to 0
    OnProgress(line1, _url.Title, string.Empty, 60);
    // Do not save movieinfo to database when fetching actors (false paramater) because we don't have all
    // movie metadata yet
    FetchActorsInMovie(false);
    }

    No do I need to get actors or not - it just does it anyway. Here's the fix:

    if (_getActors)
    {
    if (VideoDatabase.CheckMovieImdbId(_movieDetails.IMDBNumber) && _addToDatabase)
    {
    line1 = GUILocalizeStrings.Get(344); // **Progress bar actors start sets actual value to 0
    OnProgress(line1, _url.Title, string.Empty, 60);
    // Do not save movieinfo to database when fetching actors (false paramater) because we don't have all
    // movie metadata yet
    FetchActorsInMovie(false);
    }
    }

    _getActors is set in the RefreshIMDB

    fetcher._getActors = getActors;

    The _getActors setting was being ignored.

    But NOOOOO! It still doesn't work. As with everything else in this application everything is SOOOOOO complicated. (My motto is keep it SIMPLE!) The current application stores parameters like this as settings - even when the option is clearly global to the application. Here is a perfect example. When you select whether or not to fetch actors, you are telling the whole configuration application that you don't want actor data for that action. But the settings are stored as an instance of a fetcher; meaning that the setting keeps getting overridden back to false or to the default setting. But this configuration is really at the database level. My solution is to declare a boolean in VideoDatabase called _getActorsOnScan (property GetActorsOnScan). The configuration app sets this to false when it is instantiated. Now, when the checkbox is set ON or OFF, GetActorsOnScan is turned ON/OFF. Now, when you want to scan in actors, or not, the checkbox setting is what determines what happens.

    Now, I've got to look at how easy it would be to not keep checking titles for a refresh - on the basis that once you have scanned in movie info, you have already chosen which title you want data for. Then, if you do want to change the title, you can use the Lookup facility for individual movies to make custom changes.

    This is what I have been trying to do - get things that seemed to work, but don't, to work. At the same time, I think my option is more user friendly because you get to choose whether to download actor data or not, under all scenarios; not just on refresh. And, when you want to, you can still download actor data for individual or all movies. What wrong with that?
     

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    BTW, the screen now looks like this:

    1636280443200.png
     

    doskabouter

    Development Group
  • Team MediaPortal
  • September 27, 2009
    4,654
    3,120
    Nuenen
    Home Country
    Netherlands Netherlands
    Long story about stuff not working as expected
    I think this is because it touches the main reason for a mediacenter application, being able to have a collection of movies with all the bells and whistles that you can imagine.
    So this has probably been implemented well over 15 (20 maybe?) years ago and everyone with write access to the source added his or hers personal favorite to it.
    This could very well be the oldest and most changed part of the code base present, so I can really imagine why the code is as it is now.
    And as long as nothing really breaks for the end-users, you have my blessing (and trust) to make this into a more solid piece of code.
     

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    As far as I can see, all parts are in MP client, not in TVEngine nor TVplugin, right ?
    Correct. My changes only affect the client and is targeted at making the client multi-user with the client databases for a household being in a central location.
     

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    I think I may have a way to speed up scanning that is also flexible. As I mentioned above, when you scan for the first time (movie info data not in the database) and there are conflicts, you choose which title you want data for and the scan process goes and gets the data and populates movie info. When you select the title, the internal processing sets up an object (IMDBUrl) that contains the information required to scan for that title - like which database to get the title from (e.g. TI_MDB).

    I was thinking that if we store that IMDBUrl in the database for that movie, then, when we do a refresh, the scan can bypass all of the selection process and get the data. At the same time, you can choose to fetch actor data if you want. When you want to change the title for a movie you already have in the database, then use Lookup to get the data for that single movie.

    Does that sound like a plan? I think it addresses all scenarios and will be a lot faster. BTW, since I have made fetch actors optional, the scan process is 100's of percent faster.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    To me, the best solution would seem to be to offer this as an option for people who don't want to use all of the old extensions but want to have a multi-user setup.
    This is not realistic, we have 99% of the old plugins, of which I think all used by different people, and the source code is probably only for 50%
     

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    This is not realistic, we have 99% of the old plugins, of which I think all used by different people, and the source code is probably only for 50%
    Well, as I have said. I'm not bothered either way. I will have the system I want and others can decide what they want to do.
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    Use the list titles option for the first time around; i.e. populating the movie information - but making fetching actor information optional;
    That's exactly how it works now.
    We get information about the movie, we get a list of actors, and we fill out a table. If there is a checkbox to get information about actors, we get information about actors.
    Use refresh to get the actor information - without having to select from a list of titles.
    If there is no information (there is no checkbox), the first time you access the actor, the MF tries to get information about him. If he has no IMDB ID, he looks for similar ones and asks. If there is an IMDB ID, we just get information by it without any dialogs.
    This is exactly how MP1 works now.
    This is why you always get actor data - even when you don't want or need it. This is the required code change:
    As far as I remember, here MP1 gets a list of actors for this movie, and if there is a checkbox then also information about the actor.
    The _getActors setting was being ignored.
    This is the cast list, you can't remove it, because then we would have a movie without actors.
    What wrong with that?
    We don't have Actors, which is bad ... And there are no roles. :)
     

    ajs

    Development Group
  • Team MediaPortal
  • February 29, 2008
    16,059
    11,141
    Kyiv
    Home Country
    Ukraine Ukraine
    Well, as I have said. I'm not bothered either way. I will have the system I want and others can decide what they want to do.
    Well, that's the problem, we do MP1 first of all for ourselves, secondly for the User. But there will be no user, there will be no MP1, and there will be no MP1, there will be no us in this forum. You do not use plugins, I do. Others use other plugins, others, others. And it is desirable to leave as much compatibility as possible MP1 and its plugins, which is the strength of MP1.
     

    Anthony Vaughan

    MP Donator
  • Premium Supporter
  • June 25, 2015
    584
    292
    Home Country
    United Kingdom United Kingdom
    That's fine. As I've already said. I'm offering the option. If you aren't interested, then so be-it.

    I think there may be other users who disagree with you.

    I'm not going to push this; I'm just keeping everyone informed.

    One thing I won't do is waste my time arguing about everything.
     

    Users who are viewing this thread

    Top Bottom