// ReSharper disable InconsistentNaming


        public static void ImportMediaFilesMAIN
            (IEnumerable<string> combinedSceneTags, Importer importer)
        {


            string pluginpath;

            var mediaSnapshotsFI =
                MediaImportingEngineHelpers.LoadMediaSnapshots(out pluginpath);


            #region Set EnableMediaImporter flag
            if (
            (MediaImportersAndUpdatersCoreSettings.EnableMovieImporter
            && MediaSectionsAllocator.MoviesSection != null) 
            ||
            (MediaImportersAndUpdatersCoreSettings.EnableTvSeriesImporter
            && MediaSectionsAllocator.TvEpisodesSection != null)
            ||
            (MediaImportersAndUpdatersCoreSettings.EnableMusicImporter 
            && MediaSectionsAllocator.MusicSection != null)
           )
            { MediaImportersAndUpdatersCoreSettings.EnableMediaImporters = true; }
            else MediaImportersAndUpdatersCoreSettings.EnableMediaImporters = false;
            #endregion


            #region Return Cases
            if (!MediaImportersAndUpdatersCoreSettings.EnableMediaImporters)
                return;

            Debugger.LogMessageToFile("Media File Importer is enabled.");
            if (MediaImportersAndUpdatersCoreSettings.RootMediaFolders == null || MediaImportersAndUpdatersCoreSettings.RootMediaFolders.Length == 0)
                return;

#endregion


            #region Declare Vars
            string[] filmLocations;
            string[] musicLocations;
            string[] tvShowsLocations;
            
            IList<string> extensionsToIgnore;
            string[] videoExtensions;
            string[] videoExtensionsCommon;
            string[] audioExtensions;
            #endregion



            MediaImportingEngineHelpers.PerformPreImportCaching
                (mediaSnapshotsFI, pluginpath, out filmLocations,
                out musicLocations, out tvShowsLocations, out extensionsToIgnore,
                out videoExtensions, out audioExtensions, out videoExtensionsCommon);



            ImportMoviesSeriesMusic(combinedSceneTags, videoExtensions, 
                audioExtensions, pluginpath, filmLocations,
                ref extensionsToIgnore, musicLocations, tvShowsLocations,
                videoExtensionsCommon, importer);
       
        
        
        }
        internal static void RetrieveMediaLocations(Importer importer)
        {


            string importRootFoldersStr = API.Folders(importer.Ibs, importer.MfSettingsMovies) + '|'
                                          + API.Folders(importer.Ibs, importer.MfSettingsTvShows) + '|'
                                          + API.Folders(importer.Ibs, importer.MfSettingsMusic);

            MediaImportersAndUpdatersCoreSettings.RootMediaFolders = importRootFoldersStr.Split(new[] { '|' }, StringSplitOptions.None);

            try
            {


                Settings.FilmsFolders = MediaFolders.API.Folders
                    (importer.Ibs, importer.MfSettingsMovies)
                    .Split(new[] { '|' }, StringSplitOptions.None);
               

                //TODO: Also retrieve and use Music folders!

            }
            catch (Exception e)
            {
                //TODO: This message should be a Balloon Tip.

                // ReSharper disable LocalizableElement
                MessageBox.Show("The media importing engine was unable to retrieve the directories containing your Movies media files. " +
                                "Please make sure that you have provided your media locations" +
                                "for this type of your media files in the plugin's 'Media Folders' settings group and try again.",
                                "Movies Media Folders were not specified", MessageBoxButtons.OK);
                // ReSharper restore LocalizableElement
                          

                Debugger.LogMessageToFile("[Media Importing Engine] Unable to retrieve user's media files locations." +
                                          "The error was: " + Environment.NewLine + e);


            }

            try
            {

                Settings.TvShowsFolders = MediaFolders.API.Folders
                    (importer.Ibs, importer.MfSettingsTvShows)
                    .Split(new[] { '|' }, StringSplitOptions.None);

            }
            catch (Exception e)
            {

                //TODO: This message should be a balloon tip.

                // ReSharper disable LocalizableElement
                MessageBox.Show("The media importing engine was unable to retrieve the directories containing your TV Shows media files. " +
                                "Please make sure that you have provided your media locations" +
                                "for this type of your media files in the plugin's 'Media Folders' settings group and try again.",
                                "TV Shows Media Folders were not specified", MessageBoxButtons.OK);
                // ReSharper restore LocalizableElement


                Debugger.LogMessageToFile("[Media Importing Engine] Unable to retrieve user's media files locations." +
                                          "The error was: " + Environment.NewLine + e);



            }


            try
            {
                Settings.MusicFolders = 
                    API.Folders(importer.Ibs, importer.MfSettingsMusic)
                    .Split(new[] { '|' }, StringSplitOptions.None);

            }
            catch (Exception e)
            {
                //TODO: This message should be a balloon tip.
                // ReSharper disable LocalizableElement
                MessageBox.Show("The media importing engine was unable to retrieve the directories containing your Music media files. " +
                                "Please make sure that you have provided your media locations" +
                                "for this type of your media files in the plugin's 'Media Folders' settings group and try again.",
                                "Music Media Folders were not specified", MessageBoxButtons.OK);
                // ReSharper restore LocalizableElement


                Debugger.LogMessageToFile("[Media Importing Engine] Unable to retrieve user's media files locations." +
                                          "The error was: " + Environment.NewLine + e);



            }



        }
        private static void ImportMoviesSeriesMusic
            (IEnumerable<string> combinedSceneTags, string[] videoExtensions,
            string[] audioExtensions, string pluginpath, string[] filmLocations,
            ref IList<string> extensionsToIgnore, string[] musicLocations,
            string[] tvShowsLocations, IEnumerable<string> videoExtensionsCommon, Importer importer)
        {
            ImportingEngineHelpers.BeginUpdatingSections();


            if (MediaImportersAndUpdatersCoreSettings.EnableMovieImporter)
            {


                Helpers.UpdateProgress
                    ("Importing Media Files...",
                    "Preparing to Import Movies...",null);
              
                Thread.Sleep(200);

                Settings.NowImportingMediaType = "Movies";

                DirectoryScanner.ScanMediaDirectories(Settings.FilmsFolders,
                    ref extensionsToIgnore, filmLocations, tvShowsLocations,
                    musicLocations, videoExtensions, audioExtensions,
                    combinedSceneTags, videoExtensionsCommon, importer);
            }


            if (MediaImportersAndUpdatersCoreSettings.EnableTvSeriesImporter)
            {
                Helpers.UpdateProgress("Importing Media Files...",
                    "Preparing to Import TV Shows...", null);
                Thread.Sleep(200);

                Settings.NowImportingMediaType = "TvShows";

                DirectoryScanner.ScanMediaDirectories(Settings.TvShowsFolders,
                    ref extensionsToIgnore, filmLocations, tvShowsLocations,
                    musicLocations, videoExtensions, audioExtensions,
                    combinedSceneTags, videoExtensionsCommon, importer);
            }

            if (MediaImportersAndUpdatersCoreSettings.EnableMusicImporter)
            {

                Helpers.UpdateProgress("Importing Media Files...",
                    "Preparing to Import Music...", null);
                Thread.Sleep(200);

                Settings.NowImportingMediaType = "Music";

                DirectoryScanner.ScanMediaDirectories(Settings.MusicFolders,
                        ref extensionsToIgnore, filmLocations, tvShowsLocations,
                        musicLocations, videoExtensions, audioExtensions,
                        combinedSceneTags, videoExtensionsCommon, importer);
            }



            MediaImportingEngineHelpers
                .WriteNonMediaExtensionsToFile
                (ref extensionsToIgnore, pluginpath);


            ImportingEngineHelpers.FinishUpdatingSections();


        }