MediaPortal.Plugins.MovingPictures.DataProviders.DataProviderManager.ArrangeDataProviders C# (CSharp) Method

ArrangeDataProviders() public method

public ArrangeDataProviders ( string languageCode ) : void
languageCode string
return void
        public void ArrangeDataProviders(string languageCode)
        {
            foreach (DataType currType in Enum.GetValues(typeof(DataType))) {
                int nextRank = 10;
                foreach (DBSourceInfo currSource in getEditableList(currType)) {
                    // special case for themoviedb provider. should always be used for details - supports all languages
                    if (currSource.Provider is TheMovieDbProvider && currType == DataType.DETAILS) {
                        currSource.SetPriority(currType, 1);
                        currSource.Commit();
                    }

                    // special case for imdb provider. should always be used as a last resort details provider
                    else if (currSource.IsScriptable() && ((ScriptableProvider)currSource.Provider).ScriptID == 874902 && currType == DataType.DETAILS) {
                        if (languageCode != "en") {
                            currSource.SetPriority(currType, 98);
                            currSource.Commit();
                        }
                        else {
                            currSource.SetPriority(currType, 2);
                            currSource.Commit();
                        }
                    }

                    // special case for themoviedb provider. should always be used for covers and backdrops
                    else if (currSource.Provider is TheMovieDbProvider && (currType == DataType.COVERS || currType == DataType.BACKDROPS)) {
                        currSource.SetPriority(currType, 2);
                        currSource.Commit();
                    }

                    // special case for fanart.tv provider. should always be used for covers and backdrops
                    else if ((currType == DataType.COVERS || currType == DataType.BACKDROPS) && currSource.Provider is FanartTVProvider) {
                        currSource.SetPriority(currType, 3);
                        currSource.Commit();
                    }

                    // not a generic language script and not for the selected language, disable
                    else if (currSource.Provider.LanguageCode != "" &&
                             currSource.Provider.LanguageCode != "various" &&
                             currSource.Provider.LanguageCode != languageCode) {

                        currSource.SetPriority(currType, -1);
                        currSource.Commit();
                    }

                    // valid script, enable
                    else {
                        if (currSource.Provider is LocalProvider) {
                            currSource.SetPriority(currType, 0);
                            currSource.Commit();
                        }
                        else if (currSource.Provider is MyVideosProvider) {
                            currSource.SetPriority(currType, 99);
                            currSource.Commit();
                        }
                        else if (currSource.Provider.LanguageCode == "" || currSource.Provider.LanguageCode == "various") {
                            currSource.SetPriority(currType, 50 + nextRank++);
                            currSource.Commit();
                        }
                        else {
                            currSource.SetPriority(currType, nextRank++);
                            currSource.Commit();
                        }
                    }
                }

                // sort and normalize
                getEditableList(currType).Sort(sorters[currType]);
                normalizePriorities();
            }
        }